Commit Graph
583 Commits
Author SHA1 Message Date
Kristoffer Dalby d2dc13696a config, cli, packaging, nix: stop restarting headscale on a configuration error
serve exits 78 (EX_CONFIG) when the configuration file it loaded is
wrong: format, syntax, keys or values. No file, an unreadable one, the
database and ports still exit 1, so systemd keeps retrying what can
heal. The deb unit and the NixOS module set RestartPreventExitStatus=78.
A parse error gives a position and fixed words, never the file's text.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby b600c1f391 cli: print only the required keys with generate config --minimal
With every other key defaulted, server_url alone is a configuration.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby f5f86e69d0 config: require listen_addr and the sqlite path
Empty values serve cannot use; empty server_url reads "is required".

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 542fe8dd55 config: give every key but server_url a working default
server_url alone, in a file or HEADSCALE_SERVER_URL, now passes check config.

Fixes #3567
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 3a35f74873 nix: build the module on the generated options
settings mirrors headscale's keys one to one, headscale's checks judge the
rest, and the local CLI gets the socket from a variable instead of a file.

headscale always runs as headscale:headscale, which the module creates;
user and group are read-only, so setting either fails evaluation, and stay
only because nixpkgs' headplane module reads them. A settings.cli key
fails evaluation instead of being dropped with a warning, and the unit no
longer gets CAP_CHOWN.
nix/example-configuration.nix goes: the options carry its examples and
defaults.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby c7d097d65e config: log a missing config file only for serve
The environment alone is a complete configuration and client commands
need a file only for an API key, so the loader stops warning; serve logs
at info level that it runs on defaults and the environment.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby d437b271ce cli: generate NixOS options from the config schema
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 6602227d3e cli: add generate config, replacing dumpConfig
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby e9abc6ae35 hscontrol: validate configuration in NewHeadscale
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby f1cbdcfacb config: load configuration outside types
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 865c001068 types: give config values their own types
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 77491a5bd8 types: compute derived config values where they are used
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 3e12fa9d39 types: remove viper
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby cb4ccd97c2 types: reject unknown and removed config keys
Fixes #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby ae6ea2cce4 cli: add check config and check all
check config validates only the config; check all adds one
ok/FAIL/skip line per named file.

Fixes #3443
2026-11-11 12:19:22 +01:00
Kristoffer Dalby f5fd1d16cf cli: add check policy
check policy and policy set share ValidatePolicy; tests and sshTests
run against stand-ins built from the policy. Replaces policy check.

Fixes #3355
2026-11-11 12:06:27 +01:00
Kristoffer Dalby 0fe0545b3d cli: add check command group that loads config on demand
Updates #3355
2026-11-11 12:06:27 +01:00
Kristoffer Dalby f9992637a6 cli: follow the update-client wire format
Drop --force, which also shadowed the global flag. Wait 15s, past
the server's 10s c2n wait.

Updates #3629
2026-11-05 15:51:04 +01:00
Martín Gómez 931282a137 cli: add nodes update-client command 2026-11-05 15:51:04 +01:00
Kristoffer Dalby 36ea8d9e81 policy/v2: refuse autogroup:member as SSH destination
Tailscale answers invalid dst "autogroup:member" for every source.

Updates #3335
2026-11-05 13:43:48 +01:00
Kristoffer Dalby 9ad6b73072 cli: show a pre-auth key without expiration as - 2026-11-05 12:41:50 +01:00
Kristoffer Dalby 459b157c3b docs: note the posture attributes endpoint and its proxy setting
trusted_proxies now feeds a stored, API-visible address, not only logs.

Updates #2272
2026-11-05 12:38:53 +01:00
Kristoffer Dalby bdc005e518 cli: validate offline policy set like policy check 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 8550812eaf cli: show a node's own ephemeral flag instead of its key's 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 54eedce658 all: build with Go 1.27.3
crypto/x509 security fixes.
2026-10-22 14:37:00 +02:00
Kristoffer Dalby dcc01dc2b0 types: move TLS config under tls with legacy fallback
tls.cert_path, tls.key_path and tls.acme.* replace the flat keys, which
still work. Warn on them only when they turn TLS on: NixOS always sets them.

Updates #2527
2026-10-18 20:53:18 +02:00
LuoChen aaf4ccd8c9 util, types: parse unix_socket_permission strictly
Default "0o770" failed the base-8 parse and silently became 0700.
Invalid, unquoted or above-0777 values now fail config load.

Fixes #3529
2026-10-09 11:42:53 +02:00
Kristoffer Dalby c9852c43da ci: distribute the compiled integration test binary 2026-10-09 11:41:09 +02:00
Kristoffer Dalby 47653f06fb integration: avoid toolchain work and login waits in CI 2026-10-09 11:41:09 +02:00
Kristoffer Dalby 62f89ca25d cli: accept a user name in preauthkeys create --user
Resolved through lookupUser like the users commands, so scripts skip the
users list round trip. Digit-only values stay IDs.
2026-09-28 21:42:19 +02:00
Kristoffer Dalby 715c5a4a1c cli: split the user lookup out of resolveSingleUser
Lets commands with their own flags resolve a user the same way.
2026-09-28 21:42:19 +02:00
MsfPablo d60bac5c79 db: reject unknown OAuth client scopes at creation (#3424)
Unknown scopes grant nothing, so clients were silently under-privileged.
Report every invalid scope at once.

Fixes #3406
2026-09-25 21:24:37 +02:00
Michael Lopez 3746ad20db cli: distinguish no match from ambiguous match when resolving users
resolveSingleUser reported every non-single result as "multiple users
match query", including zero matches. An explicit --identifier 0 was
sent to the API, which treats id=0 as no filter, so it listed every
user and failed as ambiguous. Return a not-found error for zero matches,
list the matching users when several match, and reject a non-positive
identifier before calling the API.
2026-09-25 20:00:15 +02:00
Kristoffer Dalby 2114ced0d5 cli: classify Serve errors with operator hints
A *ListenerBindError that wraps syscall.EADDRINUSE now ends with a
"sudo ss -tlnp 'sport = :PORT'" pointer, and one wrapping
syscall.EACCES with a CAP_NET_BIND_SERVICE / setcap pointer. The
underlying chain is preserved via fmt.Errorf("%w"), so errors.Is /
errors.As continue to walk to the typed bind error and the syscall
errno.

Drop the "headscale ran into an error and had to shut down" wrap,
which only restated the symptom.

Export types.PortFromAddr so the classifier can render the port
number in the hint.

Updates #3227
2026-09-23 15:18:34 +02:00
Lukas Runge beecdf0dbf cli: fix lint findings in the users rename test
Address golangci-lint findings in users_test.go: replace inline
"if err := ...; err != nil" statements with plain assignments
(noinlineerr) and add blank lines between statements in the fake
server's filter loop and before an early return (wsl_v5).
2026-09-04 11:37:56 +02:00
Lukas Runge 41e49462c4 cli: fix users rename when resolved by name
resolveSingleUser returned the raw --identifier flag value instead of
the identifier of the matched user. Renaming with --name therefore sent
OldId=0 to the API and failed with "user not found". Return the matched
user's identifier and pass it straight to the rename endpoint.
2026-09-04 11:37:56 +02:00
Kristoffer Dalby 635bda9139 hi: compare the stream error with errors.Is 2026-08-25 21:59:00 +02:00
Kristoffer Dalby f06ff1cf81 all: build with Go 1.27
Bump every remaining toolchain reference: images, goreleaser, the hi
runner fallback and docs.
2026-08-25 21:59:00 +02:00
Fredrik Ekre dc3c0bc587 cli: remove leftover trace log from #3324 that always renders a JSON marshaling error
Noticed this while testing out #3394.
2026-07-28 12:27:10 +02:00
Kristoffer Dalby 8d91e42a9f cmd/hi: share the test-container prefix matcher and check the k3s image
Factor the hs-/ts-/derp-/k3s- prefix set into one helper used by cleanup and docker; add a doctor check for the ghcr k3s image.
2026-06-26 22:06:26 +02:00
Kristoffer Dalby b05f8875c3 hscontrol, cli: serve the v2 API on the local socket and add the oauth-clients command
Serve the v2 API over the local unix socket for the CLI and add the
oauth-clients command that drives it.
2026-06-26 09:18:06 +02:00
Kristoffer Dalby 8f314797ce all: fix full-tree golangci-lint findings
The new full-tree golangci-lint check reports issues the --new-from-rev
diff lint hid: nine wsl_v5 whitespace gaps, a prealloc, and an unparam
(setCSRFCookie never errored, so drop the return and update callers).
gocyclo on the central UpdateNodeFromMapRequest and an SA1019 NetMap
deprecation in an integration helper are suppressed with reasons.
2026-06-20 21:08:01 +02:00
Kristoffer Dalby 49d6949639 cli: stop doubling the scheme on a remote CLI address
newRemoteClient prepended "https://" unconditionally, so
HEADSCALE_CLI_ADDRESS=https://host became https://https://host and dialed
the host "https". Default a bare host to https, keep an explicit scheme.
2026-06-20 09:55:42 +02:00
Kristoffer Dalby 72adc5ff2a docs: add changelog and refresh the API reference for the v1 API 2026-06-19 15:21:00 +02:00
Kristoffer Dalby 560b6d81ad hscontrol: remove the proto, gRPC and grpc-gateway stack
With the v1 API served by Huma and the CLI on the HTTP client, nothing
uses the gRPC service or its generated code. Delete proto/, the generated
gen/go and gen/openapiv2, grpcv1.go, the buf config, the proto .Proto()
helpers and gRPC config, and the proto build tooling from the flake and
CI.
2026-06-19 15:21:00 +02:00
Kristoffer Dalby 8efa5ad1fe cli: migrate the CLI and integration tests to the v1 HTTP API
Replace the gRPC client with the generated HTTP client across every
command: locally over the unix socket without auth (matching the previous
local gRPC socket), remotely over TLS with a Bearer API key. Output
rendering and integration tests move to the HTTP client types; the
transport changes, the assertions do not.
2026-06-19 15:21:00 +02:00
Kristoffer Dalby c9bbb5bdec api/v1: add code-first Huma implementation of the v1 API
Reimplement the v1 API as a code-first Huma service in hscontrol/api/v1,
a thin adapter over the state layer. Huma emits the OpenAPI 3.1 document
(openapi/v1/headscale.yaml) from the Go operation and type definitions;
cmd/gen-openapi writes it and the 3.0.3 downgrade the client is generated
from. Responses reproduce the protojson wire contract (string-encoded
64-bit IDs, all fields emitted, RFC3339/null timestamps); errors map to
the correct HTTP status (404/400/409, 500 for server faults) via mapError.

Serve it on the chi router at /api/v1 behind the existing API-key
middleware, and point /swagger at the emitted spec.
2026-06-19 15:21:00 +02:00
Kristoffer Dalby 4f4e95fc80 all: adopt strings, errors, and os helpers 2026-06-17 16:12:19 +02:00
Kristoffer Dalby 27468f944b all: adopt maps and cmp helpers 2026-06-17 16:12:19 +02:00
Kristoffer Dalby ac725f27e4 all: adopt slices helpers 2026-06-17 16:12:19 +02:00