mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-13 08:59:08 +02:00
Fix js relay WebSocket close, raise RDP dial timeout, adjust WASM log levels
This commit is contained in:
@@ -109,7 +109,7 @@ func (e *ConnMgr) UpdatedRemoteFeatureFlag(ctx context.Context, enabled bool) er
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Warnf("lazy connection manager is enabled by management feature flag")
|
log.Infof("lazy connection manager is enabled by the management feature flag")
|
||||||
e.initLazyManager(ctx)
|
e.initLazyManager(ctx)
|
||||||
e.statusRecorder.UpdateLazyConnection(true)
|
e.statusRecorder.UpdateLazyConnection(true)
|
||||||
return e.addPeersToLazyConnManager()
|
return e.addPeersToLazyConnManager()
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
@@ -439,7 +440,11 @@ func (s *ServiceManager) GetStatePath() string {
|
|||||||
|
|
||||||
activeProf, err := s.GetActiveProfileState()
|
activeProf, err := s.GetActiveProfileState()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("failed to get active profile state: %v", err)
|
if errors.Is(err, syscall.ENOSYS) {
|
||||||
|
log.Debugf("active profile state unavailable on this platform: %v", err)
|
||||||
|
} else {
|
||||||
|
log.Warnf("failed to get active profile state: %v", err)
|
||||||
|
}
|
||||||
return defaultStatePath
|
return defaultStatePath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@@ -264,7 +265,11 @@ func (m *DefaultManager) initSelector() *routeselector.RouteSelector {
|
|||||||
|
|
||||||
// restore selector state if it exists
|
// restore selector state if it exists
|
||||||
if err := m.stateManager.LoadState(state); err != nil {
|
if err := m.stateManager.LoadState(state); err != nil {
|
||||||
log.Warnf("failed to load state: %v", err)
|
if errors.Is(err, syscall.ENOSYS) {
|
||||||
|
log.Debugf("route selector state unavailable on this platform: %v", err)
|
||||||
|
} else {
|
||||||
|
log.Warnf("failed to load state: %v", err)
|
||||||
|
}
|
||||||
return routeselector.NewRouteSelector()
|
return routeselector.NewRouteSelector()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const (
|
|||||||
RDCleanPathProxyHost = "rdcleanpath.proxy.local"
|
RDCleanPathProxyHost = "rdcleanpath.proxy.local"
|
||||||
RDCleanPathProxyScheme = "ws"
|
RDCleanPathProxyScheme = "ws"
|
||||||
|
|
||||||
rdpDialTimeout = 15 * time.Second
|
rdpDialTimeout = 30 * time.Second
|
||||||
|
|
||||||
GeneralErrorCode = 1
|
GeneralErrorCode = 1
|
||||||
WSAETimedOut = 10060
|
WSAETimedOut = 10060
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
//go:build !js
|
||||||
|
|
||||||
|
package ws
|
||||||
|
|
||||||
|
// closeConn closes the underlying WebSocket immediately, skipping the close
|
||||||
|
// handshake.
|
||||||
|
func (c *Conn) closeConn() error {
|
||||||
|
return c.Conn.CloseNow()
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//go:build js
|
||||||
|
|
||||||
|
package ws
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/coder/websocket"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
// closeConn closes the browser WebSocket without blocking the caller.
|
||||||
|
//
|
||||||
|
// The browser close API only accepts codes 1000 and 3000-4999, so CloseNow's
|
||||||
|
// 1001 (going away) throws an InvalidAccessError. Close with a valid code
|
||||||
|
// waits for the browser close event before returning, which can park the
|
||||||
|
// calling goroutine (the relay teardown path holds its mutexes while closing)
|
||||||
|
// until the close handshake finishes. Run the close in the background and
|
||||||
|
// report success; a teardown close error is not actionable.
|
||||||
|
func (c *Conn) closeConn() error {
|
||||||
|
go func() {
|
||||||
|
if err := c.Conn.Close(websocket.StatusNormalClosure, ""); err != nil {
|
||||||
|
log.Debugf("failed to close relay websocket: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -77,5 +77,5 @@ func (c *Conn) SetDeadline(t time.Time) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) Close() error {
|
func (c *Conn) Close() error {
|
||||||
return c.Conn.CloseNow()
|
return c.closeConn()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user