diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-09-01 11:19:35 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-09-01 11:19:35 -0400 |
| commit | bc75f84f58aafaf7b69f20f1507df80dccc8023b (patch) | |
| tree | d247bfb83046d0b353d2acfba5bc7b12edd9b526 /src/Propellor/Property/Tor.hs | |
| parent | e350175be425e966bd81153580644c741a09eafb (diff) | |
Tor.hiddenServiceAvailable: The hidden service hostname file may not be available immedaitely after configuring tor; avoid ugly error in this case.
Diffstat (limited to 'src/Propellor/Property/Tor.hs')
| -rw-r--r-- | src/Propellor/Property/Tor.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Propellor/Property/Tor.hs b/src/Propellor/Property/Tor.hs index 951084b4..2fe97e4e 100644 --- a/src/Propellor/Property/Tor.hs +++ b/src/Propellor/Property/Tor.hs @@ -120,6 +120,9 @@ bandwidthRate' s divby = case readSize dataUnits s of Nothing -> property ("unable to parse " ++ s) noChange -- | Enables a hidden service for a given port. +-- +-- 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]) @@ -140,11 +143,13 @@ hiddenServiceAvailable hn port = hiddenServiceHostName $ hiddenService hn port where hiddenServiceHostName p = adjustPropertySatisfy p $ \satisfy -> do r <- satisfy - h <- liftIO $ readFile (varLib </> hn </> "hostname") - warningMessage $ unwords ["hidden service hostname:", h] + mh <- liftIO $ tryIO $ readFile (varLib </> hn </> "hostname") + case mh of + Right h -> warningMessage $ unwords ["hidden service hostname:", h] + Left _e -> warningMessage "hidden service hostname not available yet" return r --- | +-- | Load the private key for a hidden service from the privdata. hiddenServiceData :: IsContext c => HiddenServiceName -> c -> Property (HasInfo + DebianLike) hiddenServiceData hn context = combineProperties desc $ props & installonion "hostname" |
