proxyClientSide :: UUID -> Annex ClientSide
proxyClientSide clientuuid = do
clientrunst <- liftIO (mkRunState $ Serving clientuuid Nothing)
- return $ ClientSide clientrunst (stdioP2PConnection Nothing)
+ ClientSide clientrunst <$> liftIO (stdioP2PConnectionDupped Nothing)
p2pErrHandler :: Annex () -> (a -> CommandPerform) -> Annex (Either ProtoFailure a) -> CommandPerform
p2pErrHandler closeconn cont a = a >>= \case
{- P2P protocol, IO implementation
-
- - Copyright 2016-2018 Joey Hess <id@joeyh.name>
+ - Copyright 2016-2024 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
, ConnIdent(..)
, ClosableConnection(..)
, stdioP2PConnection
+ , stdioP2PConnectionDupped
, connectPeer
, closeConnection
, serveUnixSocket
, connIdent = ConnIdent Nothing
}
+-- P2PConnection using stdio, but with the handles first duplicated,
+-- to avoid anything that might output to stdio (eg a program run by a
+-- special remote) from interfering with the connection.
+stdioP2PConnectionDupped :: Maybe Git.Repo -> IO P2PConnection
+stdioP2PConnectionDupped g = do
+ (readh, writeh) <- dupIoHandles
+ return $ P2PConnection
+ { connRepo = g
+ , connCheckAuth = const False
+ , connIhdl = P2PHandle readh
+ , connOhdl = P2PHandle writeh
+ , connIdent = ConnIdent Nothing
+ }
+
-- Opens a connection to a peer. Does not authenticate with it.
connectPeer :: Maybe Git.Repo -> P2PAddress -> IO P2PConnection
connectPeer g (TorAnnex onionaddress onionport) = do
rather than PUT-FROM or ALREADY-HAVE. Verify that the client processes
that ok and displays it to the user.
-* If a special remote outputs to stdout, or reads from stdin, that will
- mess up the P2P protocol. Move the special remote proxying into a
- separate process perhaps, which can be run with stdout and stdin
- redirected? Or, fix any special remotes that might do that. Are
- there any left? External special remotes certainly don't since that would
- mess up their own protocol. Hook special remotes can though.
-
* Streaming download from proxied special remotes. See design.
* Check annex.diskreserve when proxying for special remotes.