Skip to content

Commit

Permalink
[client] Remove usage of custom dialer for localhost (#2639)
Browse files Browse the repository at this point in the history
* Downgrade error log level for network monitor warnings

* Do not use custom dialer for localhost
  • Loading branch information
lixmal authored Sep 24, 2024
1 parent d47be15 commit ab82302
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 5 additions & 5 deletions client/internal/networkmonitor/monitor_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func checkChange(ctx context.Context, nexthopv4, nexthopv6 systemops.Nexthop, ca
defer func() {
err := unix.Close(fd)
if err != nil && !errors.Is(err, unix.EBADF) {
log.Errorf("Network monitor: failed to close routing socket: %v", err)
log.Warnf("Network monitor: failed to close routing socket: %v", err)
}
}()

go func() {
<-ctx.Done()
err := unix.Close(fd)
if err != nil && !errors.Is(err, unix.EBADF) {
log.Debugf("Network monitor: closed routing socket")
log.Debugf("Network monitor: closed routing socket: %v", err)
}
}()

Expand All @@ -45,12 +45,12 @@ func checkChange(ctx context.Context, nexthopv4, nexthopv6 systemops.Nexthop, ca
n, err := unix.Read(fd, buf)
if err != nil {
if !errors.Is(err, unix.EBADF) && !errors.Is(err, unix.EINVAL) {
log.Errorf("Network monitor: failed to read from routing socket: %v", err)
log.Warnf("Network monitor: failed to read from routing socket: %v", err)
}
continue
}
if n < unix.SizeofRtMsghdr {
log.Errorf("Network monitor: read from routing socket returned less than expected: %d bytes", n)
log.Debugf("Network monitor: read from routing socket returned less than expected: %d bytes", n)
continue
}

Expand All @@ -61,7 +61,7 @@ func checkChange(ctx context.Context, nexthopv4, nexthopv6 systemops.Nexthop, ca
case unix.RTM_ADD, syscall.RTM_DELETE:
route, err := parseRouteMessage(buf[:n])
if err != nil {
log.Errorf("Network monitor: error parsing routing message: %v", err)
log.Debugf("Network monitor: error parsing routing message: %v", err)
continue
}

Expand Down
5 changes: 2 additions & 3 deletions client/internal/wgproxy/proxy_userspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"net"

log "github.com/sirupsen/logrus"

nbnet "github.com/netbirdio/netbird/util/net"
)

// WGUserSpaceProxy proxies
Expand Down Expand Up @@ -36,7 +34,8 @@ func (p *WGUserSpaceProxy) AddTurnConn(remoteConn net.Conn) (net.Addr, error) {
p.remoteConn = remoteConn

var err error
p.localConn, err = nbnet.NewDialer().DialContext(p.ctx, "udp", fmt.Sprintf(":%d", p.localWGListenPort))
dialer := &net.Dialer{}
p.localConn, err = dialer.DialContext(p.ctx, "udp", fmt.Sprintf(":%d", p.localWGListenPort))
if err != nil {
log.Errorf("failed dialing to local Wireguard port %s", err)
return nil, err
Expand Down

0 comments on commit ab82302

Please sign in to comment.