diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-02-27 19:14:20 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-02-27 19:14:20 -0400 |
| commit | d67d59a25a951f236ee9bde74fd29ed773b3dd86 (patch) | |
| tree | 53974ecbdb867d54edca7fdf2506aa9ce20e1eb8 /src | |
| parent | f0a4e642c490c4a91e62788e0c46f192b402e7f0 (diff) | |
propellor spin
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor/Property/Tor.hs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/Propellor/Property/Tor.hs b/src/Propellor/Property/Tor.hs index 27c9761f..3a0926be 100644 --- a/src/Propellor/Property/Tor.hs +++ b/src/Propellor/Property/Tor.hs @@ -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 |
