Merge branch 'joeyconfig'

This commit is contained in:
Joey Hess 2014-11-10 16:22:49 -04:00
commit 3145346fb8
2 changed files with 24 additions and 0 deletions

1
debian/changelog vendored
View File

@ -1,6 +1,7 @@
propellor (0.9.3) UNRELEASED; urgency=medium
* Added prosody module, contributed by Félix Sipma.
* Can be used to configure tor hidden services. Thanks, Félix Sipma.
-- Joey Hess <joeyh@debian.org> Mon, 10 Nov 2014 11:15:27 -0400

View File

@ -16,5 +16,28 @@ isBridge = setup `requires` Apt.installed ["tor"]
, "Exitpolicy reject *:*"
] `onChange` restarted
hiddenServiceAvailable :: FilePath -> Int -> Property
hiddenServiceAvailable dir port = hiddenServiceHostName prop
where
prop = "/etc/tor/torrc" `File.containsLines`
[ "HiddenServiceDir " ++ dir
, "HiddenServicePort " ++ show port ++ " 127.0.0.1:" ++ show port
]
`describe` "hidden service available"
`onChange` Service.reloaded "tor"
hiddenServiceHostName p = adjustProperty p $ \satisfy -> do
r <- satisfy
h <- liftIO $ readFile (dir </> "hostname")
warningMessage $ unlines ["hidden service hostname:", h]
return r
hiddenService :: FilePath -> Int -> Property
hiddenService dir port = "/etc/tor/torrc" `File.containsLines`
[ "HiddenServiceDir " ++ dir
, "HiddenServicePort " ++ show port ++ " 127.0.0.1:" ++ show port
]
`describe` ("hidden service (" ++ dir ++ " " ++ show port ++ ") available")
`onChange` Service.reloaded "tor"
restarted :: Property
restarted = Service.restarted "tor"