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

Method Handle

socks/auth_handler.go:47–64  ·  view source on GitHub ↗

Handle gets the methods from the SOCKS5 client and authenticates with the first supported method

(bufConn io.Reader, conn io.Writer)

Source from the content-addressed store, hash-verified

45
46// Handle gets the methods from the SOCKS5 client and authenticates with the first supported method
47func (h *StandardAuthHandler) Handle(bufConn io.Reader, conn io.Writer) error {
48 methods, err := readMethods(bufConn)
49 if err != nil {
50 return fmt.Errorf("Failed to read auth methods: %v", err)
51 }
52
53 // first supported method is used
54 for _, method := range methods {
55 authenticator := h.authenticators[method]
56 if authenticator != nil {
57 return authenticator.Handle(bufConn, conn)
58 }
59 }
60
61 // failed to authenticate. No supported authentication type found
62 conn.Write([]byte{socks5Version, noAcceptable})
63 return fmt.Errorf("unknown authentication type")
64}
65
66// readMethods is used to read the number and type of methods
67func readMethods(r io.Reader) ([]byte, error) {

Callers

nothing calls this directly

Calls 4

readMethodsFunction · 0.85
ErrorfMethod · 0.80
HandleMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected