Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
feat: allow cross-host workers to register via --allowed-host
eli723c1bbe8053
diff --git a/c/cluster.py b/c/cluster.pyindex 64425846..6f0e5a53 100644--- a/c/cluster.py+++ b/c/cluster.py@@ -3,6 +3,8 @@import argparseimport json+import os+import sysimport threadingimport timefrom http.server import ThreadingHTTPServer@@ -99,14 +101,18 @@ class _Handler(openai_server.APIHandler):class ClusterServer(openai_server.APIServer):- def __init__(self, address, registry):+ def __init__(self, address, registry, allowed_hosts=()):ThreadingHTTPServer.__init__(self, address, _Handler)self.registry = registry# Shared APIHandler plumbing reads these off the server. The registry has# no API key or CORS surface, and its Host guard stays loopback + bind- # address (the same default openai_server enforces).+ # address (the same default openai_server enforces). A cross-host worker+ # registers from a LAN IP, so the operator opts those hosts in via+ # --allowed-host (the same #597 escape hatch coli serve exposes); the+ # default stays loopback + bind address.self.cors_origins = ()- self.allowed_hosts = ()+ self.allowed_hosts = tuple(+ h.strip().lower() for h in allowed_hosts if h and h.strip())# Connection-cap bookkeeping for the inherited APIServer.process_request /# _release / close_request. There is no engine or model to carry, so# initialise the tracking state directly rather than APIServer.__init__.@@ -120,8 +126,11 @@ def _endpoint(coordinator, path):return coordinator.rstrip("/") + "/v1/cluster/" + path-def serve(host="127.0.0.1", port=8765, stale_after=30.0):- server = ClusterServer((host, port), ClusterRegistry(stale_after))+def serve(host="127.0.0.1", port=8765, stale_after=30.0, allowed_hosts=()):+ if allowed_hosts and "*" in allowed_hosts:+ print("WARNING: --allowed-host '*' accepts ANY Host header "+ "(DNS-rebinding guard disabled)", file=sys.stderr)+ server = ClusterServer((host, port), ClusterRegistry(stale_after), allowed_hosts)print(f"colibri cluster coordinator listening on http://{host}:{port}", flush=True)try:server.serve_forever()@@ -157,8 +166,11 @@ def main():parser.add_argument("--host", default="127.0.0.1")parser.add_argument("--port", type=int, default=8765)parser.add_argument("--stale-after", type=float, default=30.0)+ parser.add_argument("--allowed-host", action="append",+ default=[h.strip() for h in os.environ.get("COLI_ALLOWED_HOSTS", "").split(",") if h.strip()],+ help="additional Host header accepted by the DNS-rebinding guard; repeat as needed")args = parser.parse_args()- serve(args.host, args.port, args.stale_after)+ serve(args.host, args.port, args.stale_after, args.allowed_host)if __name__ == "__main__":diff --git a/c/coli b/c/coliindex eb7a6321..9d2d04f8 100755--- a/c/coli+++ b/c/coli@@ -1516,7 +1516,7 @@ def _pid_alive(pid):def cmd_cluster_coordinator(a):from cluster import serve- serve(a.host, a.port, a.stale_after)+ serve(a.host, a.port, a.stale_after, a.allowed_host)def cmd_cluster_worker(a):engine=need_worker_model(a.model)@@ -1800,6 +1800,9 @@ def main():pcoord=cluster_sub.add_parser("coordinator", help="serve worker registration and discovery")pcoord.add_argument("--host",default="127.0.0.1"); pcoord.add_argument("--port",type=int,default=8765)pcoord.add_argument("--stale-after",type=float,default=30.0)+ pcoord.add_argument("--allowed-host",action="append",+ default=[h.strip() for h in os.environ.get("COLI_ALLOWED_HOSTS","").split(",") if h.strip()],+ help="additional Host header accepted by the DNS-rebinding guard; repeat as needed")pworker=cluster_sub.add_parser("worker", parents=[common], help="serve disk-backed expert compute")pworker.add_argument("--port",type=int,default=int(os.environ.get("CLUSTER_WORKER_PORT","9100")))pworker.add_argument("--coordinator",default=os.environ.get("CLUSTER_COORDINATOR"))