1726 Commits

Author SHA1 Message Date
KevinLiang10
97f629c1b5 cmd/tailscale/cli: change parameter of IsTCPForwardingOnPort
This commit changes the dnsName string parameter for IsTCPForwardingOnPort to
svcName tailcfg.ServiceName. This change is made to reduce ambiguity when
a single service might have different dnsNames

Signed-off-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
2025-06-27 17:58:44 -04:00
KevinLiang10
71fe9a9860 cmd/tailscale/cli: adjust parameter order and update output message
This commit updates the parameter order for IsTCPForwardingOnPort and SetWebHandler.
Also updated the message msgServiceIPNotAssigned to msgServiceWaitingApproval to adapt to
latest terminologies around services.

Signed-off-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
2025-06-26 17:13:41 -04:00
KevinLiang10
d40755be85 replace all assemble of host name for service with strings.Join
Signed-off-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
2025-06-26 17:13:41 -04:00
KevinLiang10
8d861680d2 replace IsServiceName with tailcfg.AsServiceName
Signed-off-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
2025-06-26 17:13:41 -04:00
KevinLiang10
ec35e6c1d8 some code simplification and add asServiceName
This commit cotains code simplification for IsServingHTTPS, SetWebHandler, SetTCPForwarding

Signed-off-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
2025-06-26 17:13:41 -04:00
KevinLiang10
59c86c90cd replace FindServiceConfig with map lookup
Signed-off-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
2025-06-26 17:13:41 -04:00
KevinLiang10
b8f2e27675 cmd/tailscale/cli: Add service flag to serve command
This commit adds the service flag to serve command which allows serving a service and add the service
to the advertisedServices field in prefs (What advertise command does that will be removed later).

When adding proxies, TCP proxies and WEB proxies work the same way as normal serve, just under a
different DNSname. There is a services specific L3 serving mode called Tun, can be set via --tun flag.
Serving a service is always in --bg mode. If --bg is explicitly set t o false, an error message will
be sent out. The restriction on proxy target being localhost or 127.0.0.1 also applies to services.

When removing proxies, TCP proxies can be removed with type and port flag and off argument. Web proxies
can be removed with type, port, setPath flag and off argument. To align with normal serve, when setPath
is not set, all handler under the hostport will be removed. When flags are not set but off argument was
passed by user, it will be a noop. Removing all config for a service will be available later with a new
subcommand clear.

Updates tailscale/corp#22954

Signed-off-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
2025-06-26 17:13:40 -04:00
JerryYan
99aaa6e92c
ipn/ipnlocal: update PeerByID to return SelfNode and rename it to NodeByID (#16096)
Like NodeByKey, add an if stmt for checking the NodeId is SelfNode.

Updates #16052

Signed-off-by: Jerry Yan <792602257@qq.com>
2025-06-26 11:43:48 -05:00
Nick Khyl
9e28bfc69c ipn/ipnlocal,wgengine/magicsock: wait for magicsock to process pending events on authReconfig
Updates #16369

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2025-06-24 16:39:08 -05:00
Andrew Lytvynov
4979ce7a94
feature/tpm: implement ipn.StateStore using TPM sealing (#16030)
Updates #15830

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
2025-06-18 14:17:12 -07:00
Jordan Whited
fcab50b276
ipn/ipnlocal,wgengine{/magicsock}: replace SetNetworkMap with eventbus (#16299)
Same with UpdateNetmapDelta.

Updates tailscale/corp#27502
Updates #15160

Signed-off-by: Jordan Whited <jordan@tailscale.com>
2025-06-18 10:31:00 -07:00
Anton Tolchanov
a91fcc8813 ipn/ipnlocal: make pricing restriction message for Tailnet Lock clearer
Fixes tailscale/corp#24417

Signed-off-by: Anton Tolchanov <anton@tailscale.com>
2025-06-18 15:01:37 +01:00
Juan Francisco Cantero Hurtado
cbc14bd3b0 ipn: add missing entries for OpenBSD
Signed-off-by: Juan Francisco Cantero Hurtado <jfch@30041993.xyz>
2025-06-17 17:53:22 -07:00
Percy Wegmann
4431fb89c2 ipn/ipnlocal: add some verbose logging to taildrive peerapi handler
Updates tailscale/corp#29702

Signed-off-by: Percy Wegmann <percy@tailscale.com>
2025-06-17 17:01:36 -05:00
Brad Fitzpatrick
259bab9bff scripts/check_license_headers.sh: delete, rewrite as a Go test
Updates tailscale/corp#29650

Change-Id: Iad4e4ccd9d68ebb1d1a12f335cc5295d0bd05b60
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-06-16 13:35:38 -07:00
Jordan Whited
8e6f63cf11
ipn/ipnlocal,wgengine/magicsock: use eventbus for node & filter updates (#16271)
nodeBackend now publishes filter and node changes to eventbus topics
that are consumed by magicsock.Conn

Updates tailscale/corp#27502
Updates tailscale/corp#29543

Signed-off-by: Jordan Whited <jordan@tailscale.com>
2025-06-16 08:42:09 -07:00
Nick Khyl
733bfaeffe ipn/ipnlocal: signal nodeBackend readiness and shutdown
We update LocalBackend to shut down the current nodeBackend
when switching to a different node, and to mark the new node's
nodeBackend as ready when the switch completes.

Updates tailscale/corp#28014
Updates tailscale/corp#29543
Updates #12614

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2025-06-13 17:58:21 -05:00
Nick Khyl
6a4d92ecef ipn/ipnlocal: replace nodeContext with nodeBackend in comments
We renamed the type in #15866 but didn't update the comments at the time.

Updates #cleanup

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2025-06-13 14:53:08 -05:00
Claus Lensbøl
6010812f0c
ipn/localapi,client/local: add debug watcher for bus events (#16239)
Updates: #15160

Signed-off-by: Claus Lensbøl <claus@tailscale.com>
2025-06-11 14:22:30 -04:00
Anton Tolchanov
db34cdcfe7 cmd/tailscale/cli: add a risk message about rp_filter
We already present a health warning about this, but it is easy to miss
on a server when blackholing traffic makes it unreachable.

In addition to a health warning, present a risk message when exit node
is enabled.

Example:

```
$ tailscale up --exit-node=lizard
The following issues on your machine will likely make usage of exit nodes impossible:
- interface "ens4" has strict reverse-path filtering enabled
- interface "tailscale0" has strict reverse-path filtering enabled
Please set rp_filter=2 instead of rp_filter=1; see https://github.com/tailscale/tailscale/issues/3310
To skip this warning, use --accept-risk=linux-strict-rp-filter
$
```

Updates #3310

Signed-off-by: Anton Tolchanov <anton@tailscale.com>
2025-06-10 07:38:06 +01:00
James Sanderson
5716d0977d health: prefix Warnables received from the control plane
Updates tailscale/corp#27759

Signed-off-by: James Sanderson <jsanderson@tailscale.com>
2025-06-09 10:35:22 +01:00
KevinLiang10
7b06532ea1
ipn/ipnlocal: Update hostinfo to control on service config change (#16146)
This commit fixes the bug that c2n requests are skiped when updating vipServices in serveConfig. This then resulted
netmap update being skipped which caused inaccuracy of Capmap info on client side. After this fix, client always
inform control about it's vipServices config changes.

Fixes tailscale/corp#29219

Signed-off-by: KevinLiang10 <37811973+KevinLiang10@users.noreply.github.com>
2025-06-06 15:20:23 -04:00
James Sanderson
5fde183754 ipn: add watch opt to include actions in health messages
Updates tailscale/corp#27759

Signed-off-by: James Sanderson <jsanderson@tailscale.com>
2025-06-04 11:01:02 +01:00
James Sanderson
8a3afa5963 ipn/ipnlocal: fix deadlock when filtering DisplayMessage URLs
Updates tailscale/corp#27759

Signed-off-by: James Sanderson <jsanderson@tailscale.com>
2025-06-03 11:09:38 +01:00
James Sanderson
11e83f9da5 controlclient,health,ipnlocal,tailcfg: add DisplayMessage support
Updates tailscale/corp#27759

Signed-off-by: James Sanderson <jsanderson@tailscale.com>
2025-05-30 14:48:11 +01:00
Nick Khyl
4cccd15eeb ipn/ipnlocal: fix data race when accessing b.appConnector
The field must only be accessed while holding LocalBackend's mutex,
but there are two places where it's accessed without the mutex:
 - (LocalBackend).MaybeClearAppConnector()
 - handleC2NAppConnectorDomainRoutesGet()

Fixes #16123

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2025-05-29 14:07:03 -05:00
Jonathan Nobels
842df37803
ipn: set RouteAll=true by default for new accounts on iOS and Android (#16110)
fixes tailscale/tailscale#16082

RouteAll should be true by default on iOS and Android.

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
2025-05-28 10:08:06 -04:00
Zach Buchheit
4a11514db5
ipn/ipnlocal: improve dohQuery error to suggest ?dns= and ?q= (#16056)
Previously, a missing or invalid `dns` parameter on GET `/dns-query`
returned only “missing ‘dns’ parameter”. Now the error message guides
users to use `?dns=` or `?q=`.

Updates: #16055

Signed-off-by: Zach Buchheit <zachb@tailscale.com>
2025-05-23 14:17:28 -07:00
James 'zofrex' Sanderson
aa8bc23c49
control/controlclient,health,tailcfg: refactor control health messages (#15839)
* 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-05-22 13:40:32 +01:00
Andrew Lytvynov
0bab16448e
ipn/store: remove a layer of indirection for registering stores (#15986)
Registering a new store is cheap, it just adds a map entry. No need to
lazy-init it with sync.Once and an intermediate slice holding init
functions.

Updates #cleanup

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
2025-05-21 08:47:23 -07:00
Brad Fitzpatrick
30a89ad378 ipn/ipnlocal: make GetExt work earlier, before extension init
Taildrop wasn't working on iOS since #15971 because GetExt didn't work
until after init, but that PR moved Init until after Start.

This makes GetExt work before LocalBackend.Start (ExtensionHost.Init).

Updates #15812

Change-Id: I6e87257cd97a20f86083a746d39df223e5b6791b
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-05-19 15:36:25 -07:00
Nick Khyl
824985afe1 feature/taildrop,ipn/ipn{ext,local}: initialize taildrop for initial profile
Currently, LocalBackend/ExtensionHost doesn't invoke the profile change callback for the initial profile.
Since the initial profile may vary depending on loaded extensions and applied policy settings,
it can't be reliably determined until all extensions are initialized. Additionally, some extensions
may asynchronously trigger a switch to the "best" profile (based on system state and policy settings) during
initialization.

We intended to address these issues as part of the ongoing profileManager/LocalBackend refactoring,
but the changes didn't land in time for the v1.84 release and the Taildrop refactoring.

In this PR, we update the Taildrop extension to retrieve the current profile at initialization time
and handle it as a profile change.

We also defer extension initialization until LocalBackend has started, since the Taildrop extension
already relies on this behavior (e.g., it requires clients to call SetDirectFileRoot before Init).

Fixes #15970
Updates #15812
Updates tailscale/corp#28449

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2025-05-14 17:58:16 -05:00
Anton Tolchanov
65e005ccaa ipn/ipnlocal: attach Tailnet Lock status to bugreports
Fixes tailscale/corp#28524

Signed-off-by: Anton Tolchanov <anton@tailscale.com>
2025-05-13 11:34:43 +01:00
Nick Khyl
ffb1dda245 ipn/ipnlocal,wgengine: move (*tsdial.Dialer).SetRoutes() calls from LocalBackend to userspaceEngine
This avoids reconfiguring the dialer unless the router config has changed.

Updates #12027

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2025-05-12 20:51:08 -05:00
Nick Khyl
565ebbdeb8 ipn/ipnlocal: move nodeBackend methods from local.go to node_backend.go
We previously kept these methods in local.go when we started moving node-specific state
from LocalBackend to nodeBackend, to make those changes easier to review. But it's time
to move them to node_backend.go.

Updates #cleanup
Updates #12614

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2025-05-09 18:17:36 -05:00
Nick Khyl
f0a27066c4 ipn/ipn{server,test}: extract the LocalAPI test client and server into ipntest
In this PR, we extract the in-process LocalAPI client/server implementation from ipn/ipnserver/server_test.go
into a new ipntest package to be used in high‑level black‑box tests, such as those for the tailscale CLI.

Updates #15575

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2025-05-09 18:12:54 -05:00
Nick Khyl
a9be049c19 ipn/ipnlocal,net/dns/resolver: use the user dialer and routes for DNS forwarding by default, except on iOS and Android
In this PR, we make the "user-dial-routes" behavior default on all platforms except for iOS and Android.
It can be disabled by setting the TS_DNS_FORWARD_USE_ROUTES envknob to 0 or false.

Updates #12027
Updates #13837

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2025-05-09 16:43:01 -05:00
Jonathan Nobels
7d6d2b4c50
health, ipn/ipnlocal: add metrics for various client events (#15828)
updates tailscale/corp#28092

Adds metrics for various client events:
* Enabling an exit node
* Enabling a mullvad exit node
* Enabling a preferred exit node
* Setting WantRunning to true/false
* Requesting a bug report ID
* Profile counts
* Profile deletions
* Captive portal detection

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
2025-05-09 12:03:22 -04:00
Brad Fitzpatrick
165b99278b feature/taildrop, ipn/ipnlocal: remove leftover dup calls to osshare
I'd moved the osshare calls to feature/taildrop hooks, but forgot to
remove them from ipnlocal, or lost them during a rebase.

But then I noticed cmd/tailscaled also had some, so turn those into a
hook.

Updates #12614

Change-Id: I024fb1d27fbcc49c013158882ee5982c2737037d
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-05-08 10:08:27 -07:00
James Sanderson
85a7abef0c tsnet: add test for packet filter generation from netmap
This is an integration test that covers all the code in Direct, Auto, and
LocalBackend that processes NetMaps and creates a Filter. The test uses
tsnet as a convenient proxy for setting up all the client pieces correctly,
but is not actually a test specific to tsnet.

Updates tailscale/corp#20514

Signed-off-by: James Sanderson <jsanderson@tailscale.com>
2025-05-08 17:18:30 +01:00
Brad Fitzpatrick
5be6ff9b62 all: remove non-applicable "linux" deps on Android
Updates #12614

Change-Id: I0e2a18eca3515d3d6206c059110556d2bbbb0c5c
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-05-07 21:05:13 -07:00
Brad Fitzpatrick
fd263adc1b ipn/store: don't link in AWS & Kubernetes stuff on Android
Android is Linux, but that not much Linux.

Updates #12614

Change-Id: Ice80bd3e3d173511c30d05a43d25a31e18928db7
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-05-07 10:38:47 -07:00
Brad Fitzpatrick
068d5ab655 feature/taildrop: move rest of Taildrop out of LocalBackend
Updates #12614

Change-Id: If451dec1d796f6a4216fe485975c87f0c62a53e5
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Co-authored-by: Nick Khyl <nickk@tailscale.com>
2025-05-06 20:41:27 -07:00
Brad Fitzpatrick
cf6a593196 cmd/tailscale/cli: rename "--posture-checking" to "--report-posture"
For consistency with other flags, per Slack chat.

Updates #5902

Change-Id: I7ae1e4c97b37185573926f5fafda82cf8b46f071
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-05-06 07:44:57 -07:00
Brad Fitzpatrick
597d0e8fd5 ipn/ipnlocal, tailcfg: add MagicDNS opt-in attr for IPv6 AAAA records
Until we turn on AAAA by default (which might make some people rely on
Happy Eyeballs for targets without IPv6), this lets people turn it on
explicitly if they want.

We still should add a peer cap as well in the future to let a peer
explicitly say that it's cool with IPv6.

Related: #9574

Updates #1813
Updates #1152

Change-Id: Iec6ec9b4b5db7a4dc700ecdf4a11146cc5303989
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-05-05 10:14:03 -07:00
Brad Fitzpatrick
32ce1bdb48 ipn/ipnlocal: use "nb" consistently as receiver for nodeBackend
Cleanup after #15866. It was using a mix of "b" and "c" before. But "b"
is ambiguous with LocalBackend's usual "b".

Updates #12614

Change-Id: I8c2e84597555ec3db0d783a00ac1c12549ce6706
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-05-02 17:44:40 -07:00
Brad Fitzpatrick
653c45585e ipn/ipnlocal: rename localNodeContext to nodeBackend
As just discussed on Slack with @nickkhyl.

Updates #12614

Change-Id: I138dd7eaffb274494297567375d969b4122f3f50
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-05-02 17:30:46 -07:00
Brad Fitzpatrick
a0d7c81a27 ipn/ipnlocal: fix Taildrop regression from refactoring
This fixes a refactoring bug introduced in 8b72dd7873201

Tests (that failed on this) are coming in a separate change.

Updates #15812

Change-Id: Ibbf461b4eaefe22ad3005fc243d0a918e8af8981
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-05-01 10:34:10 -07:00
Brad Fitzpatrick
c09cd34f59 ipn/ipnlocal: fix Taildrop deadlock
This fixes the Taildrop deadlock from 8b72dd787320.

Fixes #15824

Change-Id: I5ca583de20dd0d0b513ce546439dc632408ca1f1
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-04-30 21:21:37 -07:00
Nick Khyl
66371f392a feature,ipn/ipnlocal: add profileManager.StateChangeHook
We update profileManager to allow registering a single state (profile+prefs) change hook.
This is to invert the dependency between the profileManager and the LocalBackend, so that
instead of LocalBackend asking profileManager for the state, we can have profileManager
call LocalBackend when the state changes.

We also update feature.Hook with a new (*feature.Hook).GetOk method to avoid calling both
IsSet and Get.

Updates tailscale/corp#28014
Updates #12614

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2025-04-25 16:32:09 -05:00