Extend the error messages with IP (#2465)

Add IP address for the error messages in the Hello section
This commit is contained in:
Zoltan Papp 2024-08-22 11:26:21 +02:00 committed by GitHub
parent 82584f2089
commit d9f43e8871
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -129,7 +129,7 @@ func (r *Relay) handshake(conn net.Conn) ([]byte, error) {
buf := make([]byte, messages.MaxHandshakeSize)
n, err := conn.Read(buf)
if err != nil {
log.Errorf("failed to read message: %s", err)
log.Debugf("failed to read message from: %s, %s", conn.RemoteAddr(), err)
return nil, err
}
msgType, err := messages.DetermineClientMsgType(buf[:n])
@ -139,18 +139,18 @@ func (r *Relay) handshake(conn net.Conn) ([]byte, error) {
if msgType != messages.MsgTypeHello {
tErr := fmt.Errorf("invalid message type")
log.Errorf("failed to handshake: %s", tErr)
log.Debugf("failed to handshake with: %s, %s", conn.RemoteAddr(), tErr)
return nil, tErr
}
peerID, authPayload, err := messages.UnmarshalHelloMsg(buf[:n])
if err != nil {
log.Errorf("failed to handshake: %s", err)
log.Debugf("failed to handshake with: %s, %s", conn.RemoteAddr(), err)
return nil, err
}
if err := r.validator.Validate(authPayload); err != nil {
log.Errorf("failed to authenticate connection: %s", err)
log.Debugf("failed to authenticate connection with: %s, %s", conn.RemoteAddr(), err)
return nil, err
}