implement simple proxy actions (untested)

Still need to implement GET and PUT, and will implement CONNECT and
NOTIFYCHANGE for completeness.

All ServerMode checking is implemented for the proxy.

There are two possible approaches for how the proxy sends back messages
from the remote to the client. One would be to have a background thread
that reads messages and sends them back as they come in. The other,
which is being implemented so far, is to read messages from the remote
at points where it is expected to send them, and relay back to the
client before reading the next message from the client. At this point,
I'm unsure which approach would be better.

The need for proxynoresponse to be used by UNLOCKCONTENT, for example,
builds protocol knowledge into the proxy which it would not need with
the other method.
This commit is contained in:
Joey Hess 2024-06-11 12:05:44 -04:00
parent 373ae49c87
commit 58d8ba5a4f
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 84 additions and 19 deletions

View file

@ -64,12 +64,12 @@ performProxy clientuuid servermode remote = do
<*> pure (stdioP2PConnection Nothing)
getClientProtocolVersion remote clientside
(withclientversion clientside)
clienterrhandler
protoerrhandler
where
withclientversion clientside (Just (clientmaxversion, othermsg)) =
connectremote clientmaxversion $ \remoteside ->
proxy done servermode clientside remoteside
othermsg clienterrhandler
othermsg protoerrhandler
withclientversion _ Nothing = done
-- FIXME: Support special remotes and non-ssh git remotes.
@ -80,7 +80,7 @@ performProxy clientuuid servermode remote = do
`finally` liftIO (closeP2PSshConnection conn)
_ -> giveup "Unable to connect to remote."
clienterrhandler cont a = a >>= \case
protoerrhandler cont a = a >>= \case
-- Avoid displaying an error when the client hung up on us.
Left (ProtoFailureIOError e) | isEOFError e -> done
Left e -> giveup (describeProtoFailure e)