* golang.org/x/crypto: v0.58.0 to v0.59.0
* golang.org/x/mod: v0.41.0 to v0.43.0
* golang.org/x/sync: v0.24.0 to v0.25.0
* golang.org/x/text: v0.43.0 to v0.44.0
* golang.org/x/tools: v0.51.0 to v0.52.0
x/crypto v0.59.0 removed the DSA keys from ssh/testdata, so drop or
swap out the DSA test cases in tempfork/sshtest/ssh to match upstream.
Triggered by @bradfitz via the bumpdep workflow.
Updates tailscale/corp#47960
Signed-off-by: Dep Updater <noreply+dep-updater@tailscale.com>
A watch session's UserProfiles dedup state was only reset when the
self node delivered to it changed, as of c9fb05b6f5. Switching to
a profile that never gets a self node, such as a stopped or logged
out one, and back delivered the same self node again, so the profiles
were not resent to watchers that had dropped them on the switch. The
Windows GUI then listed no tagged or other users' devices.
Reset the dedup state on a profile change as well.
Updates #19889
Updates tailscale/corp#51597
Signed-off-by: Nick Khyl <nickk@tailscale.com>
Some HTTP proxies (as seen in ChatGPT Work's sandbox) intercept TLS and
refuse DERP's "Upgrade: DERP" request but allow WebSocket upgrades,
like browsers use. derphttp could already speak DERP over WebSockets,
but only on js/wasm or with the ts_debug_websockets build tag and an
envknob, and that path dials with its own http.Client, skipping the
DERP node selection, proxy CONNECT, and TLS logic of the normal path.
Add derphttp.HookUpgradeWebsocket. When it's set and a client's HTTP
upgrade to DERP fails after any TLS handshake succeeded, the client
redials and calls the hook to do a WebSocket handshake over the new
connection instead. Once that works, the client keeps using WebSockets
for its reconnects until they fail, so it doesn't pay for a refused
upgrade every time.
The new feature/derpwebsocket package sets the hook. Neither tailscaled
nor tsnet links it in; programs that want the fallback, like tailcat,
import it.
Updates #22412
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: I20e4b29f1bca6e7e5e3b33f960ce9d331ec7dac9
SetChildren took oldChildren from its argument instead of from
h.children, so it closed the idle connections of the children it had
just set and left those of the replaced children open.
FileSystemForRemote builds a fresh Handler for every request from its
long-lived children, so idle connections to the local file server were
closed before every request and were generally not reused.
Updates #11187
Signed-off-by: Lim-jooyoung <mmporong@gmail.com>
The datapath resolved a Magic IP to its Transit IP and then, in a second
lock acquisition, counted the new flow against the assignment holding
that Transit IP. A concurrent reserveAddresses could expire the
assignment in between and hand the Transit IP to an unrelated
destination, so the flow was installed DNATing to an address another
destination now owned, counted against that stranger's assignment.
Merge the two steps into ClientFlowCreatedForMagicIP, which resolves and
counts under one c.mu acquisition.
Fixes https://github.com/tailscale/corp/issues/44273
Change-Id: Iefae902267fd06a5d2c965a3570b6977921be76f
Signed-off-by: Mazdak Nasab <mazdak.nasab@gmail.com>
UpdateNetmapDelta updated a peer's endpoint but not its peersByID
snapshot. A later full netmap restoring the pre-delta DERP home or
endpoints then matched the stale snapshot, so the updateNodes fast path
skipped it and magicsock kept sending to the old DERP region.
Fixes#22379
Change-Id: I361f90e6063ca9e9dde02be8074b305622e46e5b
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pkg.css was publishing Tailwind CSS classes unnecessarily which could
cause conflicts with downstream consumers (e.g., if the downstream uses
Tailwind 4 as an example).
Only publish xterm's styles as these are needed for the components used
by the library.
Updates https://github.com/tailscale/corp/issues/50293
Signed-off-by: Mario Minardi <mario@tailscale.com>
nodeBackend.UpdateNetmapDelta returned false on a per-field patch for a
peer it didn't have, such as one filtered out by tailnet lock, dropping
the batch's remaining patches. LocalBackend ignored the result and
reported success, so controlclient never sent a full netmap, and its
peer dedup then hid later updates for those peers. Skip such patches
instead, and return false from LocalBackend if nodeBackend fails.
Updates #22379
Change-Id: I142bd47a89568d0f6c457f0da08601f41609d8f7
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
suggestExitNode groups candidates by DERP home region, but a HomeDERP
patch on an exit node other than the current suggestion didn't trigger
a recompute, so the suggestion could stay stale until the next full
netmap.
Updates #22379
Change-Id: Ib0c1dd9bf41fe40eac77fca378015c97fba600d1
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Userspace-only programs like tailcat don't need to watch the OS
network state, so in sandboxes without netlink access (as in ChatGPT
Work's) they'd like to use netmon.NewStatic instead of netmon.New,
which fails there. But two things broke with a static Monitor:
If reading the interface state failed, NewStatic left it nil, and
callers of InterfaceState don't expect nil.
LinkChangeLogLimiter, used by magicsock, subscribed to the static
Monitor's nil event bus client and panicked. Static monitors never
publish link changes, so skip the subscription.
Updates #22412
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: Ifa826c8cbac6a82b8a15f57bc8178b364fc30e54
netns.SetEnabled(false) is for processes like userspace-only clients
whose traffic never routes back into themselves, so they don't need
the namespace setup. But FromDialer also skipped the ALL_PROXY SOCKS
wrapping when disabled, so such processes couldn't reach the internet
in environments that only allow egress via a proxy, such as ChatGPT
Work's sandbox.
Only skip the namespace setup when disabled, and still wrap the dialer
for the proxy.
Updates #22412
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: Ic2023a329c640a1e8de32b157ed608ba385000a1
tcpproxy propagates a backend's close to the client by calling CloseWrite
on the source connection. connHalf did not implement it, so the call was a
no-op and the client never saw EOF. TestTCPRoundRobinHandler only unblocked
the proxy's remaining copy goroutine by writing more data after the first
echo. When the backend closed with that data still buffered in the pipe,
the write was discarded and the test hung until the 10 minute timeout.
Implement both halves of the half-close contract on connHalf. A new test
covers buffered data surviving CloseWrite, EOF on the read after it, and
writes failing after CloseRead.
Fixes#17533
Signed-off-by: Yunus Emre Karaman <emre884k@gmail.com>
The test asserts that a successful probe records a positive transfer
time, but the transfer is shorter than one clock tick on the Windows CI
runner: four attempts at 1 MiB plus their connection setups took 2.3ms
in total, yet every measurement read exactly 0, so the retry loop added
in #20214 just re-measured zero and then failed with
"http_bw_transfer_time_seconds_total = 0 after 4 attempts".
A 1 MiB loopback transfer takes ~0.4ms here, so no payload small enough
for a unit test is reliably measurable against a millisecond-coarse
clock. Make the transfer span more than one tick instead: /download now
writes half the payload, flushes, sleeps 50ms, then writes the rest.
The probe measures ~52ms, so the >0 assertion holds deterministically
and the retry loop can be deleted.
Fixes#21620
Signed-off-by: Yunus Emre Karaman <emre884k@gmail.com>
* golang.org/x/sys: v0.49.0 to v0.50.0
Triggered by @bradfitz via the bumpdep workflow.
Updates #22390
Change-Id: I402717314704a7f7b164a15e073608ef9dcc31fb
Signed-off-by: Dep Updater <noreply+dep-updater@tailscale.com>
A burst of PR pushes on 2026-11-13 left several GitHub-hosted test
shards sitting in "test all" for hours after their disks filled up,
holding hosted runner slots until GitHub's 6 hour job limit. Nothing
bounded them: go test's -timeout only limits a test binary while it
runs, not compiling and linking it, and test.yml set no job timeouts.
Give every test.yml job a timeout-minutes of roughly twice the slowest
successful run seen across ~1200 recent jobs.
In testwrapper, kill go test if it goes quiet for longer than any
single test binary may run (the go test -timeout plus a 5 minute
margin, overridable via TS_TESTWRAPPER_IDLE_MARGIN) and log the
process tree under testwrapper so the stuck process is visible.
Also bound the go list and listpkgs invocations and each retry
attempt, including its rebuild.
While here, fix testwrapper exiting 0 when go test was killed by a
signal (exit code -1) with no failed tests recorded.
Updates tailscale/corp#51500
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: I52bd41c247fca157d8e56381319fe80ae2f7cf02
Control via nodecap.LogUploadAuth may notify the node
that there is an authorization token to use when uploading logs.
If specified, then the logtail.Logger will use that token
when uploading.
Unfortunately, there is a time-of-use and time-of-check discrepancy
that complicates logging. When logs are written under the context
of being for a particular node, we cannot store the token,
as it may be invalid by the time that the logs are uploaded.
Instead, we add Logger.SetAuthID to annotate subsequent log entries
with an identifier for the token to later use.
Only when we upload do we strip out the auth ID, lookup the
auth token to use, and then perform the upload.
We assume that control will notify the client of new tokens
well before they expire. Fetching a refreshed token
is not the job of the client.
Updates tailscale/corp#39092
Signed-off-by: Joe Tsai <joetsai@digital-static.net>
The Windows installers no longer come in a separate -winui variant.
Remove the temporary qualifier.
Updates tailscale/corp#50987
Signed-off-by: Nick Khyl <nickk@tailscale.com>
run assigned keepAliveTimer after AfterFunc had already armed it, and
the timer's func uses the field (writePending resets it), so nothing
ordered the assignment before the first keepalive. Assign it first and
arm it with Reset, which does.
No existing test ran long enough for a keepalive to fire. The new
TestKeepAlive waits for three under synctest; with the race detector it
fails without this fix.
Updates #13038
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: I8f2c4e6a1b3d5f7091a2c3e4d5f6a7b8c9d0e1f2
onHomeDERPUpdateLocked wrote the netmap cache without checking the
CacheNetworkMaps capability, unlike the full netmap and peer delta
paths. On a node without it, each home DERP change recreated a cache
with no peers, and the next start went Running from it before control
sent any peers.
Check the capability before that write. A cache written before this
fix can still be loaded once; the first netmap from control without
the capability then discards it.
Fixes#22334
Change-Id: I2f49a6617e6756e36316605995b171f6d7b3ff28
Signed-off-by: Andy Tian <me@xiaotian.dev>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The filestore was the only implemented store but we want to be able to
add other stores depending on the platform.
Make space for compiling on more stores, though keep the file store as
the default option.
Updates #22265
Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This is needed for authenticated log uploads (see #20482).
Add a noop declaration now, so that we can call it from
client implementations on other platforms (e.g., Android or iOS).
Updates tailscale/corp#39092
Signed-off-by: Joe Tsai <joetsai@digital-static.net>
For kube-apiserver ProxyGroups with static endpoints, the operator sets
PORT on the k8s-proxy container to the targetPort of the NodePort
Services behind the advertised endpoints. k8s-proxy never read PORT, so
tsnet listened on a random port and traffic to the static endpoints was
forwarded to a port with nothing listening. Peers stayed on DERP.
This fixes this by parsing PORT and setting it as tsnet.Server.Port.
Thanks to @icheishvili (#18841) and @rquitales (#21716), whose changes
this is based on.
Updates #21714
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
policies
This adds support for reading string-list policies represented as
DWORD-backed registry subkeys. Each nonzero DWORD contributes its value
name to the resulting string list, allowing group policy settings to
expose predefined options as checkboxes instead of requiring users to
enter strings manually.
This also adds definitions for HiddenNetworkDevices.
Updates tailscale/corp#50029
Signed-off-by: kari <kari@tailscale.com>
PCP requests with an incorrect nonce are ignored by PCP servers
which follow the simple threat model defined in RFC 6887. Doing
it in natlab will ensure we detect client regressions.
Updates #21127
Change-Id: Ifefcda278800f642c161df90e76babeb089da5a3
Signed-off-by: Francois Marier <francois@tailscale.com>
This uses the same notification delivery logic for policy changes and regular ipn bus updates. Previously, sysPolicyChangedForSession silnetly dropped policy notifications when a watcher's channel was full, potentially leaving clients with stale policy and gui visibility state. Now lagging watchers follow the existing block, suspend, or close behavior, allowing them to recover the latest policy when they resume or reconnect.
Updates tailscale/corp#44104
Signed-off-by: kari-ts <kari@tailscale.com>
tailscale/wireguard-go#116 changed the receive loop to retry any errors
other than net.ErrClosed without a delay. magicsock entered a spin loop
if it encountered a UDP read error.
magicsock's receive funcs now return only net.ErrClosed when the socket
actually closes. Every other read error is counted, logged, and retried
after a short delay. IsUDPReadFeedback and IsUDPReadUnknown are removed
because they can be handled like any other error.
Retrying errors may hide failures which used to stop the receive func.
- There is a new metric magicsock_recv_udp_error which counts all read
errors.
- After 30s of continuous errors, the receive function marks itself as
broken. A warning is raised until a read succeeds.
Updates #22097
Change-Id: Ib9ade0ed001e413205eb7d452aa108aae574e0d1
Signed-off-by: Nick Beirne <nickb@tailscale.com>
Adds a test that issueACMECert, against tstest/acmetest, retries an
order naming "replaces" once without it when the CA rejects it, and
stores the cert from the retried order. It also checks that rate limits
and server errors are not retried, and that the error from the plain
order is returned if that is rejected too.
Updates #22042
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
When a previous cert exists, the renewal order names it in the ARI
"replaces" field. Let's Encrypt rejects that order if the current ACME
account did not issue the cert, which is the case once the account key
has been recreated but the cert kept (for example after
acme-account.key.pem is deleted), so renewal fails until the cert
expires or is deleted. This fixes this by retrying the order once
without "replaces" when the CA rejects it, unless it was rate limited.
The new cert belongs to the current account, so later renewals use
"replaces" again.
Fixes#22042
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
Adds a test that checks whoIs gets the identity from the request's remote
address, and returns an error instead of using the X-Forwarded-For header
when the remote address is not a tailnet node.
Updates tailscale/corp#51000
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
whoIs fell back to the X-Forwarded-For header when WhoIs on the request's
remote address failed (only when serving over plain HTTP, as cmd/k8s-proxy
does). That header comes from the client, so the identity could come from
the request instead of the connection. This fixes this by removing the
fallback, so whoIs only uses the connection's remote address. It also asks
for TCP only, as the proxy only serves TCP, so a miss does not also try UDP.
Updates tailscale/corp#51000
Thank you Emilio Mendoza @a3l6 for reporting
Signed-off-by: chaosinthecrd <tom@tmlabs.co.uk>
wgengine/magicsock: retire stale TSMP disco key after peer restart
When a nonzero control key replaces an old control key equal to the
active TSMP key, updateDiscoKey clears the TSMP-active flag and
subsequent sends use the new control key, while the retired TSMP
material stays stored. A zero control key falls back to the TSMP key as
active, and a different TSMP key that is already active stays preferred.
Each compare-and-swap attempt allocates a fresh disco snapshot before
choosing the active key.
Fixes#22201
Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
ParseDuration rewrites the digits before a d or w unit as hours, but only
looked at the digits after the decimal point, so 0.5d quietly returned
7m12s. Return an error for fractional day and week values instead.
Fixes#21552
Signed-off-by: Aniket <aniketkomailkro@gmail.com>
Lets an embedder pick the dialer for non-tailnet connections, such
as to control. When control runs in the same process, the node can
then reach it in memory (e.g. memnet) instead of via loopback.
Updates tailscale/corp#27636
Signed-off-by: Kristoffer Dalby <kristoffer@dalby.cc>
Prepare for shared socket policy for DERP, control, and log uploads.
Callers need to configure options such as TCP user timeout on the same
socket that netns configures to avoid routing loops.
Use ControlContext for dialer namespace setup and run any caller-supplied
ControlContext afterward, only if namespace setup succeeds. Reject a
non-nil Control unconditionally with a panic directing callers to
ControlContext, including when netns is disabled, rather than support
both hook types and their precedence rules. Listener Control hooks
remain unchanged.
Existing in-tree FromDialer callers supply neither hook, so no caller
migration is required. Keep socket defaults and proxy-wrapping behavior
unchanged. Test hook ordering, context and argument forwarding, errors,
legacy-hook rejection, disabled mode, and proxy delegation.
Updates tailscale/corp#50948
Change-Id: I9d778273f3257fe8a298463ef29ec2dd5d5fb7b0
Signed-off-by: James Tucker <james@tailscale.com>
The eventbus routes events by exact type, so a subscriber of *T never
sees a T. Add a test that type-checks the module for linux, windows and
darwin and fails if any event type is used with eventbus or
eventbustest both by value and by pointer. To keep memory use down, it
drops function bodies outside the packages that import those. It skips
in race builds because of a go/types data race, golang/go#81122.
Updates #22307
Change-Id: Ia7486c43936f367f8767ad9c8750faa9b6bdf8f0
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Both tests passed filter funcs taking a pointer to an event type that
is published by value, so the filters never matched. The health test
passed only because Expect timed out, so make it look for the event it
means to forbid.
Updates #22307
Change-Id: I7daf64656cd9b0e9e98372cd803a6e824db96594
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Count DERP keepalive and ping/pong traffic, terminal read-deadline
expirations, and control map-request watchdog expirations. Count
successful pre-compression log upload bytes alongside existing upload
totals to support batch-size comparisons.
Keep timeout attribution narrow: expirations do not imply a successful
reconnect, and completed writes do not imply peer receipt. Log upload
metrics remain on the existing per-logger ExpVar surface.
Add deterministic coverage without changing heartbeat timing, socket
settings, reconnect behavior, or upload policy.
Updates tailscale/corp#50948
Change-Id: I95f7bab62c000172a4825283bb4c055dd29d8043
Signed-off-by: James Tucker <james@tailscale.com>
Use ControlContext for production net.Dialer socket hooks:
PeerAPI and debug peer dialing, captive-portal probes, stunstamp TCP
measurements, and the test agent connection.
Update the PeerDialControlFunc callback signature and Apple extension
implementation together with both consumers. Preserve namespace binding,
socket settings, timeout values, and existing error handling. Listener
Control and RawConn.Control are separate APIs and remain unchanged.
Add coverage for platform hook forwarding and errors, debug and captive
portal dialing, cancellation, SO_REUSEADDR, and test-agent hook selection
and keepalive configuration. Cover the Apple missing-interface error and
non-Linux bypass no-op in their platform-specific tests.
Updates tailscale/corp#50948
Change-Id: I4fb162666724f307f2d3d0beba6ed1b0ed15bb4f
Signed-off-by: James Tucker <james@tailscale.com>
https://github.com/tailscale/wireguard-go/compare/79ead109a81a8f57c75ac9e6ddee61714c82744b...9e10ef9af41578baabde0283237d5cbb6422ff25
Start off with device.WithQueueStagedGlobalLimit inheriting the same
value from the knob it replaced, device.WithPreallocatedBuffersPerPool.
Unlike WithPreallocatedBuffersPerPool, WithQueueStagedGlobalLimit is
exclusive of packet memory allocated for transport messages that are
immediately transmitted. So, one must consider
WithQueueStagedGlobalLimit alongside .Queue{In,Out}boundSize to
understand overall memory ceiling impacts.
An approximation of the configured packet memory ceiling on iOS can be
calculated with the following formula:
device.singlePacketSlabSize * ( // 1788
(2 * device.WithQueueOutboundSize) + // 128
(2 * device.WithQueueInboundSize) + // 128
device.WithQueueStagedGlobalLimit // 64
)
=
~572KB
Where previously it was:
device.singlePacketSlabSize * ( // 1788
device.WithPreallocatedBuffersPerPool // 64
)
=
~114KB
Updates tailscale/tailscale#1971
Updates tailscale/tailscale#21773
Updates tailscale/corp#46396
Signed-off-by: Jordan Whited <jordan@tailscale.com>