diff options
| author | Joey Hess <joeyh@joeyh.name> | 2017-02-15 15:22:13 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2017-02-15 15:22:13 -0400 |
| commit | 4f29d576115d1bcbed60eacb3642523f1b5f480f (patch) | |
| tree | cb4b5ada932bbdea7c4ee97008fc871cd810b543 /src/Propellor/Property/Tor.hs | |
| parent | 6e3192f0d2e063f07d7a5d2b96648e9167cc576a (diff) | |
| parent | b29bab35747e6345a4818e5a77c53d029562e3c3 (diff) | |
Merge branch 'master' into joeyconfig
Diffstat (limited to 'src/Propellor/Property/Tor.hs')
| -rw-r--r-- | src/Propellor/Property/Tor.hs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/Propellor/Property/Tor.hs b/src/Propellor/Property/Tor.hs index ea9f39ed..db71c87a 100644 --- a/src/Propellor/Property/Tor.hs +++ b/src/Propellor/Property/Tor.hs @@ -124,22 +124,30 @@ bandwidthRate' s divby = case readSize dataUnits s of -- If used without `hiddenServiceData`, tor will generate a new -- private key. hiddenService :: HiddenServiceName -> Port -> Property DebianLike -hiddenService hn (Port port) = ConfFile.adjustSection - (unwords ["hidden service", hn, "available on port", show port]) +hiddenService hn port = hiddenService' hn [port] + +hiddenService' :: HiddenServiceName -> [Port] -> Property DebianLike +hiddenService' hn ports = ConfFile.adjustSection + (unwords ["hidden service", hn, "available on ports", intercalate "," (map show ports')]) (== oniondir) (not . isPrefixOf "HiddenServicePort") - (const [oniondir, onionport]) - (++ [oniondir, onionport]) + (const (oniondir : onionports)) + (++ oniondir : onionports) mainConfig `onChange` restarted where oniondir = unwords ["HiddenServiceDir", varLib </> hn] - onionport = unwords ["HiddenServicePort", show port, "127.0.0.1:" ++ show port] + onionports = map onionport ports' + ports' = sort ports + onionport port = unwords ["HiddenServicePort", show port, "127.0.0.1:" ++ show port] -- | Same as `hiddenService` but also causes propellor to display -- the onion address of the hidden service. hiddenServiceAvailable :: HiddenServiceName -> Port -> Property DebianLike -hiddenServiceAvailable hn port = hiddenServiceHostName $ hiddenService hn port +hiddenServiceAvailable hn port = hiddenServiceAvailable' hn [port] + +hiddenServiceAvailable' :: HiddenServiceName -> [Port] -> Property DebianLike +hiddenServiceAvailable' hn ports = hiddenServiceHostName $ hiddenService' hn ports where hiddenServiceHostName p = adjustPropertySatisfy p $ \satisfy -> do r <- satisfy |
