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)
| 81 | // handlePingbackConn reads from conn and ensures it matches |
| 82 | // the bytes in expect, or returns an error if it doesn't. |
| 83 | func 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 |