tailscale/cmd/derper
Brad Fitzpatrick 3d7fb6c21d derp/derphttp: fix race in mesh watcher
The derphttp client automatically reconnects upon failure.

RunWatchConnectionLoop called derphttp.Client.WatchConnectionChanges
once, but that wrapper method called the underlying
derp.Client.WatchConnectionChanges exactly once on derphttp.Client's
currently active connection. If there's a failure, we need to re-subscribe
upon all reconnections.

This removes the derphttp.Client.WatchConnectionChanges method, which
was basically impossible to use correctly, and changes it to be a
boolean field on derphttp.Client alongside MeshKey and IsProber. Then
it moves the call to the underlying derp.Client.WatchConnectionChanges
to derphttp's client connection code, so it's resubscribed on any
reconnect.

Some paranoia is then added to make sure people hold the API right,
not calling derphttp.Client.RunWatchConnectionLoop on an
already-started Client without having set the bool to true. (But still
auto-setting it to true if that's the first method that's been called
on that derphttp.Client, as is commonly the case, and prevents
existing code from breaking)

Fixes tailscale/corp#9916
Supercedes tailscale/tailscale#9719

Co-authored-by: Val <valerie@tailscale.com>
Co-authored-by: Irbe Krumina <irbe@tailscale.com>
Co-authored-by: Anton Tolchanov <anton@tailscale.com>
Signed-off-by: Brad Fitzpatrick <brad@danga.com>
2023-10-31 19:24:25 +00:00
..
bootstrap_dns_test.go cmd/derper: count bootstrap dns unique lookups. 2023-08-17 08:02:56 -07:00
bootstrap_dns.go cmd/derper: count bootstrap dns unique lookups. 2023-08-17 08:02:56 -07:00
cert.go cmd/derper: disable http2 2023-04-26 20:45:32 -07:00
depaware.txt ipn, safesocket: use Windows token in LocalAPI 2023-10-26 09:43:19 -06:00
derper_test.go net/packet: split off checksum munging into different pkg 2023-10-11 14:25:58 -07:00
derper.go cmd/derper,tsweb: consistently add HTTP security headers (#8579) 2023-07-11 11:53:46 -07:00
mesh.go derp/derphttp: fix race in mesh watcher 2023-10-31 19:24:25 +00:00
websocket.go net/wsconn: accept a remote addr string and plumb it through 2023-08-29 16:57:16 -07:00