Skip to content

Support sending custom global requests from the client - #759

Open
ChrisJr404 wants to merge 1 commit into
Eugeny:mainfrom
ChrisJr404:custom-global-requests
Open

Support sending custom global requests from the client#759
ChrisJr404 wants to merge 1 commit into
Eugeny:mainfrom
ChrisJr404:custom-global-requests

Conversation

@ChrisJr404

Copy link
Copy Markdown

This covers the client side of #417. Right now there's no way to send a global request with a non-standard name, so the config request from that issue (and anything else outside the built-in forwarding/keepalive ones) isn't reachable.

I added Handle::send_global_request(name, data, want_reply) that follows the same pattern as tcpip_forward and friends: it pushes the request onto the wire and, when want_reply is set, correlates the SUCCESS/FAILURE reply back through a oneshot. On success you get the response-specific payload back (empty if the peer sent none), and a failure comes back as RequestDenied. With want_reply false it just sends and returns Ok(None).

let reply = handle.send_global_request("config", payload, true).await?;

There's a round-trip test in client/test.rs against the test server, which replies with a failure for the unknown name.

I kept this to the client send path since that's what the issue asks for. Handling incoming custom requests could be a nice follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant