Skip to content

Commit

Permalink
Preserve real IP address in TLS handshake error
Browse files Browse the repository at this point in the history
  • Loading branch information
kayrus committed Jul 6, 2022
1 parent 77fba1e commit 14bc7fa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ func (s *Server) handleConn(c *Conn) error {
if err == io.EOF {
return nil
}
s.ErrorLog.Printf("TLS handshake error for %s: %v", tlsConn.RemoteAddr(), err)
if err, ok := err.(*net.OpError); ok {
// preserve remote address from PROXY protocol
err.Addr = c.conn.RemoteAddr()
}
s.ErrorLog.Printf("TLS handshake error: %w", err)
return err
}
}
Expand Down

0 comments on commit 14bc7fa

Please sign in to comment.