MCPcopy Create free account
hub / github.com/Hidden-Node/GooseRelayVPN-AndroidClient / invokeAsClient

Function invokeAsClient

internal/exit/exit_timing_test.go:198–218  ·  view source on GitHub ↗

invokeAsClient runs one /tunnel POST as the given clientID and returns the decoded downstream frames the server replied with.

(tb testing.TB, s *Server, c *frame.Crypto, clientID [frame.ClientIDLen]byte, frames []*frame.Frame)

Source from the content-addressed store, hash-verified

196// invokeAsClient runs one /tunnel POST as the given clientID and returns the
197// decoded downstream frames the server replied with.
198func invokeAsClient(tb testing.TB, s *Server, c *frame.Crypto, clientID [frame.ClientIDLen]byte, frames []*frame.Frame) []*frame.Frame {
199 tb.Helper()
200 body, err := frame.EncodeBatch(c, clientID, frames)
201 if err != nil {
202 tb.Fatalf("encode: %v", err)
203 }
204 req := httptest.NewRequest(http.MethodPost, "/tunnel", bytes.NewReader(body))
205 rec := httptest.NewRecorder()
206 s.handleTunnel(rec, req)
207 resp := rec.Result()
208 defer resp.Body.Close()
209 respBody, _ := io.ReadAll(resp.Body)
210 if len(respBody) == 0 {
211 return nil
212 }
213 _, out, err := frame.DecodeBatch(c, respBody)
214 if err != nil {
215 tb.Fatalf("decode response: %v", err)
216 }
217 return out
218}
219
220// TestExit_MultiClient_SessionIsolation is the regression test for issue #23:
221// when two clients share one server, neither should ever see the other's

Calls 4

EncodeBatchFunction · 0.92
DecodeBatchFunction · 0.92
handleTunnelMethod · 0.80
CloseMethod · 0.80

Tested by

no test coverage detected