Fall back to the request Host for the join-token panel_addr#13
Conversation
IP-only deployments (no PANEL_DOMAIN configured) got panel_addr: null, so the join-token dialog showed no control-plane address exactly where the guidance matters most. The Host the admin is browsing the panel on reaches this server by definition - use it (port stripped) when neither the live panel-domain setting nor the boot-time PANEL_DOMAIN is set. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the control plane address resolution to fall back to the request's Host header when no panel domain is configured, facilitating IP-only deployments. The API documentation has been updated accordingly. Feedback is provided regarding a potential issue with IPv6 addresses without a port, which could result in double-bracket wrapping when calling net.JoinHostPort; a code suggestion is included to strip the brackets if they are present.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if host == "" { | ||
| if h, _, err := net.SplitHostPort(r.Host); err == nil { | ||
| host = h | ||
| } else { | ||
| host = r.Host | ||
| } | ||
| } |
There was a problem hiding this comment.
If the admin accesses the panel using an IPv6 address without a port (e.g., [::1]), net.SplitHostPort will fail and host will be set to [::1]. When net.JoinHostPort is subsequently called, it will detect the colon in [::1] and wrap it in brackets again, resulting in an invalid address like [[::1]]:port.
To prevent this double-wrapping, strip the brackets from host if they are present before calling net.JoinHostPort.
| if host == "" { | |
| if h, _, err := net.SplitHostPort(r.Host); err == nil { | |
| host = h | |
| } else { | |
| host = r.Host | |
| } | |
| } | |
| if host == "" { | |
| if h, _, err := net.SplitHostPort(r.Host); err == nil { | |
| host = h | |
| } else { | |
| host = r.Host | |
| } | |
| if len(host) > 2 && host[0] == '[' && host[len(host)-1] == ']' { | |
| host = host[1 : len(host)-1] | |
| } | |
| } |
IP-only deployments (no PANEL_DOMAIN configured) got panel_addr: null, so the join-token dialog showed no control-plane address exactly where the guidance matters most. The Host the admin is browsing the panel on reaches this server by definition - use it (port stripped) when neither the live panel-domain setting nor the boot-time PANEL_DOMAIN is set.