Skip to content

fix: startup banner always shows 127.0.0.1 regardless of server.host - #307

Open
Sycun wants to merge 1 commit into
AIPentest:mainfrom
Sycun:fix/startup-banner-host
Open

fix: startup banner always shows 127.0.0.1 regardless of server.host#307
Sycun wants to merge 1 commit into
AIPentest:mainfrom
Sycun:fix/startup-banner-host

Conversation

@Sycun

@Sycun Sycun commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

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.0 the server does listen on all interfaces (lsof shows *:port); with host: 127.0.0.1 it binds loopback only. internal/app/app.go has always used cfg.Server.Host.

The real problem is the startup banner: internal/termout/startup.go hardcoded http://127.0.0.1:<port>/, so no matter what server.host was 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

  • StartupWebUIOptions gains a Host field; cmd/server/main.go passes cfg.Server.Host
  • New startupHosts(): wildcard binds (0.0.0.0 / :: / empty) expand to 127.0.0.1 plus the machine's non-loopback IPv4 addresses; an explicit host is shown as-is (IPv6 bracketed via net.JoinHostPort)
  • Banner now renders, e.g. for 0.0.0.0:
● ONLINE   https://127.0.0.1:8080/
  Network  https://192.168.0.5:8080/
  TLS      self-signed · accept the browser warning once

Test plan

  • New unit tests in internal/termout/startup_test.go: explicit host, wildcard expansion (dedup, IPv4-only, loopback first), IPv6 bracketing, redirect line
  • End-to-end: built and ran with host: 0.0.0.0 → banner lists Network URLs, lsof confirms *:port; host: 127.0.0.1 → banner shows loopback only
  • go vet clean; internal/termout, internal/config, internal/app tests pass

Note 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).

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

已经成功加载config.yaml文件,并且host绑定的是0.0.0.0,但是启动服务是绑定在127.0.0.1上

1 participant