# switchboard: toybox's only way out, after Flower's switchboard. # # Each socket is a handle with fixed labels: a WebSocket upgrade starts a # Cap'n Web session whose main object is that handle (see switchboard.js). # Whoever starts workerd hands the sockets in (-S/-s), so whoever holds a # socket's fd holds that handle and no other. using Workerd = import "/workerd/workerd.capnp"; const config :Workerd.Config = ( services = [ (name = "main", worker = .switchboard), (name = "nowhere", network = (allow = [])), (name = "public-net", network = (allow = ["public"], tlsOptions = (trustBrowserCas = true))), (name = "local-net", network = (allow = ["local"], tlsOptions = (trustBrowserCas = true))), ], sockets = [ (name = "public", http = (), service = (name = "main", props = (json = "{\"network\":\"public\"}"))), (name = "local", http = (), service = (name = "main", props = (json = "{\"network\":\"local\"}"))), ], ); const switchboard :Workerd.Worker = ( compatibilityDate = "2026-10-01", modules = [ (name = "switchboard.js", esModule = embed "switchboard.js"), (name = "labels.js", esModule = embed "labels.js"), (name = "capnweb", esModule = embed "node_modules/capnweb/dist/index-workers.js"), ], bindings = [ (name = "PUBLIC", service = "public-net"), (name = "LOCAL", service = "local-net"), ], globalOutbound = "nowhere", );