fix: support comma-separated bind addresses in host setting#1606
Open
fqx wants to merge 3 commits into
Open
Conversation
Fixes the regression introduced when jundot#1526 switched from uvicorn.run() to uvicorn.Config + bind_socket() + Server.run(sockets=[...]): the old approach silently accepted a list of hosts via asyncio.create_server(), but bind_socket() calls sock.bind((host, port)) which requires a string. Changes: - settings.py: normalise legacy YAML list values (host: [a, b]) to a comma-separated string on load so the web UI and server both see a str - cli.py (serve_command): parse comma-separated hosts, bind one socket per address before model preload (preserving the fail-fast guarantee from jundot#1526), then pass all sockets to Server.run() - cli.py (launch_command): pick the first bind address as the connect host, normalising wildcards (0.0.0.0, ::) to 127.0.0.1 - utils/network.py: add is_valid_bind_host() which accepts 0.0.0.0 and :: unlike is_valid_alias() which rejects unspecified addresses - admin/routes.py: validate each comma-separated part on save, returning a readable 400 before an invalid value can crash the server on restart - admin/static/js/dashboard.js: extract .msg from Pydantic error objects instead of joining raw objects (fixes [object Object] display), two sites - admin/i18n/{en,zh,ja,ko,zh-TW}.json: add host_multi_hint string and drop "(caution)" from host_custom label now that multi-address is valid - admin/templates/dashboard/_settings.html: show host_multi_hint hint below the custom host input when the custom mode is active Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The caution warning is still valid — manually entering a bind address can inadvertently expose the server, and supporting multiple addresses makes that risk more rather than less relevant.
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.
Problem
#1526 introduced a pre-bind approach (
uvicorn.Config + bind_socket()) to fail fast on port conflicts before model preload. This broke multi-address binding:bind_socket()callssock.bind((host, port))which requires a plain string, not a list — so users who hadhost: [127.0.0.1, 192.168.1.x]in their settings (or set a comma-separated value) now get aTypeErroron startup.Supersedes #908, which patched the old
uvicorn.run()call that no longer exists.Fix
omlx/settings.py— normalise legacy YAML list values (host: [a, b]) to a comma-separated string on load. Backward-compatible: single-string configs are unchanged.omlx/cli.py(serve_command) — split the host string by comma, bind one socket per address (preserving the fail-fast guarantee from #1526), then pass all sockets toServer.run(sockets=[...]). uvicorn accepts a socket list and listens on all of them.omlx/cli.py(launch_command) — pick the first bind address as the connect host; normalise wildcards (0.0.0.0,::) to127.0.0.1.omlx/utils/network.py— addis_valid_bind_host(): accepts all valid IPs including0.0.0.0and::, unlikeis_valid_alias()which rejects unspecified addresses.omlx/admin/routes.py— validate each comma-separated part on save, returning a readable 400 before an invalid value can crash the server on restart.omlx/admin/static/js/dashboard.js— extract.msgfrom Pydantic error objects instead of joining raw objects (fixes[object Object]display). Two call sites.omlx/admin/i18n/{en,zh,ja,ko,zh-TW}.json— addhost_multi_hintstring in all five languages; drop "(caution)" fromhost_customlabel now that entering multiple addresses is a valid normal use case.omlx/admin/templates/dashboard/_settings.html— show thehost_multi_hinthint below the custom host input when custom mode is active.Usage
Enter multiple bind addresses separated by commas in the Host field:
Existing single-address settings and legacy YAML list values both continue to work without migration.
Testing
127.0.0.1, ::1in the web UI and save — both addresses should appear in startup output"host": ["127.0.0.1", "192.168.1.x"]— should load cleanly and show both bind linesnot a host!!) — should get a readable 400 error, not[object Object]omlx launchwith a multi-address host connects via the first address🤖 Generated with Claude Code