MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / Serve

Method Serve

socks/connection_handler.go:31–57  ·  view source on GitHub ↗

Serve process new connection created after calling `Accept()` in the standard library

(c io.ReadWriter)

Source from the content-addressed store, hash-verified

29
30// Serve process new connection created after calling `Accept()` in the standard library
31func (h *StandardConnectionHandler) Serve(c io.ReadWriter) error {
32 bufConn := bufio.NewReader(c)
33
34 // read the version byte
35 version := []byte{0}
36 if _, err := bufConn.Read(version); err != nil {
37 return err
38 }
39
40 // ensure compatibility
41 if version[0] != socks5Version {
42 return fmt.Errorf("Unsupported SOCKS version: %v", version)
43 }
44
45 // handle auth
46 if err := h.authHandler.Handle(bufConn, c); err != nil {
47 return err
48 }
49
50 // process command/request
51 req, err := NewRequest(bufConn)
52 if err != nil {
53 return err
54 }
55
56 return h.requestHandler.Handle(req, c)
57}

Callers

nothing calls this directly

Calls 4

NewRequestFunction · 0.85
ErrorfMethod · 0.80
HandleMethod · 0.65
ReadMethod · 0.45

Tested by

no test coverage detected