aboutsummaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-12-06 15:49:39 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-12-06 15:50:02 -0400
commit12a58f1922d30995019ca73c462f6a9937413f2b (patch)
tree4e9a54d7ff0f4d3a204437ef295c67f7f97f5854 /Remote
parent5258f572d494d015c6c6e60c37a215bb95048bbd (diff)
need to auth with the peer
Diffstat (limited to 'Remote')
-rw-r--r--Remote/P2P.hs19
1 files changed, 16 insertions, 3 deletions
diff --git a/Remote/P2P.hs b/Remote/P2P.hs
index 0c7ca0574..68b75924f 100644
--- a/Remote/P2P.hs
+++ b/Remote/P2P.hs
@@ -16,13 +16,16 @@ import qualified P2P.Protocol as P2P
import P2P.Address
import P2P.Annex
import P2P.IO
+import P2P.Auth
import Types.Remote
import Types.GitConfig
import qualified Git
+import Annex.UUID
import Config
import Config.Cost
import Remote.Helper.Git
import Utility.Metered
+import Utility.AuthToken
import Types.NumCopies
import Control.Concurrent
@@ -128,8 +131,7 @@ runProto' a (OpenConnection conn) = do
if isJust r
then return (OpenConnection conn, r)
else do
- liftIO $ hClose (connIhdl conn)
- liftIO $ hClose (connOhdl conn)
+ liftIO $ closeConnection conn
return (ClosedConnection, r)
-- Uses an open connection if one is available in the ConnectionPool;
@@ -165,5 +167,16 @@ openConnection addr = do
g <- Annex.gitRepo
v <- liftIO $ tryNonAsync $ connectPeer g addr
case v of
- Right conn -> return (OpenConnection conn)
+ Right conn -> do
+ myuuid <- getUUID
+ authtoken <- fromMaybe nullAuthToken
+ <$> loadP2PRemoteAuthToken addr
+ res <- liftIO $ runNetProto conn $
+ P2P.auth myuuid authtoken
+ case res of
+ Just (Just _theiruuid) ->
+ return (OpenConnection conn)
+ _ -> do
+ liftIO $ closeConnection conn
+ return ClosedConnection
Left _e -> return ClosedConnection