diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-12-09 16:02:43 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-12-09 16:02:43 -0400 |
commit | 46f3063131f7711208c1134b31caf999e375306d (patch) | |
tree | 47ab66581b0d2de95865b0f7948db041f6589935 /P2P | |
parent | 1eeae43d88c924dfac7c004ff7aeb67e17c52a13 (diff) |
remotedaemon: git change detection over tor hidden service
Diffstat (limited to 'P2P')
-rw-r--r-- | P2P/Address.hs | 7 | ||||
-rw-r--r-- | P2P/Protocol.hs | 10 |
2 files changed, 15 insertions, 2 deletions
diff --git a/P2P/Address.hs b/P2P/Address.hs index 09ffc7973..1b1f66059 100644 --- a/P2P/Address.hs +++ b/P2P/Address.hs @@ -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) diff --git a/P2P/Protocol.hs b/P2P/Protocol.hs index d8be3ff42..c3c362f37 100644 --- a/P2P/Protocol.hs +++ b/P2P/Protocol.hs @@ -441,6 +441,16 @@ sendSuccess :: Bool -> Proto () sendSuccess True = net $ sendMessage SUCCESS sendSuccess False = net $ sendMessage FAILURE +notifyChange :: Proto (Maybe ChangedRefs) +notifyChange = do + net $ sendMessage NOTIFYCHANGE + ack <- net receiveMessage + case ack of + CHANGED rs -> return (Just rs) + _ -> do + net $ sendMessage (ERROR "expected CHANGED") + return Nothing + connect :: Service -> Handle -> Handle -> Proto ExitCode connect service hin hout = do net $ sendMessage (CONNECT service) |