fix: startup banner always shows 127.0.0.1 regardless of server.host - #307
Open
Sycun wants to merge 1 commit into
Open
fix: startup banner always shows 127.0.0.1 regardless of server.host#307Sycun wants to merge 1 commit into
Sycun wants to merge 1 commit into
Conversation
The Web UI startup banner always printed 127.0.0.1, even when server.host was bound to 0.0.0.0 or a specific interface. This made users believe the host setting was ignored (the actual listen binding was correct). Pass the configured host into the banner and expand wildcard binds to the machine's real addresses so LAN URLs are shown. Fixes AIPentest#301
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #301
Investigation of the reported issue ("config.yaml 的 host 配置不生效,服务一直绑定在 127.0.0.1"):
The actual listen binding was already correct. With
host: 0.0.0.0the server does listen on all interfaces (lsofshows*:port); withhost: 127.0.0.1it binds loopback only.internal/app/app.gohas always usedcfg.Server.Host.The real problem is the startup banner:
internal/termout/startup.gohardcodedhttp://127.0.0.1:<port>/, so no matter whatserver.hostwas set to, the first thing the user saw was a 127.0.0.1 URL — which is why the host setting appeared not to take effect while other settings did.Changes
StartupWebUIOptionsgains aHostfield;cmd/server/main.gopassescfg.Server.HoststartupHosts(): wildcard binds (0.0.0.0/::/ empty) expand to127.0.0.1plus the machine's non-loopback IPv4 addresses; an explicit host is shown as-is (IPv6 bracketed vianet.JoinHostPort)0.0.0.0:Test plan
internal/termout/startup_test.go: explicit host, wildcard expansion (dedup, IPv4-only, loopback first), IPv6 bracketing, redirect linehost: 0.0.0.0→ banner lists Network URLs,lsofconfirms*:port;host: 127.0.0.1→ banner shows loopback onlygo vetclean;internal/termout,internal/config,internal/apptests passNote for the reporter of #301: if LAN access still fails after this fix, the likely causes are firewall rules or the self-signed certificate warning (the in-memory cert SAN only covers
localhost/127.0.0.1, which is documented behavior).