Commit Graph
227 Commits
Author SHA1 Message Date
Kristoffer Dalby dacdfd8aaa change: do not echo a node's own report back to it
An endpoint or DERP report came back to the node as a self update;
SaaS sends it to the node's peers only.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby efe89581dc mapper: add device_id to the NextDNS query
SaaS sends the node's stable ID with the other device metadata.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby 917c6968f1 policy/v2: warn once at load about malformed nextdns attrs
SaaS loads them and its resolver skips them, as headscale does, but the
mapper also logged a warning per node on every DNS build.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby 50c4ed8f67 mapper: test that a hidden peer's policy change still sends filters 2026-10-28 18:28:22 +00:00
Kristoffer Dalby 24e3a8d526 state, change: send a deleted node's removal only to its peers
The removal went to every node, also those the policy hid the node from.
The delete now returns the node's peers from the snapshot it replaces.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby 4b0f458e11 mapper: stop an older initial map removing peers newer streams hold
AddNode diffed its map against tracking after sending it, when a newer
stream may have recorded its own; it now sends the node a full instead.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby cb9af8a5e6 mapper: bound how long one node can block a batcher worker
A node that drained slower than it was sent to held the worker for its
whole bundle; once its sends have waited 50ms, the rest waits a tick.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby ee3a5600c7 mapper: send nothing while any stream awaits its initial map
Sent to the ready streams alone, a change counted as delivered and
never reached the new stream; the worker retries it once the map is out.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby 568d14afc0 mapper: cap concurrent map sessions per node
A node chose how many map streams it held, each pinning a session.
The fifth replaces the oldest; same shape as #3468's mapper commit.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby 179af840da change: coalesce policy recomputes that carry an origin node
The recompute render ignores the origin and always carries the node's
own entry, so a burst of tag writes cost every node one per write.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby e785afd35a mapper: show an expired peer online, without endpoints or DERP
A connected expired node shows online to its peers. Neither its map
entry nor endpoint, DERP or disco patches carry the paths to reach it.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby 82d2090511 mapper: trim the Hostinfo sent to peers and to the node itself
As on Tailscale SaaS, the node's own entry keeps Hostname, RequestTags,
RoutableIPs and Services; peers get Hostname, OS, Services without
peerapi-dns-proxy, SSH host keys and AppConnector, and resend on those.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby fd70994523 mapper: keep an expired node authorised in its own entry
Tailscale SaaS sends an expired node MachineAuthorized and no Expired
flag; its past KeyExpiry already moves the client to NeedsLogin.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby 7f9bc1ef30 mapper: send a router all of its own routes
Its AllowedIPs held only the primaries the policy let it reach. It now
holds every approved route, and PrimaryRoutes the ones it serves.
2026-10-28 18:28:22 +00:00
Kristoffer Dalby 84f1404ea9 mapper: count only the batcher's goroutines in lifecycle tests
runtime.NumGoroutine deltas moved when goroutines left by earlier
tests exited mid-test. Label the batcher's goroutines and count those.
2026-10-28 18:27:54 +00:00
Kristoffer Dalby eb188b7686 policy/v2, mapper: add nextdns attr captures
SaaS accepts malformed nextdns profiles and keeps them in the CapMap;
its resolver skips them. DoH addresses compare per node: path, query,
ID.
2026-10-28 14:29:30 +00:00
Kristoffer Dalby 159deeec41 mapper: skip peers whose key expiry cannot be encoded
json.Marshal refuses a year outside [0,9999], so one stored expiry
failed every map with that node. TailNode and key patches send UTC, the
builder drops what fails and the boot scan names the node.

Fixes ANT-2026-QMCAFJ1Q
2026-10-28 14:25:41 +00:00
Kristoffer Dalby eed5c8c80a mapper: count folded patches when bounding pending
A fold keeps every patch it merges, so counting changes hid the
backlog: the cap never fired and each fold recopied the patches.
2026-10-23 18:23:53 +02:00
Kristoffer Dalby daad12e964 mapper: retry slow sessions from current state
A full session channel after the send window evicted live but busy clients.
Requeue and regenerate; evict after no progress for connectionStallTimeout.
Retire blocked reconnect siblings once the newest stream accepts the frame.

Updates #3129.
2026-10-23 18:23:53 +02:00
Kristoffer Dalby f46ea3d1df mapper: skip responses left empty by visibility filtering
A peer change hidden from a recipient still produced a frame carrying only
ControlTime, one per sender per recipient. Drop it once the response is final.
2026-10-23 18:23:53 +02:00
Kristoffer Dalby 2047ef35b8 hscontrol: wait for map session cleanup during shutdown
Batcher shutdown cuts reconnect grace short to keep shutdown prompt.
Wait for each session's Disconnect to persist LastSeen before the database closes.
2026-10-23 18:23:53 +02:00
Kristoffer Dalby 8a7921ae45 mapper: fold a node's pending backlog while its bundle is in flight
Behind workers, pending grew by every change until the next drain; under
ci-churn that held ~900 MB of queued changes.
2026-10-23 18:23:53 +02:00
Kristoffer Dalby 7a2335dc2b mapper: render each tick's peer deltas as one response
One frame per change let a join storm overflow the session channel in a
single tick, and the batcher then dropped live clients as stale.
2026-10-23 18:23:53 +02:00
Kristoffer Dalby fb015933ca mapper: drop pending changes for nodes without a connection
Disconnected nodes keep their batcher entry, and every broadcast was
rendered for them only for send to discard it.
2026-10-23 18:23:53 +02:00
Kristoffer Dalby 7414c276f6 mapper: limit capability copies to requested peers
Small peer updates should not copy capabilities for the entire tailnet.
2026-10-22 22:17:36 +02:00
Kristoffer Dalby 6489054805 mapper: enqueue broadcasts without refiltering recipients
Broadcast recipients already share the same changes.
2026-10-22 22:17:36 +02:00
Kristoffer Dalby 068711518f mapper: store user views directly in profile maps
Avoid allocating an owner pointer for every peer during profile generation.
2026-10-22 22:17:36 +02:00
Kristoffer Dalby 79ae38f0af mapper: stop shadowing predeclared cap
golangci-lint 2.15 predeclared check flags it.
2026-10-22 14:37:00 +02:00
Kristoffer Dalby eef0d1fe47 dns: add acme-dns provider
_acme-challenge is CNAMEd once to an acme-dns registration, so headscale
needs no DNS credentials. Node certificates need one registration per
name; CNAME chains are followed and writes never evict a live value.

Updates #2137
2026-10-18 20:53:18 +02:00
Kristoffer Dalby 3f6e54cbd5 mapper: send CertDomains and https cap when certificates are enabled
Both gate tailscale cert and serve HTTPS on the client; httpsEnabled
follows, as in Tailscale. No certificate when an operator extra record
sits at or below the name: a wildcard would cover it.

Updates #2137
Updates #1921
2026-10-18 20:53:18 +02:00
Kristoffer Dalby 4fd4da75f2 hscontrol: fix formatting after combining SSH policy changes
Updates #3517
2026-10-08 10:29:23 +02:00
Kristoffer Dalby 785ba22c65 mapper: send SSHPolicy only when it changes for the connection
Any non-nil SSHPolicy forces a full client netmap rebuild; the empty
policy now sent to every node made each policy change one.

Updates #3508
2026-10-08 10:29:23 +02:00
Kristoffer Dalby d7b333d2aa mapper: send an empty SSH policy when compiling it fails
Fail closed; nil kept the client's previous rules.

Updates #3508
2026-10-08 10:29:23 +02:00
Kristoffer Dalby 48046dc9c5 mapper: allow unchanged self in the full-update ping test
Updates #3518
2026-10-07 23:36:16 +02:00
Kristoffer Dalby ea6b0bf0b7 mapper: reconcile self on policy recomputes
Self renders from the same state as peers, so leaving it out of policy
responses hid an exit node's approved routes until it reconnected.

Fixes #3502
2026-10-07 23:36:16 +02:00
Kristoffer Dalby 52a7f8c89c mapper: send the logtail instruction on every full map
Full maps moved to buildFromChange and lost WithDebugConfig, so no
frame told clients to disable log upload. Enabled logtail sends nil.
2026-10-07 18:11:07 +02:00
Kristoffer Dalby d4948da301 mapper: keep pings when a full update collapses pending changes
A full renders state at drain time but cannot carry a one-shot
PingRequest; queue each ping as a ping-only frame after the full.
2026-10-07 15:25:25 +02:00
Kristoffer Dalby b4d5cdd6aa mapper: keep reconnect removals tracked until delivered
AddNode reset lastSentPeers before the queued removal went out, so a
superseding full or a disconnect before the tick lost it for good.
2026-10-07 11:09:47 +02:00
Kristoffer Dalby eeaac680be mapper: drop DNSConfig from policy responses
It forced every client into a full netmap rebuild; the resolver race it
guarded against was a client bug (tailscale/tailscale#19749).
2026-09-30 19:03:13 +02:00
Kristoffer Dalby 60d42808b8 state: keep node removal apart from policy refresh in DeleteNode
Peers get the deletion as an explicit PeersRemoved change, independent of
their sent-peers tracking.

Updates tailscale/tailscale#15660
2026-09-30 19:03:13 +02:00
Kristoffer Dalby 1bd62737b9 mapper: send removed peers as their own delta
Removals derived from a policy change, full update or reconnect rode a
response whose DNSConfig, SSHPolicy, Node or Peers force a full rebuild.

Updates tailscale/tailscale#15660
2026-09-30 19:03:13 +02:00
Kristoffer Dalby 21f6e46fb8 state: refresh policy nodes inside the peer map build
One peer build per tag/user/IP/route write; callers detect policy moves
via NodesGeneration. Per-node caches only store results for the node
pm holds, so a mapper reading mid-build cannot pin a stale filter.
2026-09-30 17:21:02 +02:00
Kristoffer Dalby 393dd3e2d9 db: store all credentials in one SHA-256-hashed table
API keys, pre-auth keys and OAuth clients/tokens share one table and verify
path. Secrets carry 256 bits of crypto/rand entropy, so a SHA-256 digest
needs no stretching; bcrypt/argon2id rows rehash on use until 0.32.
2026-09-26 00:33:12 +02:00
Kristoffer Dalby 06fa3075da hscontrol: replace tailscale line refs with doc links
Line numbers drift on every upstream bump.
2026-09-23 14:48:45 +02:00
Kristoffer Dalby e48bc46cc6 mapper: take peer visibility from the peer map only
Fixes #3408
2026-09-23 14:48:35 +02:00
Kristoffer Dalby 4c6a2dff52 state: resolve changed peers through adjacency
ListPeers now filters named peers against the recipient's adjacency, so
a node the policy hides is never delivered.

Updates #3417
2026-09-10 13:06:13 +02:00
Kristoffer Dalby 286f1d5a12 mapper: drop empty changes before fan-out
An empty change carries no work for any recipient, so it never becomes
a pending entry. Adds headscale_mapper_changes_dropped_total.

Updates #3417
2026-09-10 13:06:13 +02:00
Kristoffer Dalby 8995d8a558 mapper: assert no map response lists the recipient as its own peer
Covers every change shape under four policy shapes, plus connect churn. The
zero-matcher shape is the gap: buildTailPeers skips ReduceNodes there, so the
peer lookup is the only self filter left.
2026-09-09 18:18:53 +02:00
Kristoffer Dalby a91c0519c2 change, mapper: distinguish deleted nodes
Updates #3410
2026-09-09 18:18:17 +02:00
Kristoffer Dalby 0b69e844f5 mapper: stop a deleted node's map session
Dropping the batcher entry left serveLongPoll streaming to a node that no
longer exists: Close ranges b.nodes and can no longer reach it, so shutdown
blocks and the client keeps polling instead of re-authenticating.

Updates #3410
2026-09-09 18:18:17 +02:00