[Config] Make the listen address configurable via BIND_ADDRESS - #169
Merged
Conversation
…138) Adds BIND_ADDRESS to bind the server to a specific interface (e.g. 127.0.0.1 for same-host reverse-proxy setups) instead of always binding all interfaces. Defaults to 0.0.0.0 to preserve current behavior, and a server 'error' handler now fails startup loudly on an unbindable address instead of leaving an unhandled event.
|
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.



📖 Description
Adds a
BIND_ADDRESSenvironment variable so the server can be restricted to a specific network interface (e.g.127.0.0.1) instead of always binding to all interfaces (0.0.0.0). This closes a gap for deployments that run a reverse proxy on the same host and want the unauthenticated API reachable only via loopback.src/server/types.ts: addedbindAddress: stringtoAppConfig.src/server/config.ts: readsBIND_ADDRESS, trims it, and falls back to'0.0.0.0'when unset or whitespace-only. No further validation — an unbindable address fails atlisten()time.src/server/index.ts: passesconfig.bindAddresstoapp.listen(...), includes it in the startup log line, and adds aserver.on('error', ...)handler so a bad address (e.g.EADDRNOTAVAIL) logs a clear fatal message and exits instead of surfacing as an unhandled'error'event.README.md: documentedBIND_ADDRESSin the configuration table.deploy/systemd/openhab-log-viewer.service: added a commented example next to the other optional settings.🎫 Issues
Closes #138
👩💻 Reviewer Notes
Default behavior is unchanged (still binds
0.0.0.0whenBIND_ADDRESSis unset). Worth spot-checking thatnpm run startwithBIND_ADDRESS=127.0.0.1only accepts loopback connections, and that an invalid address (e.g. an address not present on the host) makes startup fail with the new fatal log line instead of hanging.📑 Test Plan
src/server/config.test.ts: added aloadConfig bind address parsingsuite covering the documented default (0.0.0.0), an explicitBIND_ADDRESS=127.0.0.1, and a whitespace-only value falling back to the default. Also assertedbindAddressin the existing defaults test.src/server/routes.test.ts: updated thebaseConfig()test fixture to includebindAddressso it satisfies theAppConfigtype.npm run typecheck,npm test(152/152 passing), andnpm run buildlocally.✅ Checklist
General
npm testandnpm run typechecklocally and they pass.Server-specific (
src/server)src/server(tailer, parser, buffer, routes, SSE hub, config, etc.).src/server/types.tsin sync withsrc/client/state.tsfor any shared payload change (see ARCHITECTURE.md). — N/A,bindAddressis server-only startup config, not part of a client-facing payload.⏭ Next Steps
None.