]> dgit.raspbian.org Git - git-annex.git/commitdiff
factor out Annex.Proxy
authorJoey Hess <joeyh@joeyh.name>
Tue, 18 Jun 2024 14:51:37 +0000 (10:51 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 18 Jun 2024 14:51:37 +0000 (10:51 -0400)
Annex/Proxy.hs [new file with mode: 0644]
Command/P2PStdIO.hs
git-annex.cabal

diff --git a/Annex/Proxy.hs b/Annex/Proxy.hs
new file mode 100644 (file)
index 0000000..6eacc04
--- /dev/null
@@ -0,0 +1,27 @@
+{- proxying
+ -
+ - Copyright 2024 Joey Hess <id@joeyh.name>
+ -
+ - Licensed under the GNU AGPL version 3 or higher.
+ -}
+
+module Annex.Proxy where
+
+import Annex.Common
+import P2P.Proxy
+import P2P.Protocol
+import P2P.IO
+import qualified Remote
+import Remote.Helper.Ssh (openP2PShellConnection', closeP2PShellConnection)
+
+-- FIXME: Support special remotes.
+proxySshRemoteSide :: ProtocolVersion -> Remote -> Annex RemoteSide
+proxySshRemoteSide clientmaxversion remote = mkRemoteSide (Remote.uuid remote) $
+       openP2PShellConnection' remote clientmaxversion >>= \case
+               Just conn@(OpenConnection (remoterunst, remoteconn, _)) ->
+                       return $ Just 
+                               ( remoterunst
+                               , remoteconn
+                               , void $ liftIO $ closeP2PShellConnection conn
+                               )
+               _  -> return Nothing
index 21237813187fe4886aea9b8536f492852971d4c9..eea5ca33404433edadb630701b8d35e91f081a21 100644 (file)
@@ -13,9 +13,9 @@ import P2P.Annex
 import P2P.Proxy
 import qualified P2P.Protocol as P2P
 import qualified Annex
+import Annex.Proxy
 import Annex.UUID
 import qualified CmdLine.GitAnnexShell.Checks as Checks
-import Remote.Helper.Ssh (openP2PShellConnection', closeP2PShellConnection)
 import Logs.Location
 import Logs.Cluster
 import Annex.Cluster
@@ -94,18 +94,6 @@ proxyClientSide clientuuid = do
        clientrunst <- liftIO (mkRunState $ Serving clientuuid Nothing)
        return $ ClientSide clientrunst (stdioP2PConnection Nothing)
 
--- FIXME: Support special remotes.
-proxySshRemoteSide :: P2P.ProtocolVersion -> Remote -> Annex RemoteSide
-proxySshRemoteSide clientmaxversion remote = mkRemoteSide (Remote.uuid remote) $
-       openP2PShellConnection' remote clientmaxversion >>= \case
-               Just conn@(P2P.IO.OpenConnection (remoterunst, remoteconn, _)) ->
-                       return $ Just 
-                               ( remoterunst
-                               , remoteconn
-                               , void $ liftIO $ closeP2PShellConnection conn
-                               )
-               _  -> return Nothing
-
 p2pErrHandler :: (a -> CommandPerform) -> Annex (Either ProtoFailure a) -> CommandPerform
 p2pErrHandler cont a = a >>= \case
        -- Avoid displaying an error when the client hung up on us.
index d04848b7a36b4d1cb24b59b422e6b53b9c917447..51ef9a0f443ad762b091b90a71b1cadcc00b1cf1 100644 (file)
@@ -550,6 +550,7 @@ Executable git-annex
     Annex.Path
     Annex.Perms
     Annex.PidLock
+    Annex.Proxy
     Annex.Queue
     Annex.ReplaceFile
     Annex.RemoteTrackingBranch