MCPcopy
hub / github.com/cloudflare/cloudflared / sendSocksRequest

Function sendSocksRequest

socks/connection_handler_test.go:19–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17}
18
19func sendSocksRequest(t *testing.T) []byte {
20 dialer, err := proxy.SOCKS5("tcp", "127.0.0.1:8086", nil, proxy.Direct)
21 assert.NoError(t, err)
22
23 httpTransport := &http.Transport{}
24 httpClient := &http.Client{Transport: httpTransport}
25 // set our socks5 as the dialer
26 httpTransport.Dial = dialer.Dial
27
28 req, err := http.NewRequest("GET", "http://127.0.0.1:8085", nil)
29 assert.NoError(t, err)
30
31 resp, err := httpClient.Do(req)
32 assert.NoError(t, err)
33 defer resp.Body.Close()
34
35 b, err := io.ReadAll(resp.Body)
36 assert.NoError(t, err)
37
38 return b
39}
40
41func startTestServer(t *testing.T, httpHandler func(w http.ResponseWriter, r *http.Request)) {
42 // create a socks server

Callers 1

TestSocksConnectionFunction · 0.85

Calls 2

CloseMethod · 0.65
DoMethod · 0.45

Tested by

no test coverage detected