mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-24 16:41:30 +02:00
On network changes the client restarted the whole engine. That is heavy-handed and slow: it tears down working state to recover from a transition the engine could handle itself. This replaces the restart with proper network event handling. Suspend the retry loops while no network is available. Instead of burning through backoff intervals against an unreachable network, the reconnection loops park until the OS reports a usable network again. Reconnect immediately on a network switch. When the OS hands us a new network, connections bound to the old one are swept and re-dialed right away, rather than waiting for a timeout to notice they are dead.
20 lines
660 B
Go
20 lines
660 B
Go
package grpc
|
|
|
|
import (
|
|
"google.golang.org/grpc"
|
|
|
|
"github.com/netbirdio/netbird/client/netsweep"
|
|
"github.com/netbirdio/netbird/util/wsproxy/client"
|
|
)
|
|
|
|
// WithCustomDialer returns a gRPC dial option that uses WebSocket transport for WASM/JS environments.
|
|
// The component parameter specifies the WebSocket proxy component path (e.g., "/management", "/signal").
|
|
func WithCustomDialer(tlsEnabled bool, component string) grpc.DialOption {
|
|
return client.WithWebSocketDialer(tlsEnabled, component)
|
|
}
|
|
|
|
// WithSweeper is a no-op on WASM/JS: there is no network change signal.
|
|
func WithSweeper(_ *netsweep.Sweeper) grpc.DialOption {
|
|
return grpc.EmptyDialOption{}
|
|
}
|