Skip to content

feat(ci): bump to upstream 1.72 #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 140 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
4ff276c
VERSION.txt: this is v1.71.0
dblohm7 Jul 17, 2024
1ac14d7
Dockerfile: remove warning (#12841)
clstokes Jul 17, 2024
0b32adf
hostinfo: set Hostinfo.PackageType for mkctr container builds
bradfitz Jul 17, 2024
f77821f
derp/derphttp: determine whether a region connect was to non-ideal node
bradfitz Jul 7, 2024
d97cddd
tsweb: swallow panics
icio Jul 16, 2024
d3af544
client/tailscale: document ACLTestFailureSummary.User field
bradfitz Jul 18, 2024
1608831
wgengine/router: use quad-100 as the nexthop on Windows
nickkhyl Jul 17, 2024
4850186
{tool,client}: bump node version (#12840)
mpminardi Jul 18, 2024
54f58d1
ipn/ipnlocal: add comment explaining auto exit node migration
sailorfrag Jul 15, 2024
b2c522c
tsweb: log cancelled requests as 499
icio Jul 19, 2024
0f57b93
cmd/k8s-operator,tstest,go.{mod,sum}: remove fybrik.io/crdoc dependen…
irbekrm Jul 19, 2024
32ce187
Add extra environment variables in deployment template (#12858)
jaxxstorm Jul 19, 2024
e7bf6e7
cmd/tailscale: add --min-validity flag to the cert command (#12822)
awly Jul 19, 2024
20562a4
cmd/viewer, types/views, util/codegen: add viewer support for custom …
nickkhyl Jul 14, 2024
bd54b61
types/opt: add (Value[T]).GetOr(def T) T method
nickkhyl Jul 19, 2024
1f94047
go.mod.sri: update SRI hash for go.mod changes
Jul 21, 2024
d500a92
util/slicesx: add HasPrefix, HasSuffix, CutPrefix, and CutSuffix func…
nickkhyl Jul 22, 2024
5d09649
types/lazy: add (*SyncValue[T]).SetForTest method
nickkhyl Jul 19, 2024
9904421
licenses: update license notices
Jul 22, 2024
57856fc
ipn,wgengine/magicsock: allow setting static node endpoints via tails…
irbekrm Jul 23, 2024
ba7f2d1
tsweb: log all cancellations as 499s (#12894)
icio Jul 24, 2024
43375c6
types/lazy: re-init SyncValue during test cleanup if it wasn't set be…
nickkhyl Jul 24, 2024
855da47
tsweb: Add MiddlewareStack func to apply lists of Middleware (#12907)
icio Jul 25, 2024
cf97cff
wgengine/netstack: simplify netaddrIPFromNetstackIP
bradfitz Jul 26, 2024
90be06b
health: introduce captive-portal-detected Warnable (#12707)
agottardo Jul 26, 2024
6840f47
net/dnsfallback: set CanPort80 in static DERPMap (#12929)
agottardo Jul 26, 2024
1bf82dd
util/osuser: run getent on non-Linux Unixes
overhacked Jul 7, 2024
c5623e0
go.{mod,sum},tstest/tools,k8s-operator,cmd/k8s-operator: autogenerate…
irbekrm Jul 29, 2024
1bf7ed0
tsweb: add QuietLogging option (#12838)
icio Jul 29, 2024
a21bf10
cmd/k8s-operator,k8s-operator/sessionrecording,sessionrecording,ssh/t…
irbekrm Jul 29, 2024
3088c61
go.mod: pull in latest github.com/tailscale/xnet
oxtoacart Jul 29, 2024
19b0c8a
net/dns, health: raise health warning for failing forwarded DNS queri…
barnstar Jul 29, 2024
35a8fca
cmd/tailscale/cli: release portmap after netcheck
andrew-d Jul 29, 2024
360046e
words: add some associated with scales
bradfitz Jul 29, 2024
2ab1d53
gokrazy/tsapp: add go.mod replacing two tailscale.com binaries with p…
bradfitz Jul 30, 2024
575feb4
util/osuser: turn wasm check into a const expression
bradfitz Jul 26, 2024
34de96d
go.mod.sri: update SRI hash for go.mod changes
Jul 29, 2024
32308fc
Dockerfile: add a warning that this is not used to build our publishe…
irbekrm Jul 30, 2024
1b64961
build(deps): bump github.com/docker/docker (#12966)
dependabot[bot] Jul 30, 2024
eead255
build_docker.sh: update script comment (#12970)
irbekrm Jul 30, 2024
8a8ecac
net/dns, cmd/tailscaled: plumb system health tracker into dns cleanup…
barnstar Jul 30, 2024
949b15d
net/captivedetection: call SetHealthy once connectivity restored (#12…
agottardo Jul 30, 2024
7bc2dda
go.mod,net/tstun,wgengine/netstack: implement gVisor TCP GSO for Linu…
jwhited Jul 31, 2024
0def4f8
net/netns: on Windows, fall back to default interface index when unsp…
dblohm7 Jul 31, 2024
004dded
net/tlsdial: relax self-signed cert health warning
bradfitz Jul 31, 2024
655b4f8
net/netns: remove some logspam by avoiding logging parse errors due t…
dblohm7 Jul 31, 2024
cc37031
health: don't show login error details with context cancelations
bradfitz Aug 1, 2024
f0230ce
go.mod,net/tstun,wgengine/netstack: implement gVisor TCP GRO for Linu…
jwhited Aug 2, 2024
4055b63
net/captivedetection: exclude cellular data interfaces (#13002)
agottardo Aug 2, 2024
9939374
wgengine/magicsock: use cloud metadata to get public IPs
andrew-d Jul 10, 2024
d9d9d52
wgengine/netstack: increase gVisor's TCP send and receive buffer size…
jwhited Aug 2, 2024
4099a36
util/winutil/gp: fix a busy loop bug
nickkhyl Aug 3, 2024
a917718
util/linuxfw: return nil interface not concrete type
Aug 3, 2024
f205efc
net/packet/checksum: fix v6 NAT
Aug 3, 2024
0a6eb12
go.mod.sri: update SRI hash for go.mod changes
Aug 2, 2024
1dd9c44
tsweb: mark TestStdHandler_ConnectionClosedDuringBody flaky
Aug 3, 2024
07e2487
wgengine/capture: fix v6 field typo in wireshark dissector
Aug 3, 2024
a7a394e
tstest/integration: mark TestNATPing flaky
Aug 3, 2024
25f0a3f
wgengine/netstack: use build tags to exclude gVisor GRO importation o…
jwhited Aug 3, 2024
17c88a1
net/captivedetection: mark TestAllEndpointsAreUpAndReturnExpectedResp…
jwhited Aug 3, 2024
0fd7374
cmd/tailscale/cli: fix `revoke-keys` command name in CLI output
knyar Aug 5, 2024
3b6849e
licenses: update license notices
Aug 5, 2024
91d2e17
words: raccoon dog, dog with the raccoon in 'im
kotx Aug 5, 2024
e3f0476
net/socks5: support UDP
vimt Jun 25, 2024
2275095
{control,net}: close idle connections of custom transports
knyar Aug 3, 2024
153a476
prober: add an HTTP endpoint for triggering a probe
knyar Jul 30, 2024
9b08399
prober: add a status page handler
knyar Jul 30, 2024
9106187
prober: support JSON response in RunHandler
knyar Jul 31, 2024
b3fc345
cmd/derpprobe: use a status page from the prober library
knyar Jul 31, 2024
7bac5df
control/controlhttp: extract the last network connection
knyar Aug 3, 2024
a93dc6c
wgengine/magicsock: refactor batchingUDPConn to batchingConn interfac…
jwhited Aug 6, 2024
6ca078c
cmd/derper: move 204 handler from package main to derphttp
bradfitz Aug 7, 2024
1ed958f
tstest/natlab/vnet: add start of virtual network-based NAT Lab
bradfitz Aug 5, 2024
f79183d
cmd/tsidp: add funnel support (#12591)
tendstofortytwo Aug 8, 2024
46db698
prober: make status page more clear
knyar Aug 8, 2024
ad038f4
cmd/gitops-pusher: add --fail-on-manual-edits flag (#13066)
awly Aug 8, 2024
c0c4791
cmd/gitops-pusher: ignore previous etag if local acls match control (…
awly Aug 8, 2024
a867a48
go.toolchain.rev: bump Go toolchain for net pkg resolv.conf fix
bradfitz Aug 8, 2024
f23932b
net/dns/resolver: log forwarded query details when TS_DEBUG_DNS_FORWA…
nickkhyl Aug 8, 2024
2069189
cmd/stunstamp: refactor to support multiple protocols (#13063)
jwhited Aug 9, 2024
8594292
vnet: add control/derps to test, stateful firewall
bradfitz Aug 7, 2024
1016aa0
hostinfo: add hostinfo.IsNATLabGuestVM
bradfitz Aug 8, 2024
12764e9
natlab: add NodeAgentClient
Aug 8, 2024
6798f8e
tstest/natlab/vnet: add port mapping
bradfitz Aug 8, 2024
082e46b
vnet: don't hard-code bradfitz or maisem in paths
bradfitz Aug 8, 2024
17a10f7
vnet: add network.logf
bradfitz Aug 8, 2024
f8d23b3
tstest/integration/nat: stream daemon logs directly
Aug 8, 2024
bb3e95c
vnet: fix port mapping (w/ maisem + andrew)
bradfitz Aug 8, 2024
f47a5fe
vnet: reduce some log spam
bradfitz Aug 8, 2024
730fec1
tstest/integration/nat: add start of TestGrid
bradfitz Aug 8, 2024
194ff6e
tstest/integration/nat: add sameLAN node type
bradfitz Aug 8, 2024
072d1a4
gokrazy: bump
Aug 8, 2024
d0e8375
cmd/{tta,vnet}: proxy to gokrazy UI
Aug 8, 2024
d4cc074
tstest/natlab/vnet: add pcap support
Aug 9, 2024
44d6343
tstest/natlab/vnet: add easyAF
bradfitz Aug 9, 2024
2a88428
tstest/integration/nat: skip some tests by default without flags
bradfitz Aug 9, 2024
ce4413a
client/tailscale: add Via to UserRuleMatch
Aug 9, 2024
2e32abc
cmd/tailscaled: allow setting env via linux cmdline for integration t…
bradfitz Aug 9, 2024
bc2744d
tsweb: fix TestStdHandler_ConnectionClosedDuringBody flake (#13046)
icio Aug 12, 2024
2181109
cmd/stunstamp: implement HTTPS & TCP latency measurements (#13082)
jwhited Aug 12, 2024
7aec8d4
cmd/stunstamp: refactor connection construction (#13110)
jwhited Aug 12, 2024
10c2bee
tstest/natlab/vnet: capture network wan/lan interfaces
Aug 9, 2024
0dd9f53
go.mod.sri: update SRI hash for go.mod changes
Aug 7, 2024
0686bc8
cmd/tailscaled: add env knob to control default verbosity
bradfitz Aug 12, 2024
b692985
client/tailscale: add LocalClient.OmitAuth for tests
bradfitz Aug 12, 2024
a61825c
cmd/tta, vnet: add host firewall, env var support, more tests
bradfitz Aug 10, 2024
67df9ab
util/syspolicy/setting: add package that contains types for the next …
nickkhyl Aug 4, 2024
10662c4
tstest/integration/nat: annotate test 'want' values, fail on mismatch
bradfitz Aug 13, 2024
10d0ce8
tstest/natlab: get tailscaled logs from gokrazy via syslog
bradfitz Aug 13, 2024
84adfa1
tstest/natlab/vnet: standardize on 1-based naming of nodes, networks,…
bradfitz Aug 13, 2024
b7e4805
cmd/tailscale/cli: don't run CLI as a service on gokrazy
bradfitz Aug 13, 2024
9f1d9d3
gokrazy/tsapp: remove builddirs packages that aren't in config.json
bradfitz Aug 13, 2024
adbab25
cmd/k8s-operator: fix DNS reconciler for dual-stack clusters (#13057)
irbekrm Aug 13, 2024
f79e688
cmd/tailscale/cli: fix gokrazy CLI-as-a-service detection
bradfitz Aug 13, 2024
b60a9fc
gokrazy/tsapp: remove implicit heartbeat package
bradfitz Aug 13, 2024
eae6a00
tstest/integration/nat: crank up verbosity of a failing test
bradfitz Aug 13, 2024
b26c533
tstest/integration/nat: make Tailscale status log print less spammy
bradfitz Aug 13, 2024
d985da2
tstest/natlab/vnet: fix one-by-one from earlier numbering change
bradfitz Aug 13, 2024
b358f48
tstest/integration/nat: remove -audio none flag from qemu
bradfitz Aug 13, 2024
02581b1
gokrazy,tstest/integration/nat: add Gokrazy appliance just for natlab
bradfitz Aug 13, 2024
c987cf1
go.mod: pull in latest github.com/creack/pty
qbit Aug 13, 2024
b4e5956
go.mod.sri: update SRI hash for go.mod changes
Aug 13, 2024
b9f4281
cmd/containerboot: optionally serve health check endpoint (#12899)
irbekrm Aug 14, 2024
2506bf5
fix #13076: codegen error when using anonymous struct
Aug 9, 2024
4c2e978
cmd/tailscale/cli: support passing network lock keys via files
bradfitz Aug 14, 2024
a15ff1b
cmd/k8s-operator,k8s-operator/sessionrecording: support recording kub…
irbekrm Aug 14, 2024
74b9fa1
ipn/localapi: only flush relevant data in multiFilePostResponseWriter…
oxtoacart Aug 14, 2024
2dd71e6
wgengine/magicsock: log when a ReceiveFunc fails
bradfitz Aug 14, 2024
2f27319
wgengine/netstack: disable gVisor TCP GRO for Linux (#13138)
jwhited Aug 14, 2024
f8f9f05
cmd/viewer: add support for map-like container types
nickkhyl Aug 14, 2024
6c852fa
go.{mod,sum}: migrate from nhooyr.io/websocket to github.com/coder/we…
kylecarbs Aug 9, 2024
db4247f
go.mod.sri: update SRI hash for go.mod changes
Aug 15, 2024
e107977
wgengine/magicsock: disable SIO_UDP_NETRESET on Windows
andrew-d Jul 26, 2024
d88be7c
safeweb: add Server.Close method (#13160)
awly Aug 15, 2024
cc136a5
licenses: update license notices
Aug 15, 2024
ccf091e
wgengine/magicsock: don't upgrade to linuxBatchingConn on Android (#1…
jwhited Aug 15, 2024
5cbbb48
health/dns: reduce severity of DNS unavailable warning (#13152)
agottardo Aug 16, 2024
ee976ad
posture: deduplicate MAC addresses before returning them
knyar Aug 16, 2024
aa448d5
VERSION.txt: this is v1.72.0
agottardo Aug 19, 2024
c365c9c
Merge branch 'release-branch/1.72' into cpierre/coreweave-1.72
ChandonPierre Aug 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# Copyright (c) Tailscale Inc & AUTHORS
# SPDX-License-Identifier: BSD-3-Clause

############################################################################
# Note that this Dockerfile is currently NOT used to build any of the published
# Tailscale container images and may have drifted from the image build mechanism
# we use.
# Tailscale images are currently built using https://github.com/tailscale/mkctr,
# and the build script can be found in ./build_docker.sh.
#
# WARNING: Tailscale is not yet officially supported in container
# environments, such as Docker and Kubernetes. Though it should work, we
# don't regularly test it, and we know there are some feature limitations.
#
# See current bugs tagged "containers":
# https://github.com/tailscale/tailscale/labels/containers
#
############################################################################

# This Dockerfile includes all the tailscale binaries.
#
# To build the Dockerfile:
Expand Down Expand Up @@ -46,7 +42,7 @@ RUN go install \
gvisor.dev/gvisor/pkg/tcpip/stack \
golang.org/x/crypto/ssh \
golang.org/x/crypto/acme \
nhooyr.io/websocket \
github.com/coder/websocket \
github.com/mdlayher/netlink

COPY . .
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.70.0
1.72.0
24 changes: 7 additions & 17 deletions build_docker.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
#!/usr/bin/env sh

#
# Runs `go build` with flags configured for docker distribution. All
# it does differently from `go build` is burn git commit and version
# information into the binaries inside docker, so that we can track down user
# issues.
#
############################################################################
#
# WARNING: Tailscale is not yet officially supported in container
# environments, such as Docker and Kubernetes. Though it should work, we
# don't regularly test it, and we know there are some feature limitations.
#
# See current bugs tagged "containers":
# https://github.com/tailscale/tailscale/labels/containers
#
############################################################################
# This script builds Tailscale container images using
# github.com/tailscale/mkctr.
# By default the images will be tagged with the current version and git
# hash of this repository as produced by ./cmd/mkversion.
# This is the image build mechanim used to build the official Tailscale
# container images.

set -eu

Expand Down Expand Up @@ -49,7 +39,7 @@ case "$TARGET" in
-X tailscale.com/version.gitCommitStamp=${VERSION_GIT_HASH}" \
--base="${BASE}" \
--tags="${TAGS}" \
--gotags="ts_kube" \
--gotags="ts_kube,ts_package_container" \
--repos="${REPOS}" \
--push="${PUSH}" \
--target="${PLATFORM}" \
Expand Down
10 changes: 9 additions & 1 deletion client/tailscale/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ func (c *Client) ACLHuJSON(ctx context.Context) (acl *ACLHuJSON, err error) {
// ACLTestFailureSummary specifies the JSON format sent to the
// JavaScript client to be rendered in the HTML.
type ACLTestFailureSummary struct {
User string `json:"user,omitempty"`
// User is the source ("src") value of the ACL test that failed.
// The name "user" is a legacy holdover from the original naming and
// is kept for compatibility but it may also contain any value
// that's valid in a ACL test "src" field.
User string `json:"user,omitempty"`

Errors []string `json:"errors,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
Expand Down Expand Up @@ -281,6 +286,9 @@ type UserRuleMatch struct {
Users []string `json:"users"`
Ports []string `json:"ports"`
LineNumber int `json:"lineNumber"`
// Via is the list of targets through which Users can access Ports.
// See https://tailscale.com/kb/1378/via for more information.
Via []string `json:"via,omitempty"`

// Postures is a list of posture policies that are
// associated with this match. The rules can be looked
Expand Down
29 changes: 26 additions & 3 deletions client/tailscale/localclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ type LocalClient struct {
// connecting to the GUI client variants.
UseSocketOnly bool

// OmitAuth, if true, omits sending the local Tailscale daemon any
// authentication token that might be required by the platform.
//
// As of 2024-08-12, only macOS uses an authentication token. OmitAuth is
// meant for when Dial is set and the LocalAPI is being proxied to a
// different operating system, such as in integration tests.
OmitAuth bool

// tsClient does HTTP requests to the local Tailscale daemon.
// It's lazily initialized on first use.
tsClient *http.Client
Expand Down Expand Up @@ -124,8 +132,10 @@ func (lc *LocalClient) DoLocalRequest(req *http.Request) (*http.Response, error)
},
}
})
if _, token, err := safesocket.LocalTCPPortAndToken(); err == nil {
req.SetBasicAuth("", token)
if !lc.OmitAuth {
if _, token, err := safesocket.LocalTCPPortAndToken(); err == nil {
req.SetBasicAuth("", token)
}
}
return lc.tsClient.Do(req)
}
Expand Down Expand Up @@ -933,7 +943,20 @@ func CertPair(ctx context.Context, domain string) (certPEM, keyPEM []byte, err e
//
// API maturity: this is considered a stable API.
func (lc *LocalClient) CertPair(ctx context.Context, domain string) (certPEM, keyPEM []byte, err error) {
res, err := lc.send(ctx, "GET", "/localapi/v0/cert/"+domain+"?type=pair", 200, nil)
return lc.CertPairWithValidity(ctx, domain, 0)
}

// CertPairWithValidity returns a cert and private key for the provided DNS
// domain.
//
// It returns a cached certificate from disk if it's still valid.
// When minValidity is non-zero, the returned certificate will be valid for at
// least the given duration, if permitted by the CA. If the certificate is
// valid, but for less than minValidity, it will be synchronously renewed.
//
// API maturity: this is considered a stable API.
func (lc *LocalClient) CertPairWithValidity(ctx context.Context, domain string, minValidity time.Duration) (certPEM, keyPEM []byte, err error) {
res, err := lc.send(ctx, "GET", fmt.Sprintf("/localapi/v0/cert/%s?type=pair&min_validity=%s", domain, minValidity), 200, nil)
if err != nil {
return nil, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion client/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"license": "BSD-3-Clause",
"engines": {
"node": "18.16.1",
"node": "18.20.4",
"yarn": "1.22.19"
},
"type": "module",
Expand Down
64 changes: 63 additions & 1 deletion cmd/containerboot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
// ${TS_CERT_DOMAIN}, it will be replaced with the value of the available FQDN.
// It cannot be used in conjunction with TS_DEST_IP. The file is watched for changes,
// and will be re-applied when it changes.
// - TS_HEALTHCHECK_ADDR_PORT: if specified, an HTTP health endpoint will be
// served at /healthz at the provided address, which should be in form [<address>]:<port>.
// If not set, no health check will be run. If set to :<port>, addr will default to 0.0.0.0
// The health endpoint will return 200 OK if this node has at least one tailnet IP address,
// otherwise returns 503.
// NB: the health criteria might change in the future.
// - TS_EXPERIMENTAL_VERSIONED_CONFIG_DIR: if specified, a path to a
// directory that containers tailscaled config in file. The config file needs to be
// named cap-<current-tailscaled-cap>.hujson. If this is set, TS_HOSTNAME,
Expand Down Expand Up @@ -95,6 +101,7 @@ import (
"log"
"math"
"net"
"net/http"
"net/netip"
"os"
"os/exec"
Expand Down Expand Up @@ -158,6 +165,7 @@ func main() {
AllowProxyingClusterTrafficViaIngress: defaultBool("EXPERIMENTAL_ALLOW_PROXYING_CLUSTER_TRAFFIC_VIA_INGRESS", false),
PodIP: defaultEnv("POD_IP", ""),
EnableForwardingOptimizations: defaultBool("TS_EXPERIMENTAL_ENABLE_FORWARDING_OPTIMIZATIONS", false),
HealthCheckAddrPort: defaultEnv("TS_HEALTHCHECK_ADDR_PORT", ""),
}

if err := cfg.validate(); err != nil {
Expand Down Expand Up @@ -349,6 +357,9 @@ authLoop:

certDomain = new(atomic.Pointer[string])
certDomainChanged = make(chan bool, 1)

h = &healthz{} // http server for the healthz endpoint
healthzRunner = sync.OnceFunc(func() { runHealthz(cfg.HealthCheckAddrPort, h) })
)
if cfg.ServeConfigPath != "" {
go watchServeConfigChanges(ctx, cfg.ServeConfigPath, certDomainChanged, certDomain, client)
Expand Down Expand Up @@ -565,6 +576,13 @@ runLoop:
log.Fatalf("storing device IPs and FQDN in Kubernetes Secret: %v", err)
}
}

if cfg.HealthCheckAddrPort != "" {
h.Lock()
h.hasAddrs = len(addrs) != 0
h.Unlock()
healthzRunner()
}
}
if !startupTasksDone {
// For containerboot instances that act as TCP
Expand Down Expand Up @@ -1152,7 +1170,8 @@ type settings struct {
// PodIP is the IP of the Pod if running in Kubernetes. This is used
// when setting up rules to proxy cluster traffic to cluster ingress
// target.
PodIP string
PodIP string
HealthCheckAddrPort string
}

func (s *settings) validate() error {
Expand Down Expand Up @@ -1201,6 +1220,11 @@ func (s *settings) validate() error {
if s.EnableForwardingOptimizations && s.UserspaceMode {
return errors.New("TS_EXPERIMENTAL_ENABLE_FORWARDING_OPTIMIZATIONS is not supported in userspace mode")
}
if s.HealthCheckAddrPort != "" {
if _, err := netip.ParseAddrPort(s.HealthCheckAddrPort); err != nil {
return fmt.Errorf("error parsing TS_HEALTH_CHECK_ADDR_PORT value %q: %w", s.HealthCheckAddrPort, err)
}
}
return nil
}

Expand Down Expand Up @@ -1374,3 +1398,41 @@ func tailscaledConfigFilePath() string {
log.Printf("Using tailscaled config file %q for capability version %q", maxCompatVer, tailcfg.CurrentCapabilityVersion)
return path.Join(dir, kubeutils.TailscaledConfigFileNameForCap(maxCompatVer))
}

// healthz is a simple health check server, if enabled it returns 200 OK if
// this tailscale node currently has at least one tailnet IP address else
// returns 503.
type healthz struct {
sync.Mutex
hasAddrs bool
}

func (h *healthz) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.Lock()
defer h.Unlock()
if h.hasAddrs {
w.Write([]byte("ok"))
} else {
http.Error(w, "node currently has no tailscale IPs", http.StatusInternalServerError)
}
}

// runHealthz runs a simple HTTP health endpoint on /healthz, listening on the
// provided address. A containerized tailscale instance is considered healthy if
// it has at least one tailnet IP address.
func runHealthz(addr string, h *healthz) {
lis, err := net.Listen("tcp", addr)
if err != nil {
log.Fatalf("error listening on the provided health endpoint address %q: %v", addr, err)
}
mux := http.NewServeMux()
mux.Handle("/healthz", h)
log.Printf("Running healthcheck endpoint at %s/healthz", addr)
hs := &http.Server{Handler: mux}

go func() {
if err := hs.Serve(lis); err != nil {
log.Fatalf("failed running health endpoint: %v", err)
}
}()
}
15 changes: 10 additions & 5 deletions cmd/derper/depaware.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
W 💣 github.com/alexbrainman/sspi/negotiate from tailscale.com/net/tshttpproxy
github.com/beorn7/perks/quantile from github.com/prometheus/client_golang/prometheus
💣 github.com/cespare/xxhash/v2 from github.com/prometheus/client_golang/prometheus
github.com/coder/websocket from tailscale.com/cmd/derper+
github.com/coder/websocket/internal/errd from github.com/coder/websocket
github.com/coder/websocket/internal/util from github.com/coder/websocket
github.com/coder/websocket/internal/xsync from github.com/coder/websocket
L github.com/coreos/go-iptables/iptables from tailscale.com/util/linuxfw
W 💣 github.com/dblohm7/wingoes from tailscale.com/util/winutil
github.com/fxamacker/cbor/v2 from tailscale.com/tka
github.com/go-json-experiment/json from tailscale.com/types/opt
github.com/go-json-experiment/json from tailscale.com/types/opt+
github.com/go-json-experiment/json/internal from github.com/go-json-experiment/json+
github.com/go-json-experiment/json/internal/jsonflags from github.com/go-json-experiment/json+
github.com/go-json-experiment/json/internal/jsonopts from github.com/go-json-experiment/json+
Expand Down Expand Up @@ -82,10 +86,6 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
google.golang.org/protobuf/runtime/protoiface from google.golang.org/protobuf/internal/impl+
google.golang.org/protobuf/runtime/protoimpl from github.com/prometheus/client_model/go+
google.golang.org/protobuf/types/known/timestamppb from github.com/prometheus/client_golang/prometheus+
nhooyr.io/websocket from tailscale.com/cmd/derper+
nhooyr.io/websocket/internal/errd from nhooyr.io/websocket
nhooyr.io/websocket/internal/util from nhooyr.io/websocket
nhooyr.io/websocket/internal/xsync from nhooyr.io/websocket
tailscale.com from tailscale.com/version
tailscale.com/atomicfile from tailscale.com/cmd/derper+
tailscale.com/client/tailscale from tailscale.com/derp
Expand Down Expand Up @@ -146,9 +146,11 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
tailscale.com/util/cloudenv from tailscale.com/hostinfo+
W tailscale.com/util/cmpver from tailscale.com/net/tshttpproxy
tailscale.com/util/ctxkey from tailscale.com/tsweb+
💣 tailscale.com/util/deephash from tailscale.com/util/syspolicy/setting
L 💣 tailscale.com/util/dirwalk from tailscale.com/metrics
tailscale.com/util/dnsname from tailscale.com/hostinfo+
tailscale.com/util/fastuuid from tailscale.com/tsweb
💣 tailscale.com/util/hashx from tailscale.com/util/deephash
tailscale.com/util/httpm from tailscale.com/client/tailscale
tailscale.com/util/lineread from tailscale.com/hostinfo+
L tailscale.com/util/linuxfw from tailscale.com/net/netns
Expand All @@ -159,6 +161,8 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
tailscale.com/util/singleflight from tailscale.com/net/dnscache
tailscale.com/util/slicesx from tailscale.com/cmd/derper+
tailscale.com/util/syspolicy from tailscale.com/ipn
tailscale.com/util/syspolicy/internal from tailscale.com/util/syspolicy/setting
tailscale.com/util/syspolicy/setting from tailscale.com/util/syspolicy
tailscale.com/util/vizerror from tailscale.com/tailcfg+
W 💣 tailscale.com/util/winutil from tailscale.com/hostinfo+
W 💣 tailscale.com/util/winutil/winenv from tailscale.com/hostinfo+
Expand All @@ -180,6 +184,7 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
golang.org/x/crypto/nacl/secretbox from golang.org/x/crypto/nacl/box
golang.org/x/crypto/salsa20/salsa from golang.org/x/crypto/nacl/box+
W golang.org/x/exp/constraints from tailscale.com/util/winutil
golang.org/x/exp/maps from tailscale.com/util/syspolicy/setting
L golang.org/x/net/bpf from github.com/mdlayher/netlink+
golang.org/x/net/dns/dnsmessage from net+
golang.org/x/net/http/httpguts from net/http
Expand Down
29 changes: 2 additions & 27 deletions cmd/derper/derper.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func main() {
tsweb.AddBrowserHeaders(w)
io.WriteString(w, "User-agent: *\nDisallow: /\n")
}))
mux.Handle("/generate_204", http.HandlerFunc(serveNoContent))
mux.Handle("/generate_204", http.HandlerFunc(derphttp.ServeNoContent))
debug := tsweb.Debugger(mux)
debug.KV("TLS hostname", *hostname)
debug.KV("Mesh key", s.HasMeshKey())
Expand Down Expand Up @@ -337,7 +337,7 @@ func main() {
if *httpPort > -1 {
go func() {
port80mux := http.NewServeMux()
port80mux.HandleFunc("/generate_204", serveNoContent)
port80mux.HandleFunc("/generate_204", derphttp.ServeNoContent)
port80mux.Handle("/", certManager.HTTPHandler(tsweb.Port80Handler{Main: mux}))
port80srv := &http.Server{
Addr: net.JoinHostPort(listenHost, fmt.Sprintf("%d", *httpPort)),
Expand Down Expand Up @@ -378,31 +378,6 @@ func main() {
}
}

const (
noContentChallengeHeader = "X-Tailscale-Challenge"
noContentResponseHeader = "X-Tailscale-Response"
)

// For captive portal detection
func serveNoContent(w http.ResponseWriter, r *http.Request) {
if challenge := r.Header.Get(noContentChallengeHeader); challenge != "" {
badChar := strings.IndexFunc(challenge, func(r rune) bool {
return !isChallengeChar(r)
}) != -1
if len(challenge) <= 64 && !badChar {
w.Header().Set(noContentResponseHeader, "response "+challenge)
}
}
w.WriteHeader(http.StatusNoContent)
}

func isChallengeChar(c rune) bool {
// Semi-randomly chosen as a limited set of valid characters
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') ||
('0' <= c && c <= '9') ||
c == '.' || c == '-' || c == '_'
}

var validProdHostname = regexp.MustCompile(`^derp([^.]*)\.tailscale\.com\.?$`)

func prodAutocertHostPolicy(_ context.Context, host string) error {
Expand Down
Loading