Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

tools: poll the server address the config binds, not loopback (#2330)

nekomario2869fe40553d29
diff --git a/tools/strata_bench.py b/tools/strata_bench.py
index 63c66c7b0..89dc30e5b 100644
--- a/tools/strata_bench.py
+++ b/tools/strata_bench.py
@@ -917,6 +917,16 @@ def write_results(res: dict, parent: Path, red, log_lines: list[str]) -> Path:
# --------------------------------------------------------------------------------------------------------- main
+def server_base(host, port) -> str:
+ """The address to talk to for a locally started server. The config's `host` is the interface the server
+ binds - a specific IP, or a wildcard that is not connectable as written - so it cannot be polled as-is.
+ An explicit `--url` bypasses this; there the caller knows the address."""
+ host = host or "127.0.0.1"
+ host = {"0.0.0.0": "127.0.0.1", "::": "::1"}.get(host, host) # wildcard binds accept loopback
+ authority = f"[{host}]" if ":" in host and not host.startswith("[") else host
+ return f"http://{authority}:{port}"
+
+
def main(argv=None) -> int:
ap = argparse.ArgumentParser(description="Measure this Strata install and write a shareable report (see the top of this file).")
ap.add_argument("--config", help="the model config to run (default: the newest strata-*.json of this folder)")
@@ -963,8 +973,7 @@ def main(argv=None) -> int:
if a.url:
base = a.url.rstrip("/")
else:
- port = a.port or int(cfg.get("port", 8080))
- base = f"http://127.0.0.1:{port}"
+ base = server_base(cfg.get("host"), a.port or int(cfg.get("port", 8080)))
red = redactor(key=key)
started = False
try:
diff --git a/tools/test_bench_host.py b/tools/test_bench_host.py
new file mode 100644
index 000000000..be0d67d09
--- /dev/null
+++ b/tools/test_bench_host.py
@@ -0,0 +1,39 @@
+"""Tests for the server address tools/strata_bench.py polls, without starting one.
+
+ python -m unittest tools.test_bench_host
+"""
+from __future__ import annotations
+
+import sys
+import unittest
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[1]
+sys.path.insert(0, str(ROOT / "tools"))
+import strata_bench as SB # noqa: E402
+
+
+class ServerBase(unittest.TestCase):
+ def test_uses_the_configured_host(self):
+ # The readiness poll was hardcoded to 127.0.0.1 while the server was started on the config's
+ # host, so a LAN bind left BENCH saying "still loading" until it was killed (#2330).
+ self.assertEqual(SB.server_base("192.168.1.10", 8080), "http://192.168.1.10:8080")
+
+ def test_defaults_to_loopback_without_a_host(self):
+ self.assertEqual(SB.server_base("", 9000), "http://127.0.0.1:9000")
+ self.assertEqual(SB.server_base(None, 9000), "http://127.0.0.1:9000")
+
+ def test_wildcard_binds_are_connected_through_loopback(self):
+ self.assertEqual(SB.server_base("0.0.0.0", 8080), "http://127.0.0.1:8080")
+ self.assertEqual(SB.server_base("::", 8080), "http://[::1]:8080")
+
+ def test_ipv6_literals_are_bracketed(self):
+ self.assertEqual(SB.server_base("fd00::5", 8080), "http://[fd00::5]:8080")
+ self.assertEqual(SB.server_base("[fd00::5]", 8080), "http://[fd00::5]:8080")
+
+ def test_a_hostname_is_left_alone(self):
+ self.assertEqual(SB.server_base("bench.local", 8080), "http://bench.local:8080")
+
+
+if __name__ == "__main__":
+ unittest.main()