mirror of
https://github.com/tailscale/tailscale.git
synced 2026-06-03 21:01:54 +08:00
WARNING: this is an unreviewed prototype; please do not assume this
works or is correct
The daemon's startBackendLocked reimplemented tsnet/tsnet.go's start()
nearly line-for-line — same tsd.NewSystem, netmon.New, tsdial.Dialer,
wgengine.NewUserspaceEngine, netstack.Create, netstack dial-hooks,
store.New, ipnlocal.NewLocalBackend, prefs, NeedsLogin handling, and
localapi.NewHandler. Plus the daemon kept its own GetTCPHandlerForFlow
listener registry, its own LocalAPI handler, and a hand-rolled
tailscaleIPs() reading from NetMapNoPeers.
This is a pure refactor: the daemon now constructs a tsnet.Server and
delegates to it. No tsnet code is touched.
startBackendLocked -> &tsnet.Server{...}.Start()
awaitRunning (Up) -> ts.Up(ctx)
RegisterListener -> ts.Listen + per-listener acceptLoop goroutine
serveDatapath dial -> ts.Dial
serveLocalAPI -> byte-splice via ts.LocalClient().Dial into
tsnet's in-process memnet localapi listener;
Hijacker and Flusher semantics still work
because we're a dumb byte pipe.
whoIs -> ts.LocalClient().WhoIs
tailscaleIPs -> ts.TailscaleIPs
CertDomains -> ts.CertDomains
Deletes the daemon-side getTCPHandlerForFlow / getUDPHandlerForFlow,
the listenerByKey registry, lookupListener, listenAddrFor +
pickEphemeralPort (tsnet's Listen handles port allocation), cmpOr,
the single-conn http.Server listener used to host our own localapi
handler, and the direct wgengine/magicsock/netstack/ipnlocal/
controlclient/tsdial/netmon/tsd/store/ipnauth/ipn/hostinfo imports.
Daemon size: 1160 -> 925 lines (-20%).
Mental surface in the daemon shrinks much more than the line count
because the heavy subsystems are no longer reached at all.
The integration test (TestTsnet2EndToEnd) still passes in ~8s; race
detector is clean. tsnet2/ (the client shim) is unchanged and still
imports zero of wgengine / magicsock / ipnlocal / netstack / localapi
/ controlclient (verified via go list -deps), so Goal 2 of the design
(WireGuard out of the app process) is preserved.
Minor behavior change: state file is now <state-dir>/tailscaled.state
instead of <state-dir>/tsnet2.state, because tsnet.Server picks the
filename. No v1 consumer depends on this.
Deferred: forwarding tsnet.Server.UserLogf (auth URLs etc.) over the
control channel to the app's UserLogf. tsnet logs them to its own
log.Printf for now.
|
||
|---|---|---|
| .. | ||
| addlicense | ||
| build-webclient | ||
| checkmetrics | ||
| cigocacher | ||
| cloner | ||
| connector-gen | ||
| containerboot | ||
| derper | ||
| derpprobe | ||
| dist | ||
| distsign | ||
| featuretags | ||
| get-authkey | ||
| gitops-pusher | ||
| hello | ||
| jsonimports | ||
| k8s-nameserver | ||
| k8s-operator | ||
| k8s-proxy | ||
| mkmanifest | ||
| mkpkg | ||
| mkversion | ||
| nardump | ||
| natc | ||
| netlogfmt | ||
| nginx-auth | ||
| omitsize | ||
| pgproxy | ||
| printdep | ||
| proxy-test-server | ||
| proxy-to-grafana | ||
| sniproxy | ||
| speedtest | ||
| ssh-auth-none-demo | ||
| stunc | ||
| stund | ||
| stunstamp | ||
| sync-containers | ||
| systray | ||
| tailscale | ||
| tailscaled | ||
| testcontrol | ||
| testwrapper | ||
| tl-longchain | ||
| tsconnect | ||
| tsidp | ||
| tsnet2d | ||
| tsnet-proxy | ||
| tsp | ||
| tsshd | ||
| tta | ||
| vet | ||
| viewer | ||
| vnet | ||
| xdpderper | ||