control/controlhttp: use custom port for non-localhost JS noise client connections

Control may not be bound to (just) localhost when sharing dev servers,
allow the Wasm client to connect to it in that case too.

Signed-off-by: Mihai Parparita <mihai@tailscale.com>
pull/5779/head
Mihai Parparita 2 years ago committed by Mihai Parparita
parent f981b1d9da
commit e97d5634bf

@ -29,9 +29,11 @@ func (d *Dialer) Dial(ctx context.Context) (*controlbase.Conn, error) {
wsScheme := "wss" wsScheme := "wss"
host := d.Hostname host := d.Hostname
if host == "localhost" { // If using a custom control server (on a non-standard port), prefer that.
// This mirrors the port selection in newNoiseClient from noise.go.
if d.HTTPPort != "" && d.HTTPPort != "80" && d.HTTPSPort == "443" {
wsScheme = "ws" wsScheme = "ws"
host = net.JoinHostPort(host, strDef(d.HTTPPort, "80")) host = net.JoinHostPort(host, d.HTTPPort)
} }
wsURL := &url.URL{ wsURL := &url.URL{
Scheme: wsScheme, Scheme: wsScheme,

Loading…
Cancel
Save