summaryrefslogtreecommitdiffhomepage
path: root/control/controlclient/auto.go
AgeCommit message (Collapse)AuthorFilesLines
2026-01-23all: remove AUTHORS file and references to itWill Norris1-1/+1
This file was never truly necessary and has never actually been used in the history of Tailscale's open source releases. A Brief History of AUTHORS files --- The AUTHORS file was a pattern developed at Google, originally for Chromium, then adopted by Go and a bunch of other projects. The problem was that Chromium originally had a copyright line only recognizing Google as the copyright holder. Because Google (and most open source projects) do not require copyright assignemnt for contributions, each contributor maintains their copyright. Some large corporate contributors then tried to add their own name to the copyright line in the LICENSE file or in file headers. This quickly becomes unwieldy, and puts a tremendous burden on anyone building on top of Chromium, since the license requires that they keep all copyright lines intact. The compromise was to create an AUTHORS file that would list all of the copyright holders. The LICENSE file and source file headers would then include that list by reference, listing the copyright holder as "The Chromium Authors". This also become cumbersome to simply keep the file up to date with a high rate of new contributors. Plus it's not always obvious who the copyright holder is. Sometimes it is the individual making the contribution, but many times it may be their employer. There is no way for the proejct maintainer to know. Eventually, Google changed their policy to no longer recommend trying to keep the AUTHORS file up to date proactively, and instead to only add to it when requested: https://opensource.google/docs/releasing/authors. They are also clear that: > Adding contributors to the AUTHORS file is entirely within the > project's discretion and has no implications for copyright ownership. It was primarily added to appease a small number of large contributors that insisted that they be recognized as copyright holders (which was entirely their right to do). But it's not truly necessary, and not even the most accurate way of identifying contributors and/or copyright holders. In practice, we've never added anyone to our AUTHORS file. It only lists Tailscale, so it's not really serving any purpose. It also causes confusion because Tailscalars put the "Tailscale Inc & AUTHORS" header in other open source repos which don't actually have an AUTHORS file, so it's ambiguous what that means. Instead, we just acknowledge that the contributors to Tailscale (whoever they are) are copyright holders for their individual contributions. We also have the benefit of using the DCO (developercertificate.org) which provides some additional certification of their right to make the contribution. The source file changes were purely mechanical with: git ls-files | xargs sed -i -e 's/\(Tailscale Inc &\) AUTHORS/\1 contributors/g' Updates #cleanup Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <will@tailscale.com>
2025-11-18types/key,wgengine/magicsock,control/controlclient,ipn: add debug disco key ↵James Tucker1-0/+7
rotation Adds the ability to rotate discovery keys on running clients, needed for testing upcoming disco key distribution changes. Introduces key.DiscoKey, an atomic container for a disco private key, public key, and the public key's ShortString, replacing the prior separate atomic fields. magicsock.Conn has a new RotateDiscoKey method, and access to this is provided via localapi and a CLI debug command. Note that this implementation is primarily for testing as it stands, and regular use should likely introduce an additional mechanism that allows the old key to be used for some time, to provide a seamless key rotation rather than one that invalidates all sessions. Updates tailscale/corp#34037 Signed-off-by: James Tucker <james@tailscale.com>
2025-11-18types/netmap,*: remove some redundant fields from NetMapBrad Fitzpatrick1-1/+1
Updates #12639 Change-Id: Ia50b15529bd1c002cdd2c937cdfbe69c06fa2dc8 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-11-17control/controlclient: remove some public API, move to Options & test-onlyBrad Fitzpatrick1-8/+27
Includes adding StartPaused, which will be used in a future change to enable netmap caching testing. Updates #12639 Change-Id: Iec39915d33b8d75e9b8315b281b1af2f5d13a44a Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-11-14control/controlclient,ipn/ipnlocal: replace State enum with boolean flagsJames Tucker1-32/+20
Remove the State enum (StateNew, StateNotAuthenticated, etc.) from controlclient and replace it with two explicit boolean fields: - LoginFinished: indicates successful authentication - Synced: indicates we've received at least one netmap This makes the state more composable and easier to reason about, as multiple conditions can be true independently rather than being encoded in a single enum value. The State enum was originally intended as the state machine for the whole client, but that abstraction moved to ipn.Backend long ago. This change continues moving away from the legacy state machine by representing state as a combination of independent facts. Also adds test helpers in ipnlocal that check independent, observable facts (hasValidNetMap, needsLogin, etc.) rather than relying on derived state enums, making tests more robust. Updates #12639 Signed-off-by: James Tucker <james@tailscale.com>
2025-11-14control/controlclient: make Observer optionalBrad Fitzpatrick1-4/+6
As a baby step towards eventbus-ifying controlclient, make the Observer optional. This also means callers that don't care (like this network lock test, and some tests in other repos) can omit it, rather than passing in a no-op one. Updates #12639 Change-Id: Ibd776b45b4425c08db19405bc3172b238e87da4e Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-11-13ipn/ipnlocal: remove all the weird locking (LockedOnEntry, UnlockEarly, etc)Brad Fitzpatrick1-0/+7
Fixes #11649 Updates #16369 Co-authored-by: James Sanderson <jsanderson@tailscale.com> Change-Id: I63eaa18fe870ddf81d84b949efac4d1b44c3db86 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-10-30control/controlclient: remove unused reference to mapCtx (#17614)James 'zofrex' Sanderson1-2/+1
Updates #cleanup Signed-off-by: James Sanderson <jsanderson@tailscale.com>
2025-10-02control/controlclient,health,ipn/ipnlocal,health: fix deadlock by deleting ↵Brad Fitzpatrick1-31/+0
health reporting A recent change (009d702adfa0fc) introduced a deadlock where the /machine/update-health network request to report the client's health status update to the control plane was moved to being synchronous within the eventbus's pump machinery. I started to instead make the health reporting be async, but then we realized in the three years since we added that, it's barely been used and doesn't pay for itself, for how many HTTP requests it makes. Instead, delete it all and replace it with a c2n handler, which provides much more helpful information. Fixes tailscale/corp#32952 Change-Id: I9e8a5458269ebfdda1c752d7bbb8af2780d71b04 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-10-01tsnet: remove AuthenticatedAPITransport (API-over-noise) supportBrad Fitzpatrick1-10/+0
It never launched and I've lost hope of it launching and it's in my way now, so I guess it's time to say goodbye. Updates tailscale/corp#4383 Updates #17305 Change-Id: I2eb551d49f2fb062979cc307f284df4b3dfa5956 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-09-28util/backoff: rename logtail/backoff package to util/backoffBrad Fitzpatrick1-1/+1
It has nothing to do with logtail and is confusing named like that. Updates #cleanup Updates #17323 Change-Id: Idd34587ba186a2416725f72ffc4c5778b0b9db4a Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-09-22controlclient/auto: switch eventbus to using a monitor (#17205)Claus Lensbøl1-19/+16
Only changes how the go routine consuming the events starts and stops, not what it does. Updates #15160 Signed-off-by: Claus Lensbøl <claus@tailscale.com>
2025-09-19health: remove direct callback and replace with eventbus (#17199)Claus Lensbøl1-7/+33
Pulls out the last callback logic and ensures timers are still running. The eventbustest package is updated support the absence of events. Updates #15160 Signed-off-by: Claus Lensbøl <claus@tailscale.com>
2025-09-15control/controlclient: introduce eventbus messages instead of callbacks (#16956)Claus Lensbøl1-1/+5
This is a small introduction of the eventbus into controlclient that communicates with mainly ipnlocal. While ipnlocal is a complicated part of the codebase, the subscribers here are from the perspective of ipnlocal already called async. Updates #15160 Signed-off-by: Claus Lensbøl <claus@tailscale.com>
2025-05-22control/controlclient,health,tailcfg: refactor control health messages (#15839)James 'zofrex' Sanderson1-1/+6
* control/controlclient,health,tailcfg: refactor control health messages Updates tailscale/corp#27759 Signed-off-by: James Sanderson <jsanderson@tailscale.com> Signed-off-by: Paul Scott <408401+icio@users.noreply.github.com> Co-authored-by: Paul Scott <408401+icio@users.noreply.github.com>
2025-03-12control/controlclient, ipn: add client audit logging (#14950)Jonathan Nobels1-0/+7
updates tailscale/corp#26435 Adds client support for sending audit logs to control via /machine/audit-log. Specifically implements audit logging for user initiated disconnections. This will require further work to optimize the peristant storage and exclusion via build tags for mobile: tailscale/corp#27011 tailscale/corp#27012 Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
2025-01-30control/controlclient: flesh out a recently added commentBrad Fitzpatrick1-6/+11
Updates tailscale/corp#26058 Change-Id: Ib46161fbb2e79c080f886083665961f02cbf5949
2025-01-30control/controlclient: add missing word in commentBrad Fitzpatrick1-1/+1
Found by review.ai. Updates #cleanup Change-Id: Ib9126de7327527b8b3818d92cc774bb1c7b6f974 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-01-24control/controlclient: skip SetControlClientStatus when queue has newer ↵Brad Fitzpatrick1-2/+69
results later Updates #1909 Updates #12542 Updates tailscale/corp#26058 Change-Id: I3033d235ca49f9739fdf3deaf603eea4ec3e407e Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-05-17control/controlclient: delete unused Client.Login Oauth2Token fieldBrad Fitzpatrick1-7/+5
Updates #12172 (then need to update other repos) Change-Id: I439f65e0119b09e00da2ef5c7a4f002f93558578 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-05-07cmd/tailscale,controlclient,ipnlocal: fix 'up', deflake tests moreBrad Fitzpatrick1-3/+14
The CLI's "up" is kinda chaotic and LocalBackend.Start is kinda chaotic and they both need to be redone/deleted (respectively), but this fixes some buggy behavior meanwhile. We were previously calling StartLoginInteractive (to start the controlclient's RegisterRequest) redundantly in some cases, causing test flakes depending on timing and up's weird state machine. We only need to call StartLoginInteractive in the client if Start itself doesn't. But Start doesn't tell us that. So cheat a bit and a put the information about whether there's a current NodeKey in the ipn.Status. It used to be accessible over LocalAPI via GetPrefs as a private key but we removed that for security. But a bool is fine. So then only call StartLoginInteractive if that bool is false and don't do it in the WatchIPNBus loop. Fixes #12028 Updates #12042 Change-Id: I0923c3f704a9d6afd825a858eb9a63ca7c1df294 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-05-07control/controlclient: early return and outdent some codeBrad Fitzpatrick1-25/+23
I found this too hard to read before. This is pulled out of #12033 as it's unrelated cleanup in retrospect. Updates #12028 Change-Id: I727c47e573217e3d1973c5b66a76748139cf79ee Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-04-26control/controlclient: plumb health.TrackerBrad Fitzpatrick1-7/+6
Updates #11874 Updates #4136 Change-Id: Ia941153bd83523f0c8b56852010f5231d774d91a Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-04-25health: add Tracker type, in prep for removing global variablesBrad Fitzpatrick1-6/+6
This moves most of the health package global variables to a new `health.Tracker` type. But then rather than plumbing the Tracker in tsd.System everywhere, this only goes halfway and makes one new global Tracker (`health.Global`) that all the existing callers now use. A future change will eliminate that global. Updates #11874 Updates #4136 Change-Id: I6ee27e0b2e35f68cb38fecdb3b2dc4c3f2e09d68 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-01-18control/controlclient,util/execqueue: extract execqueue into a packageJames Tucker1-95/+4
This is a useful primitive for asynchronous execution of ordered work I want to use in another change. Updates tailscale/corp#16833 Signed-off-by: James Tucker <james@tailscale.com>
2023-12-21all: cleanup unused code, part 2 (#10670)Andrew Lytvynov1-16/+0
And enable U1000 check in staticcheck. Updates #cleanup Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
2023-11-05control/controlclient: move lastPrintMap field from Direct to mapSessionBrad Fitzpatrick1-1/+1
It was a really a mutable field owned by mapSession that we didn't move in earlier commits. Once moved, it's then possible to de-func-ify the code and turn it into a regular method rather than an installed optional hook. Noticed while working to move map session lifetimes out of Direct.sendMapRequest's single-HTTP-connection scope. Updates #7175 Updates #cleanup Change-Id: I6446b15793953d88d1cabf94b5943bb3ccac3ad9 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-09-12control/controlclient, types/netmap: start plumbing delta netmap updatesBrad Fitzpatrick1-0/+45
Currently only the top four most popular changes: endpoints, DERP home, online, and LastSeen. Updates #1909 Change-Id: I03152da176b2b95232b56acabfb55dcdfaa16b79 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-09-05control/controlclient: check c.closed in waitUnpauseMaisem Ali1-1/+1
We would only check if the client was paused, but not if the client was closed. This meant that a call to Shutdown may block forever/leak goroutines Updates #cleanup Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-09-02ipn/ipnlocal: fix deadlock in resetControlClientLockedMaisem Ali1-1/+2
resetControlClientLocked is called while b.mu was held and would call cc.Shutdown which would wait for the observer queue to drain. However, there may be active callbacks from cc already waiting for b.mu resulting in a deadlock. This makes it so that resetControlClientLocked does not call Shutdown, and instead just returns the value. It also makes it so that any status received from previous cc are ignored. Updates tailscale/corp#12827 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-09-01control/controlclient: clean up various things in prep for state overhaulBrad Fitzpatrick1-217/+150
We want the overall state (used only for tests) to be computed from the individual states of each component, rather than moving the state around by hand in dozens of places. In working towards that, we found a lot of things to clean up. Updates #cleanup Change-Id: Ieaaae5355dfae789a8ec7a56ce212f1d7e3a92db Co-authored-by: Maisem Ali <maisem@tailscale.com> Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-09-01control/controlclient: serialize Observer callsBrad Fitzpatrick1-8/+86
Don't just start goroutines and hope for them to be ordered. Fixes potential regression from earlier 7074a40c0. Updates #cleanup Change-Id: I501a6f3e4e8e6306b958bccdc1e47869991c31f7 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-31control/controlclient: run SetControlClientStatus in goroutineMaisem Ali1-8/+4
We have cases where the SetControlClientStatus would result in a Shutdown call back into the auto client that would block forever. The right thing to do here is to fix the LocalBackend state machine but thats a different dumpster fire that we are slowly making progress towards. This makes it so that the SetControlClientStatus happens in a different goroutine so that calls back into the auto client do not block. Also add a few missing mu.Unlocks in LocalBackend.Start. Updates #9181 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-08-31control/controlclient: rename Auto cancel methods, add missing Lock variantBrad Fitzpatrick1-18/+26
Then use the Locked variants in Shutdown while we already hold the lock. Updates #cleanup Change-Id: I367d53e6be6f37f783c8f43fc9c4d498d0adf501 Co-authored-by: Maisem Ali <maisem@tailscale.com> Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-30control/controlclient: remove unused StartLogoutBrad Fitzpatrick1-11/+0
Updates #cleanup Co-authored-by: Maisem Ali <maisem@tailscale.com> Change-Id: I9d052fdbee787f1e8c872124e4bee61c7f04d142 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-30control/controlclient: cancel map poll when logging outBrad Fitzpatrick1-0/+1
Don't depend on the server to do it. Updates #cleanup Change-Id: I8ff40b02aa877155a71fd4db58cbecb872241ac8 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-30control/controlclient: de-pointer Status.PersistView, document moreBrad Fitzpatrick1-3/+2
Updates #cleanup Updates #1909 Change-Id: I31d91e120e3b299508de2136021eab3b34131a44 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-30control/controlclient: delete Status.Log{in,out}FinishedBrad Fitzpatrick1-15/+5
They were entirely redundant and 1:1 with the status field so this turns them into methods instead. Updates #cleanup Updates #1909 Change-Id: I7d939750749edf7dae4c97566bbeb99f2f75adbc Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-30control/controlclient: unexport Status.state, add test-only accessorBrad Fitzpatrick1-1/+1
Updates #cleanup Updates #1909 Change-Id: I38dcde6fa0de0f58ede4529992cee2e36de33dd6 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-30control/controlclient: merge, simplify two health check callsBrad Fitzpatrick1-3/+2
I'm trying to remove some stuff from the netmap update path. Updates #1909 Change-Id: Iad2c728dda160cd52f33ef9cf0b75b4940e0ce64 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-29control/controlclient: clean up a few little thingsBrad Fitzpatrick1-8/+9
De-pointer a *time.Time type, move it after the mutex which guard is, rename two test-only methods with our conventional "ForTest" suffix. Updates #cleanup Change-Id: I4f4d1acd9c2de33d9c3cb6465d7349ed051aa9f9 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-28control/controlclient: replace a status func with Observer interfaceBrad Fitzpatrick1-12/+12
For now the method has only one interface (the same as the func it's replacing) but it will grow, eventually with the goal to remove the controlclient.Status type for most purposes. Updates #1909 Change-Id: I715c8bf95e3f5943055a94e76af98d988558a2f2 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-13control/controlclient: move lastUpdateGenInformed to tighter scopeBrad Fitzpatrick1-7/+7
No need to have it on Auto or be behind a mutex; it's only read/written from a single goroutine. Move it there. Updates tailscale/corp#5761 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-12control/controlclient: refactor in prep for optimized delta handlingBrad Fitzpatrick1-26/+37
See issue. This is a baby step towards passing through deltas end-to-end from node to control back to node and down to the various engine subsystems, not computing diffs from two full netmaps at various levels. This will then let us support larger netmaps without burning CPU. But this change itself changes no behavior. It just changes a func type to an interface with one method. That paves the way for future changes to then add new NetmapUpdater methods that do more fine-grained work than updating the whole world. Updates #1909 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-11control/controlclient: avert a data race when logging (#8863)M. J. Fromberger1-2/+5
The read of the synced field for logging takes place outside the lock, and races with other (locked) writes of this field, including for example the one at current line 556 in mapRoutine. Updates tailscale/corp#13856 Change-Id: I056b36d7a93025aafdf73528dd7645f10b791af6 Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
2023-08-10control/controlclient: add Auto.updateRoutineMaisem Ali1-167/+163
Instead of having updates replace the map polls, create a third goroutine which is solely responsible for making sure that control is aware of the latest client state. This also makes it so that the streaming map polls are only broken when there are auth changes, or the client is paused. Updates tailscale/corp#5761 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-08-08control/controlclient: use ptr.ToMaisem Ali1-2/+2
Updates #cleanup Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-08-04control: use tstime instead of time (#8595)Claire Wang1-8/+9
Updates #8587 Signed-off-by: Claire Wang <claire@tailscale.com>
2023-07-13control/controlclient: reset backoff in mapRoutine on netmap recvMaisem Ali1-0/+2
We were never resetting the backoff in streaming mapResponses. The call to `PollNetMap` always returns with an error. Changing that contract is harder, so manually reset backoff when a netmap is received. Updates tailscale/corp#12894 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-04-12net/sockstats: pass in logger to sockstats.WithSockStatsMihai Parparita1-4/+4
Using log.Printf may end up being printed out to the console, which is not desirable. I noticed this when I was investigating some client logs with `sockstats: trace "NetcheckClient" was overwritten by another`. That turns to be harmless/expected (the netcheck client will fall back to the DERP client in some cases, which does its own sockstats trace). However, the log output could be visible to users if running the `tailscale netcheck` CLI command, which would be needlessly confusing. Updates tailscale/corp#9230 Signed-off-by: Mihai Parparita <mihai@tailscale.com>