MCPcopy
hub / github.com/caddyserver/caddy / handlePingbackConn

Function handlePingbackConn

cmd/main.go:83–93  ·  view source on GitHub ↗

handlePingbackConn reads from conn and ensures it matches the bytes in expect, or returns an error if it doesn't.

(conn net.Conn, expect []byte)

Source from the content-addressed store, hash-verified

81// handlePingbackConn reads from conn and ensures it matches
82// the bytes in expect, or returns an error if it doesn't.
83func handlePingbackConn(conn net.Conn, expect []byte) error {
84 defer conn.Close()
85 confirmationBytes, err := io.ReadAll(io.LimitReader(conn, 32))
86 if err != nil {
87 return err
88 }
89 if !bytes.Equal(confirmationBytes, expect) {
90 return fmt.Errorf("wrong confirmation: %x", confirmationBytes)
91 }
92 return nil
93}
94
95// LoadConfig loads the config from configFile and adapts it
96// using adapterName. If adapterName is specified, configFile

Callers 1

cmdStartFunction · 0.85

Calls 2

CloseMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected