mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
internal/proxy keeps no package state. newServer makes a server from the config, as Main starts (it replaces Config.apply, loadPolicies and every global they set), and each part keeps what it changes under its own lock: events (the event log and recent blocks), egress (the policy, the host's addresses in hostAddrs, the company proxies in upstreams), secrets (the bindings file and the values cache, file lock taken before the values'), ca (devvm's CA and its leaves), links (the list and the sockets' folder) and nixCache (the cache's folder, checked narinfos, fetches and slots). The proxy's own log is a *log.Logger each part is given; Main's lifeline tick is a const, and run takes it for tests. What's left package-level is error sentinels and three fixed tables (notPublic, nat64, githubMinting), now in the structure test's allowedVars; the structure test no longer leaves internal/proxy out, and its rule case for the proxy fails a var. Tests make their own server with newServer (testServer, listen, logs, fakeSecret on a secrets, testCA) and all run in parallel. TestServersApart checks two servers in one process share no password, blocks, events, values or CA leaves. A tunnel to a host the policy allows passes the far end's bytes to the VM from the start (splice's before), so a server that speaks first gets its greeting through; the VM's bytes still pass only after the SNI check, which reads one byte first and the ClientHello only when it starts 0x16. TestTunnelServerSpeaksFirst failed on the code before. Docs: the proxy README (the server, files, testing), network.md's tunnel paragraph, AGENTS.md's test-seams line, Contributing's package-vars row. Co-Authored-By: Claude Opus 5.5 <[email protected]>