summaryrefslogtreecommitdiffhomepage
path: root/tsweb
AgeCommit message (Collapse)AuthorFilesLines
2026-04-13all: fix six tests that failed with -count=2Brad Fitzpatrick1-1/+1
Avery found a bunch of tests that fail with -count=2. Updates tailscale/corp#40176 (tracks making our CI detect them) Change-Id: Ie3e4398070dd92e4fe0146badddf1254749cca20 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> Co-authored-by: Avery Pennarun <apenwarr@tailscale.com>
2026-04-08tsweb: add TS_DEBUG_TRUSTED_CIDRS envknob to debug (#19283)Jason O'Donnell2-0/+129
Add a new envknob that allows connections from trusted CIDR ranges to access debug endpoints without Tailscale authentication. This is useful for in-cluster scrapers like Prometheus that are not on a tailnet, do not have static IP addresses and cannot use debug keys. Fixes #19282 Signed-off-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com>
2026-04-05cmd/vet: add subtestnames analyzer; fix all existing violationsBrad Fitzpatrick1-22/+22
Add a new vet analyzer that checks t.Run subtest names don't contain characters requiring quoting when re-running via "go test -run". This enforces the style guide rule: don't use spaces or punctuation in subtest names. The analyzer flags: - Direct t.Run calls with string literal names containing spaces, regex metacharacters, quotes, or other problematic characters - Table-driven t.Run(tt.name, ...) calls where tt ranges over a slice/map literal with bad name field values Also fix all 978 existing violations across 81 test files, replacing spaces with hyphens and shortening long sentence-like names to concise hyphenated forms. Updates #19242 Change-Id: Ib0ad96a111bd8e764582d1d4902fe2599454ab65 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2026-03-06all: use Go 1.26 things, run most gofix modernizersBrad Fitzpatrick2-12/+10
I omitted a lot of the min/max modernizers because they didn't result in more clear code. Some of it's older "for x := range 123". Also: errors.AsType, any, fmt.Appendf, etc. Updates #18682 Change-Id: I83a451577f33877f962766a5b65ce86f7696471c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2026-02-06tsweb/varz: remove unnecessary Map.Init() calls in testsAnton Tolchanov1-8/+0
Updates #cleanup Signed-off-by: Anton Tolchanov <anton@tailscale.com>
2026-02-06tsweb/varz: only export numeric expvar.Map valuesAnton Tolchanov2-2/+55
Currently the expvar exporter attempts to write expvar.String, which breaks the Prometheus metric page. Updates tailscale/corp#36552 Signed-off-by: Anton Tolchanov <anton@tailscale.com>
2026-01-23all: remove AUTHORS file and references to itWill Norris12-12/+12
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-12-12tsweb: add Unwrap to loggingResponseWriter for ResponseController (#18195)James 'zofrex' Sanderson1-0/+4
The new http.ResponseController type added in Go 1.20: https://go.dev/doc/go1.20#http_responsecontroller requires ResponseWriters that are wrapping the original passed to ServeHTTP to implement an Unwrap method: https://pkg.go.dev/net/http#NewResponseController With this in place, it is possible to call methods such as Flush and SetReadDeadline on a loggingResponseWriter without needing to implement them there ourselves. Updates tailscale/corp#34763 Updates tailscale/corp#34813 Signed-off-by: James Sanderson <jsanderson@tailscale.com>
2025-11-18all: rename variables with lowercase-l/uppercase-IAlex Chan1-19/+19
See http://go/no-ell Signed-off-by: Alex Chan <alexc@tailscale.com> Updates #cleanup Change-Id: I8c976b51ce7a60f06315048b1920516129cc1d5d
2025-10-10tsweb/varz: add support for ShardedInt metricsAnton Tolchanov2-0/+19
Fixes tailscale/corp#33236 Signed-off-by: Anton Tolchanov <anton@tailscale.com>
2025-06-16scripts/check_license_headers.sh: delete, rewrite as a Go testBrad Fitzpatrick1-0/+1
Updates tailscale/corp#29650 Change-Id: Iad4e4ccd9d68ebb1d1a12f335cc5295d0bd05b60 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-06-12tsweb/varz: add binary name to version metricBrad Fitzpatrick1-1/+19
Fixes tailscale/corp#29530 Change-Id: Iae04456d7ac5527897f060370e90c9517c00a818 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-04-28tsweb/varz: export GC CPU fraction gaugeJames Tucker2-14/+124
We were missing this metric, but it can be important for some workloads. Varz memstats output allocation cost reduced from 30 allocs per invocation to 1 alloc per invocation. Updates tailscale/corp#28033 Signed-off-by: James Tucker <james@tailscale.com> Co-authored-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-04-16tsd: wire up the event bus to tailscaledDavid Anderson2-1/+3
Updates #15160 Signed-off-by: David Anderson <dave@tailscale.com>
2025-04-16tsweb: don't hook up pprof handlers in javascript buildsDavid Anderson4-12/+33
Updates #15160 Signed-off-by: David Anderson <dave@tailscale.com>
2025-03-18tsweb: split promvarz into an optional dependencyDavid Anderson3-5/+23
Allows the use of tsweb without pulling in all of the heavy prometheus client libraries, protobuf and so on. Updates #15160 Signed-off-by: David Anderson <dave@tailscale.com>
2025-03-12tsweb: add title to DebugHandler and helper registration methodsWill Norris1-5/+26
Allow customizing the title on the debug index page. Also add methods for registering http.HandlerFunc to make it a little easier on callers. Updates tailscale/corp#27058 Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <will@tailscale.com>
2025-01-22tsweb: add missing debug pprof endpointsBrad Fitzpatrick1-7/+7
Updates tailscale/corp#26016 Change-Id: I47a5671e881cc092d83c1e992e2271f90afcae7e Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-11-20tsweb: change RequestID format to have a date in itBrad Fitzpatrick2-5/+30
So we can locate them in logs more easily. Updates tailscale/corp#24721 Change-Id: Ia766c75608050dde7edc99835979a6e9bb328df2 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-11-07tsweb/varz: optimize some allocs, add helper func for othersBrad Fitzpatrick1-2/+8
Updates #cleanup Updates tailscale/corp#23546 (noticed when doing this) Change-Id: Ia9f627fe32bb4955739b2787210ba18f5de27f4d Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-08-27usermetric: add initial user-facing metricsKristoffer Dalby1-12/+21
This commit adds a new usermetric package and wires up metrics across the tailscale client. Updates tailscale/corp#22075 Co-authored-by: Anton Tolchanov <anton@tailscale.com> Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2024-08-27tsweb/varz: remove pprofKristoffer Dalby1-1/+0
Updates tailscale/corp#22075 Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2024-08-12tsweb: fix TestStdHandler_ConnectionClosedDuringBody flake (#13046)Paul Scott1-11/+12
Fixes #13017 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-08-03tsweb: mark TestStdHandler_ConnectionClosedDuringBody flakyMaisem Ali1-0/+2
Updates #13107 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2024-07-29tsweb: add QuietLogging option (#12838)Paul Scott2-1/+61
Allows the use of tsweb.LogHandler exclusively for callbacks describing the handler HTTP requests. Fixes #12837 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-25tsweb: Add MiddlewareStack func to apply lists of Middleware (#12907)Paul Scott2-0/+66
Fixes #12909 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-24tsweb: log all cancellations as 499s (#12894)Paul Scott2-29/+250
Updates #12141 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-19tsweb: log cancelled requests as 499Paul Scott2-16/+105
Fixes #12860 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-18tsweb: swallow panicsPaul Scott2-104/+231
With this change, the error handling and request logging are all done in defers after calling inner.ServeHTTP. This ensures that any recovered values which we want to re-panic with retain a useful stacktrace. However, we now only re-panic from errorHandler when there's no outside logHandler. Which if you're using StdHandler there always is. We prefer this to ensure that we are able to write a 500 Internal Server Error to the client. If a panic hits http.Server then the response is not sent back. Updates #12784 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-16tsweb: log once per requestPaul Scott2-157/+422
StdHandler/retHandler would previously emit one log line for each request. If there were multiple StdHandler in the chain, there would be one log line per instance of retHandler. With this change, only the outermost StdHandler/logHandler actually logs the request or invokes OnStart or OnCompletion callbacks. The error-rendering part of retHandler lives on in errorHandler, and errorHandler passes those errors up the stack to logHandler through a callback that logHandler places in the request.Context(). Updates tailscale/corp#19999 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-15tsweb: fix TestStdHandler_panic flakePaul Scott1-9/+3
Fixes #12816 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-15tsweb: add stack trace to panic error msgPaul Scott2-4/+96
Updates #12784 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-06-26tsweb: accept a function to call before request handlingAnton Tolchanov2-3/+28
To complement the existing `onCompletion` callback, which is called after request handler. Updates tailscale/corp#17075 Signed-off-by: Anton Tolchanov <anton@tailscale.com>
2024-06-14derp/xdp,cmd/xdpderper: initial skeleton (#12390)Jordan Whited1-1/+1
This commit introduces a userspace program for managing an experimental eBPF XDP STUN server program. derp/xdp contains the eBPF pseudo-C along with a Go pkg for loading it and exporting its metrics. cmd/xdpderper is a package main user of derp/xdp. Updates tailscale/corp#20689 Signed-off-by: Jordan Whited <jordan@tailscale.com>
2024-06-06tsweb: add optional on completion callback funcKristoffer Dalby1-0/+12
Updates corp#17075 Co-Authored-By: Anton Tolchanov <anton@tailscale.com> Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2024-05-31tsweb: rename AccessLogRecord's When to TimeMarwan Sulaiman3-26/+26
This change makes our access log record more consistent with the new log/tslog package formatting of "time". Note that we can change slog itself to call "time" "when" but we're chosing to make this breaking change to be consistent with the std lib's defaults. Updates tailscale/corp#17071 Signed-off-by: Marwan Sulaiman <marwan@tailscale.com>
2024-05-05tsweb: remove redundant bumpStartIfNeeded funcWill Norris1-7/+8
Updates #12001 Signed-off-by: Will Norris <will@tailscale.com>
2024-05-03tsweb: ensure in-flight requests are always marked as finishedWill Norris1-2/+5
The inflight request tracker only starts recording a new bucket after the first non-error request. Unfortunately, it's written in such a way that ONLY successful requests are ever marked as being finished. Once a bucket has had at least one successful request and begun to be tracked, all subsequent error cases are never marked finished and always appear as in-flight. This change ensures that if a request is recorded has having been started, we also mark it as finished at the end. Updates tailscale/corp#19767 Signed-off-by: Will Norris <will@tailscale.com>
2024-04-16all: use Go 1.22 range-over-intBrad Fitzpatrick1-2/+2
Updates #11058 Change-Id: I35e7ef9b90e83cac04ca93fd964ad00ed5b48430 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-04-09tsweb: switch to fastuuid for request ID generationJames Tucker1-2/+2
Request ID generation appears prominently in some services cumulative allocation rate, and while this does not eradicate this issue (the API still makes UUID objects), it does improve the overhead of this API and reduce the amount of garbage that it produces. Updates tailscale/corp#18266 Updates tailscale/corp#19054 Signed-off-by: James Tucker <james@tailscale.com>
2024-04-05tsweb: handle panics in retHandlerMaisem Ali1-1/+26
We would have incomplete stats and missing logs in cases of panics. Updates tailscale/corp#18687 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2024-04-02tsweb: update doc on BucketedStatsOptions.Finish to match behaviorJames Tucker1-1/+2
I originally came to update this to match the documented behavior, but the code is deliberately avoiding this behavior currently, making it hard to decide how to update this. For now just align the documentation to the behavior. Updates #cleanup Signed-off-by: James Tucker <james@tailscale.com>
2024-03-28tsweb: make BucketedStats not track 400s, 404s, etcBrad Fitzpatrick1-2/+20
Updates tailscale/corp#18687 Change-Id: I142ccb1301ec4201c70350799ff03222bce96668 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-03-27tsweb/varz: add charset=utf-8 to varz handlerBrad Fitzpatrick1-1/+1
Some of our labels contain UTF-8 and get mojibaked in the browser right now. Updates tailscale/corp#18687 Change-Id: I6069cffd6cc8813df415f06bb308bc2fc3ab65c4 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-03-26metrics, tsweb/varz: add multi-label map metricsBrad Fitzpatrick2-0/+28
Updates tailscale/corp#18640 Change-Id: Ia9ae25956038e9d3266ea165537ac6f02485b74c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-03-24tsweb/varz: flesh out munging of expvar keys into valid Prometheus metricsBrad Fitzpatrick2-1/+42
From a problem we hit with how badger registers expvars; it broke trunkd's exported metrics. Updates tailscale/corp#1297 Change-Id: I42e1552e25f734c6f521b6e993d57a82849464b2 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-03-06tsweb: add String method to tsweb.RequestIDAndrew Dunham1-0/+6
In case we want to change the format to something opaque later. Updates tailscale/corp#2549 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: Ie2eac8b885b694be607e9d5101d24b650026d89c
2024-03-04tsweb: add more test cases for TestCleanRedirectURL (#11331)Chris Palmer1-1/+9
Updates #cleanup Signed-off-by: Chris Palmer <cpalmer@tailscale.com>
2024-02-28tsweb: allow empty redirect URL in CleanRedirectURL (#11295)Andrew Lytvynov2-28/+36
Updates #cleanup Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
2024-02-27tsweb: expose function to generate request IDsAndrew Dunham1-7/+14
For use in corp. Updates tailscale/corp#2549 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: I71debae1ce9ae48cf69cc44c2ab5c443fc3b2005