Tor: hidden service

Signed-off-by: Félix Sipma <felix.sipma@no-log.org>
This commit is contained in:
Félix Sipma 2014-11-10 20:39:15 +01:00 committed by Joey Hess
parent 9608a390d2
commit 053183d44b
1 changed files with 23 additions and 0 deletions

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"