Crate: kinetic-pac
Stage: 11
Reading Time: 60 mins
Depends On: kinetic-core, kinetic-daemon (running at port 16000)
What Is This?
kinetic-pac is the Proxy Auto-Configuration server for the Kinetic network. It serves a dynamically generated JavaScript PAC file at http://127.0.0.1:16001/proxy.pac, and injects this URL into the OS-level proxy settings so all browsers and network-aware applications automatically route .kin traffic through the local Kinetic HTTP proxy.
A PAC (Proxy Auto-Config) file is a JavaScript function that browsers and OSes call for every HTTP request: “given this URL and hostname, should I go direct or use a proxy?” Kinetic generates this function dynamically based on whatever TLD proxies are currently registered.
Key Pieces
SavedState+ lockfile: Captures the original OS proxy settings before modification and writes them atomically toproxy_active.lock. If the daemon crashes, the next launch restores the old settings before applying new ones.ProxyConfiguratortrait + OS implementations: Platform-specific code (KdeConfigurator,GnomeConfigurator,MacosConfigurator,WindowsConfigurator) that shells out togsettings,kwriteconfig5,networksetup, or PowerShell to inject the PAC URL into the OS network settings.PacManager: The lifecycle controller. Callssave_previous_state→ atomic lockfile write →install. Reverses onuninstall.- The PAC HTTP server: An Axum server at
http://127.0.0.1:16001with a single/proxy.pacroute. On each request, it scans theproxies/directory for registered JSON proxy descriptors and generates a fresh JavaScript PAC function. - Graceful shutdown: A
tokio::spawnbackground task listens forSIGTERM(Unix) orCtrl+Cand callspac_manager.uninstall()beforestd::process::exit(0).
How to Read This Stage
- Start with
02_pac_main_1.mdto understandSavedState,ProxyConfigurator,PacManager, and crash recovery. - Read
03_pac_main_2.mdto see the PAC file generation loop and the shutdown signal handling. - Finish with
04_pac_os.mdto understand each platform’s concrete proxy injection commands.