feat(socks): auth-code/JWT login, network presets, reliability settings, control plane + web panel - #18
Open
full-bars wants to merge 1 commit into
Open
Conversation
…gs, control plane + web panel Extends the socks5 client with developer-facing capabilities for test/beta networks and runtime tuning, mirroring the Android developer screen. Login: - --auth-code (env AUTH_CODE) redeems a code via POST /auth/code-login — the flow providers use; beta/test networks have no password accounts. - --jwt (env JWT) skips login entirely and uses an existing network JWT. - Password login remains the default when neither is given. Network presets: - --network=main|beta (env NETWORK) resolves api/platform URL pairs; explicit --api-url/--platform-url override per field. Reliability settings: - --reliability=<file> loads a partial JSON overlay of connect.ReliabilitySettings at startup (ms durations; nil keeps the engine default, explicit zero is applied). Merged over current settings so unset fields are never zeroed. Control plane (loopback only): - --control=<addr> starts a local HTTP server. Primary interface is an embedded single-page web panel (1s poll): measurements grid, session header with elapsed time + cumulative traffic + live throughput rates (auto-scaled, from /stats deltas), click-to-cycle preset knobs and toggles, per-exit drop/stall/resume/migrate, reset/shuffle/probe-all, quit. Same endpoints available directly: GET/PUT /settings, POST /actions, GET /metrics, GET /exits, GET /stats. - Security: loopback binding enforced at startup (non-loopback fails fast); mutating requests must carry no Origin header or a loopback Origin (CSRF guard); read-merge-write serialized under a mutex; request bodies capped at 64 KiB; server Read/Write/Idle timeouts. - Panel styled with the URnetwork design tokens from the beta.app.ur.network dashboard; layout, knob groups, and preset lists adapted from the developer tools screen in the URnetwork Beta Android app. Observability: - --metrics-every=<ms> prints reliability counters + exit table on an interval; --reset-metrics zeroes counters at startup. Tests: 26 unit tests race-clean covering reliability merge semantics, control endpoints, CSRF guard, loopback enforcement, concurrent-PUT race, stubbed code-login, /stats and quit action. gofmt + go vet clean.
full-bars
force-pushed
the
fix/socks-noauth-origin
branch
from
August 8, 2026 03:29
e2651ce to
1fba8f3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds three independent capabilities to the dev socks5 client, plus a metrics printer:
--auth-coderedeems a code via/auth/code-login(for beta/test networks that have no password accounts, the same flow the provider CLI uses).--jwtskips login entirely and uses an existing network JWT directly. Password login (--user-auth+--password) remains the default and is unchanged.--network=main|betapreset (envNETWORK) resolves the matching api/platform URL pair. Explicit--api-url/--platform-url(or their env vars) override the preset per field.--reliability=<file>loads a partial JSON overlay ofconnect.ReliabilitySettingsat startup. Durations are milliseconds in the file. A field absent from the file keeps the engine default; a field present with an explicit zero is applied. The overlay is merged onto the multi client's current settings, not applied standalone, so unset fields never get zeroed.--control=<addr>starts a local control plane, mirroring the Android app's developer screen. Its primary interface is a web panel; the same endpoints are also reachable over HTTP for scripting (see below). Binding is enforced to loopback at startup; a non-loopback--controladdress fails fast. Mutating requests additionally require either noOriginheader or a loopbackOrigin, so a web page open in a browser cannot drive the plane cross-origin even though it is reachable on loopback.--metrics-every=<ms>prints reliability counters and the exit table to stdout on an interval;--reset-metricszeroes the counters at startup.Web panel
--control=127.0.0.1:9998and open http://127.0.0.1:9998/ in a browser. The panel is a single embedded page (no external assets) that polls every 1s:The panel layout, its knob groups, and the preset value lists are adapted from the developer tools screen in the URnetwork Beta Android app (the beta-test network's mobile client).
HTTP endpoints (fallback / scripting)
The panel talks to the same local HTTP API, which is also available directly:
GET /settings— current settings, ms/json shapePUT /settings— partialreliabilityFilemerged onto current settings (read-merge-write under a mutex)POST /actions—drop,stall,migrate,shuffle,probe-all,reset-metricsGET /metrics— reliability counters snapshotGET /exits— current exit tableUsage examples
All examples bind the SOCKS5 listener to loopback (
127.0.0.1), which isalso the default when
--addris omitted. Use--addr 0.0.0.0:9999onlywhen you deliberately want other devices on the LAN to reach the proxy —
note the proxy has no SOCKS5 authentication, so never bind it to a public
interface.
Password login against the main network (default, shown explicitly):
Auth-code login against beta:
JWT login against beta, skipping login entirely:
Explicit endpoints, overriding the network preset:
Kitchen sink, on Windows (the control port is arbitrary; any free loopback
port works):
Example
settings.json(partial overlay; only named fields change, everything else keeps the engine default):{ "maxFlowsPerExit": 64, "sendStallTimeoutMs": 3000, "busyProbe": true }Warning
The control server is unauthenticated by design. Loopback-only binding and the
Originguard stop remote machines and browser cross-origin requests, but they do not stop other local processes or users on a shared machine from reading and changing settings, dropping exits, or migrating flows. Do not expose--controlbeyond loopback and do not run it on a shared or multi-tenant host.Verification
PUT /settingschangedmaxFlowsPerExitfrom 32 to 64 and the change was reflected on the nextGET /settings; a non-loopbackOriginheader on a mutating request was rejected with 403; in the browser, cycling duration/count knobs and toggling switches in the panel produced the expectedPUT /settingscalls and updated values. The screenshot above was taken while the proxy was actively carrying traffic (flows opened 13, all pinned to one exit; probes 1379/753).go test -race ./...).Notes
Note
VerdictsHeldSharedFate(an Android-fork-only counter) is not present in upstream connect'sReliabilityMetricsSnapshot, so it is omitted from the metrics readout and the control panel's measurements grid. Everything else in the snapshot is surfaced.socksproxyname in the CLI's own usage text is only the docopt usage label; the actual binary issocks(socks.exeon Windows).--reliabilityand the control server'sPUT /settingsshare the same merge path (applyFileOver+fileToSettings), so file-based and live-tuned settings behave identically with respect to nil-keeps-default / explicit-zero-applies semantics.