Merge branch 'joeyconfig'
This commit is contained in:
commit
bd7869c01c
|
@ -9,35 +9,44 @@ isBridge :: Property
|
||||||
isBridge = setup `requires` Apt.installed ["tor"]
|
isBridge = setup `requires` Apt.installed ["tor"]
|
||||||
`describe` "tor bridge"
|
`describe` "tor bridge"
|
||||||
where
|
where
|
||||||
setup = "/etc/tor/torrc" `File.hasContent`
|
setup = mainConfig `File.hasContent`
|
||||||
[ "SocksPort 0"
|
[ "SocksPort 0"
|
||||||
, "ORPort 443"
|
, "ORPort 443"
|
||||||
, "BridgeRelay 1"
|
, "BridgeRelay 1"
|
||||||
, "Exitpolicy reject *:*"
|
, "Exitpolicy reject *:*"
|
||||||
] `onChange` restarted
|
] `onChange` restarted
|
||||||
|
|
||||||
hiddenServiceAvailable :: FilePath -> Int -> Property
|
hiddenServiceAvailable :: HostName -> Int -> Property
|
||||||
hiddenServiceAvailable dir port = hiddenServiceHostName prop
|
hiddenServiceAvailable hn port = hiddenServiceHostName prop
|
||||||
where
|
where
|
||||||
prop = "/etc/tor/torrc" `File.containsLines`
|
prop = mainConfig `File.containsLines`
|
||||||
[ "HiddenServiceDir " ++ dir
|
[ unlines ["HiddenServiceDir", varLib </> hn]
|
||||||
, "HiddenServicePort " ++ show port ++ " 127.0.0.1:" ++ show port
|
, unlines ["HiddenServicePort", show port, "127.0.0.1:" ++ show port]
|
||||||
]
|
]
|
||||||
`describe` "hidden service available"
|
`describe` "hidden service available"
|
||||||
`onChange` Service.reloaded "tor"
|
`onChange` Service.reloaded "tor"
|
||||||
hiddenServiceHostName p = adjustProperty p $ \satisfy -> do
|
hiddenServiceHostName p = adjustProperty p $ \satisfy -> do
|
||||||
r <- satisfy
|
r <- satisfy
|
||||||
h <- liftIO $ readFile (dir </> "hostname")
|
h <- liftIO $ readFile (varLib </> hn </> "hostname")
|
||||||
warningMessage $ unlines ["hidden service hostname:", h]
|
warningMessage $ unlines ["hidden service hostname:", h]
|
||||||
return r
|
return r
|
||||||
|
|
||||||
hiddenService :: FilePath -> Int -> Property
|
hiddenService :: HostName -> Int -> Property
|
||||||
hiddenService dir port = "/etc/tor/torrc" `File.containsLines`
|
hiddenService hn port = mainConfig `File.containsLines`
|
||||||
[ "HiddenServiceDir " ++ dir
|
[ unlines ["HiddenServiceDir", varLib </> hn]
|
||||||
, "HiddenServicePort " ++ show port ++ " 127.0.0.1:" ++ show port
|
, unlines ["HiddenServicePort", show port, "127.0.0.1:" ++ show port]
|
||||||
]
|
]
|
||||||
`describe` ("hidden service (" ++ dir ++ " " ++ show port ++ ") available")
|
`describe` unlines ["hidden service available:", hn, show port]
|
||||||
`onChange` Service.reloaded "tor"
|
`onChange` restarted
|
||||||
|
|
||||||
restarted :: Property
|
restarted :: Property
|
||||||
restarted = Service.restarted "tor"
|
restarted = Service.restarted "tor"
|
||||||
|
|
||||||
|
mainConfig :: FilePath
|
||||||
|
mainConfig = "/etc/tor/torrc"
|
||||||
|
|
||||||
|
varLib :: FilePath
|
||||||
|
varLib = "/var/lib/tor"
|
||||||
|
|
||||||
|
varRun :: FilePath
|
||||||
|
varRun = "/var/run/tor"
|
||||||
|
|
Loading…
Reference in New Issue