remotedaemon: git change detection over tor hidden service

This commit is contained in:
Joey Hess 2016-12-09 16:02:43 -04:00
parent f7687e0876
commit 2c907fff51
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
8 changed files with 116 additions and 46 deletions

View file

@ -37,15 +37,18 @@ class FormatP2PAddress a where
instance FormatP2PAddress P2PAddress where
formatP2PAddress (TorAnnex (OnionAddress onionaddr) onionport) =
"tor-annex::" ++ onionaddr ++ ":" ++ show onionport
torAnnexScheme ++ ":" ++ onionaddr ++ ":" ++ show onionport
unformatP2PAddress s
| "tor-annex::" `isPrefixOf` s = do
| (torAnnexScheme ++ ":") `isPrefixOf` s = do
let s' = dropWhile (== ':') $ dropWhile (/= ':') s
let (onionaddr, ps) = separate (== ':') s'
onionport <- readish ps
return (TorAnnex (OnionAddress onionaddr) onionport)
| otherwise = Nothing
torAnnexScheme :: String
torAnnexScheme = "tor-annex:"
instance FormatP2PAddress P2PAddressAuth where
formatP2PAddress (P2PAddressAuth addr authtoken) =
formatP2PAddress addr ++ ":" ++ T.unpack (fromAuthToken authtoken)