propellor spin

This commit is contained in:
Joey Hess 2015-02-27 19:14:20 -04:00
parent f0a4e642c4
commit d67d59a25a
Failed to extract signature
2 changed files with 15 additions and 6 deletions

View File

@ -86,7 +86,7 @@ clam = standardSystem "clam.kitenet.net" Unstable "amd64"
& Network.ipv6to4
& Tor.isRelay
& Tor.named "kite1"
& Tor.bandwidthRate "128 kibibytes"
& Tor.bandwidthRate (Tor.PerMonth "400 GB")
& Docker.configured
& Docker.garbageCollected `period` Daily

View File

@ -80,15 +80,24 @@ configured settings = File.fileProperty "tor configured" go mainConfig
toconfig (k, v) = k ++ " " ++ v
fromconfig = separate (== ' ')
type BwLimit = String
data BwLimit
= PerSecond String
| PerDay String
| PerMonth String
-- | Limit incoming and outgoing traffic to the specified
-- amount, per second.
-- amount each.
--
-- For example, "30 kibibytes" is the minimum limit for a useful relay.
-- For example, PerSecond "30 kibibytes" is the minimum limit
-- for a useful relay.
bandwidthRate :: BwLimit -> Property NoInfo
bandwidthRate s = case readSize dataUnits s of
Just sz -> configured [("BandwidthRate", show sz ++ " bytes")]
bandwidthRate (PerSecond s) = bandwidthRate' s 1
bandwidthRate (PerDay s) = bandwidthRate' s (24*60*60)
bandwidthRate (PerMonth s) = bandwidthRate' s (31*24*60*60)
bandwidthRate' :: String -> Integer -> Property NoInfo
bandwidthRate' s divby = case readSize dataUnits s of
Just sz -> configured [("BandwidthRate", show (sz `div` divby) ++ " bytes")]
Nothing -> property ("unable to parse " ++ s) noChange
hiddenServiceAvailable :: HiddenServiceName -> Int -> Property NoInfo