fix(acl): add logging for unexpected remote address types in TCP and UDP listeners

This commit is contained in:
yusing
2026-02-15 17:22:53 +08:00
parent be9af03a1e
commit 0a139067b8
2 changed files with 6 additions and 0 deletions

View File

@@ -5,6 +5,8 @@ import (
"io"
"net"
"time"
"github.com/rs/zerolog/log"
)
type TCPListener struct {
@@ -44,6 +46,7 @@ func (s *TCPListener) Accept() (net.Conn, error) {
}
addr, ok := c.RemoteAddr().(*net.TCPAddr)
if !ok {
log.Error().Msgf("unexpected remote address type: %T, addr: %s", c.RemoteAddr(), c.RemoteAddr().String())
// Not a TCPAddr, drop
c.Close()
return noConn{}, nil

View File

@@ -4,6 +4,8 @@ import (
"errors"
"net"
"time"
"github.com/rs/zerolog/log"
)
type UDPListener struct {
@@ -33,6 +35,7 @@ func (s *UDPListener) ReadFrom(p []byte) (int, net.Addr, error) {
}
udpAddr, ok := addr.(*net.UDPAddr)
if !ok {
log.Error().Msgf("unexpected remote address type: %T, addr: %s", addr, addr.String())
// Not a UDPAddr, drop
continue
}