mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 07:16:38 +00:00
[client,signal,management] Adjust browser client ws proxy paths (#4565)
This commit is contained in:
@@ -96,13 +96,14 @@ func (s stringAddr) Network() string { return "tcp" }
|
||||
func (s stringAddr) String() string { return string(s) }
|
||||
|
||||
// WithWebSocketDialer returns a gRPC dial option that uses WebSocket transport for JS/WASM environments.
|
||||
func WithWebSocketDialer(tlsEnabled bool) grpc.DialOption {
|
||||
// The component parameter specifies the WebSocket proxy component path (e.g., "/management", "/signal").
|
||||
func WithWebSocketDialer(tlsEnabled bool, component string) grpc.DialOption {
|
||||
return grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
|
||||
scheme := "wss"
|
||||
if !tlsEnabled {
|
||||
scheme = "ws"
|
||||
}
|
||||
wsURL := fmt.Sprintf("%s://%s%s", scheme, addr, wsproxy.ProxyPath)
|
||||
wsURL := fmt.Sprintf("%s://%s%s%s", scheme, addr, wsproxy.ProxyPath, component)
|
||||
|
||||
ws := js.Global().Get("WebSocket").New(wsURL)
|
||||
|
||||
|
||||
@@ -2,9 +2,16 @@ package wsproxy
|
||||
|
||||
import "errors"
|
||||
|
||||
// ProxyPath is the standard path where the WebSocket proxy is mounted on servers.
|
||||
// ProxyPath is the base path where the WebSocket proxy is mounted on servers.
|
||||
const ProxyPath = "/ws-proxy"
|
||||
|
||||
// Component paths that are appended to ProxyPath
|
||||
const (
|
||||
ManagementComponent = "/management"
|
||||
SignalComponent = "/signal"
|
||||
FlowComponent = "/flow"
|
||||
)
|
||||
|
||||
// Common errors
|
||||
var (
|
||||
ErrConnectionTimeout = errors.New("WebSocket connection timeout")
|
||||
|
||||
Reference in New Issue
Block a user