types: reject unknown and removed config keys

Fixes #1926
This commit is contained in:
Kristoffer Dalby committed 2026-11-11 15:02:16 +01:00
1 parent 7328157817
commit cb4ccd97c2
73 files changed
+3606 -2692

No files matched your search

-2
View File
@@ -51,10 +51,8 @@ runs:
server_url: ${URL}
listen_addr: 0.0.0.0:8443
metrics_listen_addr: 127.0.0.1:9090
grpc_listen_addr: 127.0.0.1:50443
unix_socket: /tmp/hs/headscale.sock
unix_socket_permission: "0770"
private_key_path: /tmp/hs/private.key
noise:
private_key_path: /tmp/hs/noise.key
prefixes:
+6
View File
@@ -104,6 +104,12 @@ linters:
- common-false-positives
- legacy
- std-error-handling
rules:
# Config key names repeat across the key tables, validation and error
# reports until the config reshape gives each key one home.
- path: hscontrol/types/(config|config_keys|listener)\.go
linters:
- goconst
paths:
- third_party$
- builtin$
+8 -8
View File
@@ -11,7 +11,6 @@ import (
policyv2 "github.com/juanfont/headscale/hscontrol/policy/v2"
"github.com/juanfont/headscale/hscontrol/types"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var errCheckFailed = errors.New("check failed")
@@ -24,7 +23,7 @@ func init() {
checkCmd.AddCommand(checkPolicyCmd)
for _, c := range []*cobra.Command{checkConfigCmd, checkAllCmd} {
c.Flags().StringP("file", "f", "", "Path to the config file (default: found as serve finds it: -c, HEADSCALE_CONFIG, /etc/headscale, ~/.headscale, .)")
c.Flags().StringP("file", "f", "", "Path to the config file (default: found as serve finds it: -c, HEADSCALE_CONFIG, /etc/headscale, $XDG_CONFIG_HOME/headscale, headscale under each $XDG_CONFIG_DIRS entry, ~/.headscale, .)")
checkCmd.AddCommand(c)
}
@@ -74,9 +73,7 @@ var checkConfigCmd = &cobra.Command{
Long: `
Config validates the configuration: its syntax, keys and values. It does
not check the files the configuration names; "headscale check all" does.
Without --file it finds the configuration as "headscale serve" does. Secret
files named by oidc.client_secret_path and the DNS provider *_path settings
are read while the configuration loads.`,
Without --file it finds the configuration as "headscale serve" does.`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
_, src, err := loadCheckedConfig(cmd)
@@ -96,7 +93,8 @@ var checkAllCmd = &cobra.Command{
Long: `
All checks the configuration, then each file it names, and lists every file
with ok, FAIL (the error below it) or skip. Skip is a key file that startup
creates when it is missing. It exits non-zero when any line is FAIL.
creates when it is missing, or a "file:<path>" secret. It exits non-zero
when any line is FAIL.
A derp.paths file that fails to parse is FAIL here, although startup only
skips it with a warning.`,
@@ -130,6 +128,8 @@ var checkAllCmd = &cobra.Command{
printCheckLine(out, "ok", f.Key, f.Path, width, nil)
case f.CreatedAtStartup && errors.Is(err, os.ErrNotExist):
printCheckLine(out, "skip", f.Key, f.Path+" (missing; startup creates it)", width, nil)
case errors.Is(err, config.ErrSecretNotRead):
printCheckLine(out, "skip", f.Key, f.Path+" ("+err.Error()+")", width, nil)
default:
failed++
@@ -180,7 +180,7 @@ func loadCheckedConfig(cmd *cobra.Command) (*types.Config, string, error) {
err := loadConfig(path)
src := viper.ConfigFileUsed()
src := types.ConfigFile()
if src == "" {
src = "(defaults and environment)"
}
@@ -189,7 +189,7 @@ func loadCheckedConfig(cmd *cobra.Command) (*types.Config, string, error) {
return nil, src, err
}
cfg, err := types.LoadServerConfig()
cfg, err := types.CheckServerConfig()
return cfg, src, err
}
+85
View File
@@ -273,6 +273,91 @@ func TestCheckAll(t *testing.T) {
})
}
// No check reads a file: secret: its file may exist only for the service
// (systemd credentials, sops, agenix). check all lists each one as skipped.
func TestCheckSecretsUnread(t *testing.T) {
const acmeDNS = ` challenge:
provider:
name: acmedns
`
t.Run("missing secret files", func(t *testing.T) {
dir := t.TempDir()
missing := filepath.Join(dir, "missing")
for k, v := range map[string]string{
"HEADSCALE_OIDC_ISSUER": "https://idp.example.com",
"HEADSCALE_OIDC_CLIENT_ID": "headscale",
"HEADSCALE_OIDC_CLIENT_SECRET": "file:" + missing,
"HEADSCALE_DATABASE_TYPE": "postgres",
"HEADSCALE_DATABASE_POSTGRES_PASS": "file:" + missing,
"HEADSCALE_DNS_CHALLENGE_PROVIDER_NAME": "cloudflare",
"HEADSCALE_DNS_CHALLENGE_PROVIDER_API_TOKEN": "file:" + missing,
} {
t.Setenv(k, v)
}
cfg := writeServerConfig(t, dir, "")
_, err := runCheck(t, checkConfigCmd, cfg)
require.NoError(t, err)
out, err := runCheck(t, checkAllCmd, cfg)
require.NoError(t, err)
lines := strings.Split(out, "\n")
for _, key := range []string{"oidc.client_secret", "database.postgres.pass", "dns.challenge.provider.api_token"} {
require.Contains(t, lines, fmt.Sprintf("skip %-32s %s (secret, not read)", key, missing))
}
})
// A URL from a file cannot be validated unread.
for name, provider := range map[string]string{
"account": acmeDNS + ` username: user
password: pass
subdomain: reg
server_url: "file:%s"
`,
"registration": acmeDNS + ` config:
laptop.example.com:
username: user
password: pass
subdomain: reg
server_url: "file:%s"
`,
} {
t.Run("acme-dns "+name+" url from file", func(t *testing.T) {
dir := t.TempDir()
cfg := writeServerConfig(t, dir, fmt.Sprintf(provider, filepath.Join(dir, "missing")))
for _, c := range []*cobra.Command{checkConfigCmd, checkAllCmd} {
_, err := runCheck(t, c, cfg)
require.NoError(t, err, c.Name())
}
})
}
// Setting names match case-insensitively, as the decoder matches them;
// only the environment's JSON keeps their case.
for _, field := range []string{"server_url", "SERVER_URL", "Server_URL"} {
t.Run("acme-dns registration "+field+" from file in env json", func(t *testing.T) {
dir := t.TempDir()
t.Setenv("HEADSCALE_DNS_CHALLENGE_PROVIDER_NAME", "acmedns")
t.Setenv("HEADSCALE_DNS_CHALLENGE_PROVIDER", fmt.Sprintf(
`{"config":{"Node.Example.com":{"username":"user","password":"pass","subdomain":"reg",%q:"file:%s"}}}`,
field, filepath.Join(dir, "missing")))
cfg := writeServerConfig(t, dir, "")
for _, c := range []*cobra.Command{checkConfigCmd, checkAllCmd} {
_, err := runCheck(t, c, cfg)
require.NoError(t, err, c.Name())
}
})
}
}
func TestCheckFileCommands(t *testing.T) {
dir := t.TempDir()
+8 -2
View File
@@ -2,9 +2,10 @@ package cli
import (
"fmt"
"os"
"github.com/juanfont/headscale/hscontrol/types"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
func init() {
@@ -16,7 +17,12 @@ var dumpConfigCmd = &cobra.Command{
Short: "dump current config to /etc/headscale/config.dump.yaml, integration test only",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
err := viper.WriteConfigAs("/etc/headscale/config.dump.yaml")
out, err := types.DumpConfig()
if err != nil {
return fmt.Errorf("dumping config: %w", err)
}
err = os.WriteFile("/etc/headscale/config.dump.yaml", out, 0o600)
if err != nil {
return fmt.Errorf("dumping config: %w", err)
}
+5 -7
View File
@@ -11,7 +11,6 @@ import (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tcnksm/go-latest"
)
@@ -54,8 +53,9 @@ func skipsInitConfig(args []string) bool {
}
// loadConfig loads path, else the file -c names, else $HEADSCALE_CONFIG,
// else the first config.* in /etc/headscale, ~/.headscale or ".". Without a
// file it loads defaults and environment only.
// else the first config.* in /etc/headscale, $XDG_CONFIG_HOME/headscale,
// headscale under each $XDG_CONFIG_DIRS entry, ~/.headscale or ".". Without
// a file it loads defaults and environment only.
func loadConfig(path string) error {
for _, p := range []string{path, cfgFile, os.Getenv("HEADSCALE_CONFIG")} {
if p == "" {
@@ -99,13 +99,11 @@ func initConfig() {
zerolog.SetGlobalLevel(zerolog.Disabled)
}
logFormat := viper.GetString("log.format")
if logFormat == types.JSONLogFormat {
if types.LogFormat() == types.JSONLogFormat {
log.Logger = log.Output(os.Stdout)
}
disableUpdateCheck := viper.GetBool("disable_check_updates")
if !disableUpdateCheck && !machineOutput {
if !types.UpdateCheckDisabled() && !machineOutput {
versionInfo := types.GetVersionInfo()
if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") &&
!versionInfo.Dirty {
+1 -1
View File
@@ -466,7 +466,7 @@ func TestLoadConfig(t *testing.T) {
t.Cleanup(func() { cfgFile = old })
require.NoError(t, loadConfig(tt.path))
require.Equal(t, tt.want, viper.ConfigFileUsed())
require.Equal(t, tt.want, types.ConfigFile())
})
}
}
+5 -5
View File
@@ -39,7 +39,7 @@ func TestClassifyServeError(t *testing.T) {
name: "eaddrinuse-named-port",
err: &types.ListenerBindError{
Listener: "ACME HTTP-01 challenge",
YAMLKey: "tls_letsencrypt_listen",
YAMLKey: "tls.acme.http_listen",
Addr: ":http",
Err: &net.OpError{Op: "listen", Net: "tcp", Err: syscall.EADDRINUSE},
},
@@ -77,12 +77,12 @@ func TestClassifyServeError(t *testing.T) {
{
name: "wrapped-eaddrinuse-still-classified",
err: fmt.Errorf("serve: %w", &types.ListenerBindError{
Listener: "gRPC",
YAMLKey: "grpc_listen_addr",
Addr: "0.0.0.0:50443",
Listener: "metrics",
YAMLKey: "metrics_listen_addr",
Addr: "127.0.0.1:9090",
Err: &net.OpError{Op: "listen", Net: "tcp", Err: syscall.EADDRINUSE},
}),
wantHintSubstr: []string{"sudo ss -tlnp 'sport = :50443'"},
wantHintSubstr: []string{"sudo ss -tlnp 'sport = :9090'"},
},
{
name: "eaddrinuse-unparseable-addr-omits-port",
+22 -28
View File
@@ -7,8 +7,6 @@ import (
"testing"
"github.com/juanfont/headscale/hscontrol/types"
"github.com/juanfont/headscale/hscontrol/util"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -32,19 +30,7 @@ func TestConfigFileLoading(t *testing.T) {
err = types.LoadConfig(cfgFile, true)
require.NoError(t, err)
// Test that config file was interpreted correctly
assert.Equal(t, "http://127.0.0.1:8080", viper.GetString("server_url"))
assert.Equal(t, "127.0.0.1:8080", viper.GetString("listen_addr"))
assert.Equal(t, "127.0.0.1:9090", viper.GetString("metrics_listen_addr"))
assert.Equal(t, "sqlite", viper.GetString("database.type"))
assert.Equal(t, "/var/lib/headscale/db.sqlite", viper.GetString("database.sqlite.path"))
assert.Empty(t, viper.GetString("tls.acme.hostname"))
assert.Equal(t, ":http", viper.GetString("tls.acme.http_listen"))
assert.Equal(t, "HTTP-01", viper.GetString("tls.acme.challenge_type"))
mode, err := util.ParseFileMode(viper.GetString("unix_socket_permission"))
require.NoError(t, err)
assert.Equal(t, fs.FileMode(0o770), mode)
assert.False(t, viper.GetBool("logtail.enabled"))
assertExampleConfig(t)
}
func TestConfigLoading(t *testing.T) {
@@ -64,17 +50,25 @@ func TestConfigLoading(t *testing.T) {
err = types.LoadConfig(tmpDir, false)
require.NoError(t, err)
// Test that config file was interpreted correctly
assert.Equal(t, "http://127.0.0.1:8080", viper.GetString("server_url"))
assert.Equal(t, "127.0.0.1:8080", viper.GetString("listen_addr"))
assert.Equal(t, "127.0.0.1:9090", viper.GetString("metrics_listen_addr"))
assert.Equal(t, "sqlite", viper.GetString("database.type"))
assert.Equal(t, "/var/lib/headscale/db.sqlite", viper.GetString("database.sqlite.path"))
assert.Empty(t, viper.GetString("tls.acme.hostname"))
assert.Equal(t, ":http", viper.GetString("tls.acme.http_listen"))
assert.Equal(t, "HTTP-01", viper.GetString("tls.acme.challenge_type"))
mode, err := util.ParseFileMode(viper.GetString("unix_socket_permission"))
require.NoError(t, err)
assert.Equal(t, fs.FileMode(0o770), mode)
assert.False(t, viper.GetBool("logtail.enabled"))
assertExampleConfig(t)
}
// assertExampleConfig checks the loaded config-example.yaml was interpreted
// correctly.
func assertExampleConfig(t *testing.T) {
t.Helper()
cfg, err := types.LoadServerConfig()
require.NoError(t, err)
assert.Equal(t, "http://127.0.0.1:8080", cfg.ServerURL)
assert.Equal(t, "127.0.0.1:8080", cfg.Addr)
assert.Equal(t, "127.0.0.1:9090", cfg.MetricsAddr)
assert.Equal(t, types.DatabaseSqlite, cfg.Database.Type)
assert.Equal(t, "/var/lib/headscale/db.sqlite", cfg.Database.Sqlite.Path)
assert.Empty(t, cfg.TLS.ACME.Hostname)
assert.Equal(t, ":http", cfg.TLS.ACME.HTTPListen)
assert.Equal(t, "HTTP-01", cfg.TLS.ACME.ChallengeType)
assert.Equal(t, fs.FileMode(0o770), cfg.UnixSocketPermission)
assert.False(t, cfg.LogTail.Enabled)
}
+12 -10
View File
@@ -1,7 +1,10 @@
---
# headscale will look for a configuration file named `config.yaml` (or `config.json`) in the following order:
# headscale will look for a configuration file named `config.yaml` (or `config.json`,
# `config.yml`, `config.hujson`) in the following order:
#
# - `/etc/headscale`
# - `$XDG_CONFIG_HOME/headscale` (default `~/.config/headscale`)
# - `headscale` under each `$XDG_CONFIG_DIRS` entry (default `/etc/xdg`)
# - `~/.headscale`
# - current working directory
@@ -144,7 +147,6 @@ node:
# Default key expiry for non-tagged nodes, regardless of registration method
# (auth key, CLI, web auth). Tagged nodes are exempt and never expire.
#
# This is the base default. OIDC can override this via oidc.expiry.
# If a client explicitly requests a specific expiry, the client value is used.
#
# Setting the value to "0" means no default expiry (nodes never expire unless
@@ -221,6 +223,7 @@ database:
# port: 5432
# name: headscale
# user: foo
# # A secret, or "file:<path>" to read it from a file (see oidc.client_secret).
# pass: bar
# max_open_conns: 10
# max_idle_conns: 10
@@ -379,11 +382,11 @@ dns:
# resolvers: []
# acmedns, cloudflare, gigahost, hetzner, powerdns or rfc2136. The other
# keys are settings of that provider; add _path to a key to read it from
# a file.
# keys are settings of that provider; a string setting can be read from
# a file with "file:<path>" (see oidc.client_secret).
# provider:
# name: cloudflare
# api_token_path: /run/credentials/headscale.service/cloudflare-token
# api_token: "file:${CREDENTIALS_DIRECTORY}/cloudflare-token"
#
# acmedns needs a registration per certificate name under config, and
# each _acme-challenge name CNAMEd to its registration's fulldomain. A
@@ -419,12 +422,11 @@ unix_socket_permission: "0770"
# client_id: "your-oidc-client-id"
#
# # Client secret generated by the identity provider
# # Note: client_secret and client_secret_path are mutually exclusive.
# client_secret: "your-oidc-client-secret"
# # Alternatively, set `client_secret_path` to read the secret from the file.
# # It resolves environment variables, making integration to systemd's
# # `LoadCredential` straightforward:
# client_secret_path: "${CREDENTIALS_DIRECTORY}/oidc_client_secret"
# # Alternatively, "file:<path>" reads the secret from the file, as for
# # every secret setting. It resolves environment variables, making
# # integration to systemd's `LoadCredential` straightforward:
# # client_secret: "file:${CREDENTIALS_DIRECTORY}/oidc_client_secret"
#
# # Use the expiry from the token received from OpenID when the user logged
# # in. This will typically lead to frequent need to reauthenticate and should
+1 -1
View File
@@ -73,7 +73,7 @@ func registerPolicy(api huma.API, b Backend) {
return out, nil
case types.PolicyModeFile:
absPath := util.AbsolutePathFromConfigPath(b.Cfg.Policy.Path)
absPath := util.AbsolutePath(b.Cfg.ConfigDir, b.Cfg.Policy.Path)
f, err := os.Open(absPath)
if err != nil {
+1 -1
View File
@@ -221,7 +221,7 @@ func currentPolicy(b Backend) ([]byte, error) {
return []byte(p.Data), nil
case types.PolicyModeFile:
path := util.AbsolutePathFromConfigPath(b.Cfg.Policy.Path)
path := util.AbsolutePath(b.Cfg.ConfigDir, b.Cfg.Policy.Path)
if path == "" {
return []byte(defaultPolicy), nil
}
+14 -2
View File
@@ -17,7 +17,12 @@ import (
"tailscale.com/types/key"
)
var ErrSameKey = errors.New("noise and DERP private keys must differ")
var (
ErrSameKey = errors.New("noise and DERP private keys must differ")
// ErrSecretNotRead is the check of a file: secret: no check reads one.
ErrSecretNotRead = errors.New("secret, not read")
)
// File is one file the configuration names.
type File struct {
@@ -38,7 +43,7 @@ func Files(cfg *types.Config) []File {
var files []File
if cfg.Policy.Mode == types.PolicyModeFile && cfg.Policy.Path != "" {
p := util.AbsolutePathFromConfigPath(cfg.Policy.Path)
p := util.AbsolutePath(cfg.ConfigDir, cfg.Policy.Path)
files = append(files, File{Key: "policy.path", Path: p, Check: func() error { return CheckPolicyFile(p) }})
}
@@ -73,6 +78,13 @@ func Files(cfg *types.Config) []File {
})
}
for _, kv := range cfg.UnreadSecrets {
files = append(files, File{
Key: kv.Key, Path: fmt.Sprint(kv.Value),
Check: func() error { return ErrSecretNotRead },
})
}
return files
}
-2
View File
@@ -41,8 +41,6 @@ database:
type: sqlite3
sqlite:
path: headscale.db
gorm:
prepare_stmt: true
`), 0o600))
require.NoError(t, types.LoadConfig(configPath, true))
+1 -1
View File
@@ -76,7 +76,7 @@ func PolicyBytes(tx *gorm.DB, cfg *types.Config) ([]byte, error) {
return nil, nil
}
absPath := util.AbsolutePathFromConfigPath(path)
absPath := util.AbsolutePath(cfg.ConfigDir, path)
return os.ReadFile(absPath)
+5 -6
View File
@@ -21,7 +21,6 @@ import (
"github.com/juanfont/headscale/hscontrol/types"
"github.com/juanfont/headscale/hscontrol/util"
"github.com/spf13/viper"
"tailscale.com/tailcfg"
)
@@ -270,12 +269,12 @@ func GetDERPMap(cfg types.DERPConfig) (*tailcfg.DERPMap, error) {
}
derpMap := mergeDERPMaps(derpMaps)
shuffleDERPMap(derpMap)
shuffleDERPMap(derpMap, cfg.ShuffleSeed)
return derpMap, errors.Join(errs...)
}
func shuffleDERPMap(dm *tailcfg.DERPMap) {
func shuffleDERPMap(dm *tailcfg.DERPMap, seed string) {
if dm == nil || len(dm.Regions) == 0 {
return
}
@@ -293,7 +292,7 @@ func shuffleDERPMap(dm *tailcfg.DERPMap) {
// A new generator per call gives the same input the same order. Clients
// close their home relay when its node order changes, so a refresh that
// finds no change must not reorder anything.
rng := rand.New(rand.NewSource(derpShuffleSeed())) //nolint:gosec // weak random is fine for DERP scrambling
rng := rand.New(rand.NewSource(derpShuffleSeed(seed))) //nolint:gosec // weak random is fine for DERP scrambling
for _, id := range ids {
region := dm.Regions[id]
@@ -313,12 +312,12 @@ var (
derpSeedMu sync.Mutex
)
func derpShuffleSeed() int64 {
func derpShuffleSeed(seed string) int64 {
derpSeedMu.Lock()
defer derpSeedMu.Unlock()
if !derpSeedSet {
seed := cmp.Or(viper.GetString("dns.base_domain"), time.Now().String())
seed = cmp.Or(seed, time.Now().String())
derpSeed = int64(crc64.Checksum([]byte(seed), crc64Table)) //nolint:gosec // only a seed, overflow is harmless
derpSeedSet = true
}
+5 -15
View File
@@ -12,7 +12,6 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/juanfont/headscale/hscontrol/types"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
"tailscale.com/tailcfg"
)
@@ -250,14 +249,10 @@ func TestShuffleDERPMapDeterministic(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
viper.Set("dns.base_domain", tt.baseDomain)
defer viper.Reset()
resetDerpRandomForTesting()
testMap := tt.derpMap.View().AsStruct()
shuffleDERPMap(testMap)
shuffleDERPMap(testMap, tt.baseDomain)
if diff := cmp.Diff(tt.expected, testMap); diff != "" {
t.Errorf("Shuffled DERP map doesn't match expected (-expected +actual):\n%s", diff)
@@ -269,10 +264,6 @@ func TestShuffleDERPMapDeterministic(t *testing.T) {
// TestGetDERPMapKeepsOrderAcrossRefreshes: clients close their home relay when
// its node order changes, so a refresh of the same input must keep the order.
func TestGetDERPMapKeepsOrderAcrossRefreshes(t *testing.T) {
viper.Set("dns.base_domain", "stable.example.com")
defer viper.Reset()
resetDerpRandomForTesting()
source := &tailcfg.DERPMap{Regions: map[tailcfg.DERPRegionID]*tailcfg.DERPRegion{}}
@@ -286,11 +277,11 @@ func TestGetDERPMapKeepsOrderAcrossRefreshes(t *testing.T) {
source.Regions[id+1] = region
}
first, err := GetDERPMap(types.DERPConfig{DERPMap: source})
first, err := GetDERPMap(types.DERPConfig{DERPMap: source, ShuffleSeed: "stable.example.com"})
require.NoError(t, err)
for range 5 {
next, err := GetDERPMap(types.DERPConfig{DERPMap: source})
next, err := GetDERPMap(types.DERPConfig{DERPMap: source, ShuffleSeed: "stable.example.com"})
require.NoError(t, err)
if diff := cmp.Diff(first, next); diff != "" {
@@ -346,13 +337,12 @@ func TestShuffleDERPMapEdgeCases(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
shuffleDERPMap(tt.derpMap)
shuffleDERPMap(tt.derpMap, "")
})
}
}
func TestShuffleDERPMapWithoutBaseDomain(t *testing.T) {
viper.Reset()
resetDerpRandomForTesting()
derpMap := &tailcfg.DERPMap{
@@ -372,7 +362,7 @@ func TestShuffleDERPMapWithoutBaseDomain(t *testing.T) {
}
original := derpMap.View().AsStruct()
shuffleDERPMap(derpMap)
shuffleDERPMap(derpMap, "")
if len(derpMap.Regions) != 1 || len(derpMap.Regions[1].Nodes) != 4 {
t.Error("Shuffle corrupted DERP map structure")
+154 -49
View File
@@ -49,14 +49,29 @@ type Provider interface {
// providers is the compiled-in provider registry. Providers are decoded
// from configuration through their json tags, so adding one is one line
// plus its module; the set is curated because each provider is a
// dependency to keep current and its quirks become ours.
var providers = map[string]func() Provider{
"acmedns": func() Provider { return &acmeDNS{served: make(map[string][2]acmeDNSValue)} },
"cloudflare": func() Provider { return new(cloudflare.Provider) },
"gigahost": func() Provider { return new(gigahost.Provider) },
"hetzner": func() Provider { return new(hetzner.Provider) },
"powerdns": func() Provider { return new(powerdns.Provider) },
"rfc2136": func() Provider { return new(rfc2136.Provider) },
// dependency to keep current and its quirks become ours. required lists
// the settings the provider's own code cannot work without, so a missing
// one fails at startup instead of at the first certificate. env names the
// variable the provider's own code reads a required setting from when the
// setting is unset.
var providers = map[string]struct {
build func() Provider
required []string
env map[string]string
}{
// validate checks the accounts.
"acmedns": {build: func() Provider { return &acmeDNS{served: make(map[string][2]acmeDNSValue)} }},
// api_token authenticates writes; zone_token only zone lookups.
"cloudflare": {build: func() Provider { return new(cloudflare.Provider) }, required: []string{"api_token"}},
"gigahost": {build: func() Provider { return new(gigahost.Provider) }, required: []string{"api_key"}},
"hetzner": {
build: func() Provider { return new(hetzner.Provider) },
required: []string{"api_token"},
env: map[string]string{"api_token": "LIBDNS_HETZNER_TOKEN"}, //nolint:gosec // a variable's name, not a credential
},
"powerdns": {build: func() Provider { return new(powerdns.Provider) }, required: []string{"server_url", "api_token"}},
// Every request is TSIG-signed.
"rfc2136": {build: func() Provider { return new(rfc2136.Provider) }, required: []string{"server", "key_name", "key_alg", "key"}},
}
var (
@@ -68,11 +83,11 @@ var (
errAcmeDNSOneAccount = errors.New("acme-dns with one account answers every name's challenge from one record; " +
"node certificates need a registration per name under config")
errAcmeDNSShared = errors.New("acme-dns registration mapped to more than one name")
)
// pathSuffix marks a setting whose value is read from a file, keeping
// secrets out of the configuration file.
const pathSuffix = "_path"
// ErrSecretUnread is returned, with the value as given, by a secret
// func that leaves a file: secret unread; checks of it are skipped.
ErrSecretUnread = errors.New("secret left unread")
)
// ProviderNames returns the names of the compiled-in providers.
func ProviderNames() []string {
@@ -84,20 +99,21 @@ func ProviderNames() []string {
// settings holds the provider's keys as written in the configuration
// file. get looks up a single key and is consulted for every field of
// the provider, because environment variables only reach individual
// keys, never a map. Any string field can instead be read from a file
// named by "<field>_path". Unknown keys are an error so a typo does not
// silently leave a credential empty.
// keys, never a map. secret resolves every string setting, nested ones
// included, so any of them can be read from a file. Unknown keys are an
// error so a typo does not silently leave a credential empty.
func NewProvider(
name string,
settings map[string]any,
get func(key string) (any, bool),
secret func(key, value string) (string, error),
) (Provider, error) {
newProvider, ok := providers[strings.ToLower(name)]
entry, ok := providers[strings.ToLower(name)]
if !ok {
return nil, fmt.Errorf("%w: %q", ErrUnknownProvider, name)
}
provider := newProvider()
provider := entry.build()
input := make(map[string]any, len(settings))
for k, v := range settings {
@@ -106,44 +122,37 @@ func NewProvider(
delete(input, "name")
// The values left unread, for validate to skip. Kept by value, as a
// setting's name may be spelt in any case.
unread := map[string]bool{}
read := func(key, value string) (string, error) {
s, err := secret(key, value)
if errors.Is(err, ErrSecretUnread) {
unread[value] = true
return value, nil
}
return s, err
}
fields := jsonFields(provider)
for tag, kind := range fields {
if v, ok := get(tag); ok {
input[tag] = v
}
pathKey := tag + pathSuffix
if _, isField := fields[pathKey]; isField || kind != reflect.String {
value, ok := input[tag]
if _, isMap := value.(map[string]any); !ok || (kind != reflect.String && !isMap) {
continue
}
if v, ok := get(pathKey); ok {
input[pathKey] = v
}
path, ok := input[pathKey]
if !ok {
continue
}
if _, both := input[tag]; both {
return nil, fmt.Errorf("%w: %s and %s are mutually exclusive", ErrProviderConfig, tag, pathKey)
}
value, err := os.ReadFile(os.ExpandEnv(fmt.Sprint(path)))
value, err := resolveSecrets(tag, value, read)
if err != nil {
return nil, fmt.Errorf("%w: reading %s: %w", ErrProviderConfig, pathKey, err)
return nil, fmt.Errorf("%w: %w", ErrProviderConfig, err)
}
input[tag] = strings.TrimSpace(string(value))
delete(input, pathKey)
}
// Every provider needs a credential or a server: a block with only a
// name is a secret that was not set, and would fail at the first
// certificate instead of at startup.
if len(input) == 0 {
return nil, fmt.Errorf("%w for %s: no settings", ErrProviderConfig, name)
input[tag] = value
}
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
@@ -162,8 +171,25 @@ func NewProvider(
return nil, fmt.Errorf("%w for %s: %w", ErrProviderConfig, name, err)
}
if v, ok := provider.(interface{ validate() error }); ok {
err = v.validate()
// After decoding, so a misspelt setting is reported as that. An unread
// file: value counts as set.
var missing []string
for _, k := range entry.required {
// os.Getenv("") is "" for a setting without a fallback variable.
if v := input[k]; (v == nil || v == "") && os.Getenv(entry.env[k]) == "" {
missing = append(missing, k)
}
}
if len(missing) > 0 {
return nil, fmt.Errorf("%w for %s: missing %s", ErrProviderConfig, name, strings.Join(missing, ", "))
}
if v, ok := provider.(interface {
validate(unread map[string]bool) error
}); ok {
err = v.validate(unread)
if err != nil {
return nil, fmt.Errorf("%w for %s: %w", ErrProviderConfig, name, err)
}
@@ -172,6 +198,83 @@ func NewProvider(
return provider, nil
}
// resolveSecrets resolves every string in value, down through nested
// settings such as acme-dns's per-name registrations; key names the
// setting in errors. Maps are copied, as they may be the caller's.
func resolveSecrets(key string, value any, secret func(key, value string) (string, error)) (any, error) {
switch value := value.(type) {
case string:
return secret(key, value)
case map[string]any:
out := make(map[string]any, len(value))
for k, v := range value {
r, err := resolveSecrets(key+"."+k, v, secret)
if err != nil {
return nil, err
}
out[k] = r
}
return out, nil
}
return value, nil
}
// IsProviderSetting reports whether a compiled-in provider has a setting
// named name, nested ones such as acme-dns's registrations included.
func IsProviderSetting(name string) bool {
return providerSetting(name, func(reflect.Type) bool { return true })
}
// IsProviderMapSetting reports whether a compiled-in provider has a map
// setting named name, whose keys are names, such as acme-dns's
// registrations, rather than settings.
func IsProviderMapSetting(name string) bool {
return providerSetting(name, func(t reflect.Type) bool { return t.Kind() == reflect.Map })
}
func providerSetting(name string, match func(reflect.Type) bool) bool {
for _, entry := range providers {
if hasSetting(reflect.TypeOf(entry.build()), name, match) {
return true
}
}
return false
}
// hasSetting matches names case-insensitively, as the decoder does.
func hasSetting(t reflect.Type, name string, match func(reflect.Type) bool) bool {
for t.Kind() == reflect.Pointer || t.Kind() == reflect.Map || t.Kind() == reflect.Slice {
t = t.Elem()
}
if t.Kind() != reflect.Struct {
return false
}
for _, f := range reflect.VisibleFields(t) {
tag, _, _ := strings.Cut(f.Tag.Get("json"), ",")
if !f.IsExported() || tag == "" || tag == "-" {
continue
}
ft := f.Type
for ft.Kind() == reflect.Pointer {
ft = ft.Elem()
}
if (strings.EqualFold(tag, name) && match(ft)) || hasSetting(f.Type, name, match) {
return true
}
}
return false
}
// jsonFields returns the json key and kind of each configurable field of
// the provider struct.
func jsonFields(provider Provider) map[string]reflect.Kind {
@@ -313,7 +416,8 @@ func (p *acmeDNS) CheckIsolation() error {
sub := p.Configs[name].Subdomain
if other, shared := names[sub]; shared {
return fmt.Errorf("%w: %s and %s share registration %s", errAcmeDNSShared, other, name, sub)
// The registration is not named: it may have been read from a file.
return fmt.Errorf("%w: %s and %s share a registration", errAcmeDNSShared, other, name)
}
names[sub] = name
@@ -336,8 +440,8 @@ func (p *acmeDNS) registration(zone, name string) string {
// validate reports at startup what acmedns would only report at the first
// certificate. It builds requests without checking the URL, so a bad
// server_url would panic.
func (p *acmeDNS) validate() error {
// server_url would panic. An unread server_url is checked once it is read.
func (p *acmeDNS) validate(unread map[string]bool) error {
accounts := []acmedns.DomainConfig{{
Username: p.Username,
Password: p.Password,
@@ -351,8 +455,9 @@ func (p *acmeDNS) validate() error {
for _, a := range accounts {
u, err := url.Parse(a.ServerURL)
missing := a.Username == "" || a.Password == "" || a.Subdomain == ""
badURL := !unread[a.ServerURL] && (err != nil || u.Host == "")
if missing || err != nil || u.Host == "" {
if missing || badURL {
return errAcmeDNSAccount
}
}
+114 -14
View File
@@ -7,6 +7,7 @@ import (
"net/http/httptest"
"os"
"path/filepath"
"strings"
"sync"
"testing"
"time"
@@ -24,6 +25,69 @@ import (
func noEnv(string) (any, bool) { return nil, false }
// readSecret stands in for the caller's file: resolver.
func readSecret(_, value string) (string, error) {
path, ok := strings.CutPrefix(value, "file:")
if !ok {
return value, nil
}
b, err := os.ReadFile(path)
return strings.TrimSpace(string(b)), err
}
func TestIsProviderSetting(t *testing.T) {
assert.True(t, IsProviderSetting("api_token"))
assert.True(t, IsProviderSetting("config"))
assert.True(t, IsProviderSetting("fulldomain"), "a registration setting")
assert.True(t, IsProviderSetting("API_Token"), "matched as the decoder matches")
assert.True(t, IsProviderMapSetting("config"))
assert.False(t, IsProviderMapSetting("api_token"))
assert.False(t, IsProviderSetting("api_token_path"))
}
// unreadSecret stands in for a caller that checks without reading files.
func unreadSecret(_, value string) (string, error) {
if strings.HasPrefix(value, "file:") {
return value, ErrSecretUnread
}
return value, nil
}
// TestNewProviderUnreadSecrets pins that a check without the files skips
// only what needs their contents.
func TestNewProviderUnreadSecrets(t *testing.T) {
account := func(serverURL string) map[string]any {
return map[string]any{"username": "user", "password": "file:/pass", "subdomain": "reg", "server_url": serverURL}
}
tests := []struct {
name string
settings map[string]any
wantErr bool
}{
{name: "server_url from file", settings: account("file:/url")},
{name: "registration server_url from file", settings: map[string]any{"config": map[string]any{"laptop.example.com": account("file:/url")}}},
{name: "literal server_url still checked", settings: account("auth.acme-dns.io"), wantErr: true},
{name: "literal registration server_url still checked", settings: map[string]any{"config": map[string]any{"laptop.example.com": account("auth.acme-dns.io")}}, wantErr: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := NewProvider("acmedns", tt.settings, noEnv, unreadSecret)
if tt.wantErr {
require.ErrorIs(t, err, ErrProviderConfig)
return
}
require.NoError(t, err)
})
}
}
func TestNewProvider(t *testing.T) {
secret := filepath.Join(t.TempDir(), "token")
require.NoError(t, os.WriteFile(secret, []byte("from-file\n"), 0o600))
@@ -64,21 +128,21 @@ func TestNewProvider(t *testing.T) {
},
},
{
name: "secret from path",
name: "secret from file",
provider: "cloudflare",
settings: map[string]any{"api_token_path": secret},
settings: map[string]any{"api_token": "file:" + secret},
want: &cloudflare.Provider{APIToken: "from-file"},
},
{
name: "value and path both set",
name: "path key is unknown",
provider: "cloudflare",
settings: map[string]any{"api_token": "tok", "api_token_path": secret},
settings: map[string]any{"api_token_path": secret},
wantErr: ErrProviderConfig,
},
{
name: "unreadable path",
name: "unreadable file",
provider: "cloudflare",
settings: map[string]any{"api_token_path": filepath.Join(t.TempDir(), "missing")},
settings: map[string]any{"api_token": "file:" + filepath.Join(t.TempDir(), "missing")},
wantErr: ErrProviderConfig,
},
{
@@ -95,13 +159,13 @@ func TestNewProvider(t *testing.T) {
{
name: "gigahost",
provider: "gigahost",
settings: map[string]any{"api_key_path": secret},
settings: map[string]any{"api_key": "file:" + secret},
want: &gigahost.Provider{APIKey: "from-file"},
},
{
name: "hetzner",
provider: "hetzner",
settings: map[string]any{"api_token_path": secret},
settings: map[string]any{"api_token": "file:" + secret},
want: &hetzner.Provider{APIToken: "from-file"},
},
{
@@ -114,10 +178,10 @@ func TestNewProvider(t *testing.T) {
name: "acmedns",
provider: "acmedns",
settings: map[string]any{
"username": "user",
"password_path": secret,
"subdomain": "reg",
"server_url": "https://auth.acme-dns.io",
"username": "user",
"password": "file:" + secret,
"subdomain": "reg",
"server_url": "https://auth.acme-dns.io",
},
want: &acmeDNS{
Username: "user",
@@ -150,6 +214,42 @@ func TestNewProvider(t *testing.T) {
served: map[string][2]acmeDNSValue{},
},
},
{
name: "acmedns per domain from file",
provider: "acmedns",
settings: map[string]any{"config": map[string]any{
"node.ts.example.com": map[string]any{
"username": "user",
"password": "file:" + secret,
"subdomain": "reg",
"server_url": "https://auth.acme-dns.io",
},
}},
want: &acmeDNS{
Configs: map[string]acmedns.DomainConfig{
"node.ts.example.com": {
Username: "user",
Password: "from-file",
Subdomain: "reg",
ServerURL: "https://auth.acme-dns.io",
},
},
served: map[string][2]acmeDNSValue{},
},
},
{
name: "acmedns per domain file missing",
provider: "acmedns",
settings: map[string]any{"config": map[string]any{
"node.ts.example.com": map[string]any{
"username": "user",
"password": "file:" + filepath.Join(t.TempDir(), "missing"),
"subdomain": "reg",
"server_url": "https://auth.acme-dns.io",
},
}},
wantErr: ErrProviderConfig,
},
{
name: "acmedns server_url without scheme",
provider: "acmedns",
@@ -181,7 +281,7 @@ func TestNewProvider(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := NewProvider(tt.provider, tt.settings, noEnv)
got, err := NewProvider(tt.provider, tt.settings, noEnv, readSecret)
if tt.wantErr != nil {
require.ErrorIs(t, err, tt.wantErr)
@@ -281,7 +381,7 @@ func TestAcmeDNSRefusesEviction(t *testing.T) {
srv := newFakeAcmeDNS(t)
p, err := NewProvider("acmedns", srv.registration(), noEnv)
p, err := NewProvider("acmedns", srv.registration(), noEnv, readSecret)
require.NoError(t, err)
ctx := context.Background()
+2 -1
View File
@@ -1291,7 +1291,8 @@ func TestCertDomains(t *testing.T) {
"subdomain": "reg",
"server_url": "https://auth.acme-dns.io",
},
}}, func(string) (any, bool) { return nil, false })
}}, func(string) (any, bool) { return nil, false },
func(_, v string) (string, error) { return v, nil })
require.NoError(t, err)
tests := []struct {
+1 -1
View File
@@ -441,7 +441,7 @@ func NewState(cfg *types.Config) (*State, error) {
}
// Apply defaults for [NodeStore] batch configuration if not set.
// This ensures tests that create Config directly (without viper) still work.
// This ensures tests that create Config directly (without LoadConfig) still work.
batchSize := cmp.Or(cfg.Tuning.NodeStoreBatchSize, defaultNodeStoreBatchSize)
batchTimeout := cmp.Or(cfg.Tuning.NodeStoreBatchTimeout, defaultNodeStoreBatchTimeout)
+303 -561
View File
File diff suppressed because it is too large. Load diff
+12 -8
View File
@@ -50,8 +50,6 @@ func keyPosition(src []byte, path []string) (int, int, bool) {
// configKeys lists every key the loader reads, so env mapping and the strict
// pass know the schema. Open maps are in openMapKeys.
//
//nolint:goconst // schema table, not shared literals
var configKeys = []string{
"server_url",
"listen_addr",
@@ -129,7 +127,6 @@ var configKeys = []string{
"oidc.issuer",
"oidc.client_id",
"oidc.client_secret",
"oidc.client_secret_path",
"oidc.scope",
"oidc.extra_params",
"oidc.allowed_domains",
@@ -213,12 +210,17 @@ var configDefaults = map[string]any{
"tuning.node_store_batch_size": defaultNodeStoreBatchSize,
"tuning.node_store_batch_timeout": "500ms",
"prefixes.allocation": string(IPAllocationStrategySequential),
"tls.acme.challenge_type": HTTP01ChallengeType,
"tls.acme.http_listen": ":http",
"tls.acme.cache_dir": "/var/lib/headscale/cache",
}
// removedKey is a key that once worked and is now rejected. In files Old
// matches the key and everything beneath it; for environment variables only
// the exact name, so the old dns_config.* leaves are listed too.
type removedKey struct{ Old, New, Since, Hint string }
// the exact name, so the old dns_config.* leaves are listed too. New holds
// the replacement keys, space separated; Value, when set, is what New takes.
// Hint is free text for what the other fields cannot say.
type removedKey struct{ Old, New, Value, Since, Hint string }
var removedKeys = []removedKey{
{Old: "acl_policy_path", New: "policy.path", Since: "0.30"},
@@ -236,7 +238,7 @@ var removedKeys = []removedKey{
{Old: "oidc.map_legacy_users", Since: "0.26"},
{Old: "randomize_client_port", Since: "0.29", Hint: `set "randomizeClientPort": true at the top level of the policy file, or grant the cap per node via a "nodeAttrs" entry`},
{Old: "oidc.expiry", New: "node.expiry", Since: "0.29"},
{Old: "ephemeral_node_inactivity_timeout", New: "node.ephemeral.inactivity_timeout", Since: "0.29"},
{Old: "ephemeral_node_inactivity_timeout", New: "node.ephemeral.inactivity_timeout", Since: "0.30"},
{Old: "tls_cert_path", New: "tls.cert_path", Since: "0.30"},
{Old: "tls_key_path", New: "tls.key_path", Since: "0.30"},
{Old: "tls_letsencrypt_hostname", New: "tls.acme.hostname", Since: "0.30"},
@@ -257,9 +259,9 @@ var removedKeys = []removedKey{
{Old: "db_pass", New: "database.postgres.pass", Since: "0.30"},
{Old: "db_ssl", New: "database.postgres.ssl", Since: "0.30"},
{Old: "private_key_path", New: "noise.private_key_path", Since: "0.23"},
{Old: "ip_prefixes", New: "prefixes.v4", Since: "0.23", Hint: "use prefixes.v4 and prefixes.v6"},
{Old: "ip_prefixes", New: "prefixes.v4 prefixes.v6", Since: "0.23"},
{Old: "log_level", New: "log.level", Since: "0.17"},
{Old: "json_logs", New: "log.format", Since: "0.30", Hint: `use log.format: "json"`},
{Old: "json_logs", New: "log.format", Value: "json", Since: "0.30"},
{Old: "tls_client_auth_mode", Since: "0.30"},
{Old: "node_update_check_interval", Since: "0.30"},
{Old: "changes_check_interval", Since: "0.30"},
@@ -269,4 +271,6 @@ var removedKeys = []removedKey{
{Old: "oidc.domain_map", Since: "0.13"},
{Old: "oidc.namespace", Since: "0.30"},
{Old: "oidc.user", Since: "0.30"},
{Old: "oidc.client_secret_path", New: "oidc.client_secret", Value: "file:<path>", Since: "0.30"},
{Old: "database.postgres.password_file", New: "database.postgres.pass", Value: "file:<path>", Since: "0.30"},
}
+135 -30
View File
@@ -12,6 +12,7 @@ import (
"time"
"github.com/go-viper/mapstructure/v2"
hsdns "github.com/juanfont/headscale/hscontrol/dns"
"github.com/knadh/koanf/parsers/json"
"github.com/knadh/koanf/parsers/yaml"
"github.com/knadh/koanf/providers/confmap"
@@ -363,32 +364,107 @@ func removedConfigKey(path string) (removedKey, bool) {
}
}
return removedKey{}, false
return removedProviderPath(path)
}
func (r removedKey) hint() string {
// removedProviderPath matches a DNS provider's <setting>_path, nested ones
// included, the file form "file:<path>" replaced. Provider settings have no
// fixed list, so the form is matched by name, for every provider, selected
// or not.
func removedProviderPath(path string) (removedKey, bool) {
const prefix = "dns.challenge.provider."
field, ok := strings.CutPrefix(path, prefix)
setting := field[strings.LastIndex(field, ".")+1:]
if !ok || !strings.HasSuffix(setting, "_path") || hsdns.IsProviderSetting(setting) {
return removedKey{}, false
}
return removedKey{
Old: path,
New: prefix + strings.TrimSuffix(field, "_path"),
Value: "file:<path>",
Since: "0.30",
}, true
}
// walkRemoved calls add for every removed key below path, an open map
// whose contents are otherwise the user's, and deletes it from m, so a
// caller that only warns loads the rest. labels says m's keys are names,
// such as acme-dns's registrations: data, kept as written and not checked.
func walkRemoved(path string, m map[string]any, labels bool, add func(path string, r removedKey)) {
for _, name := range slices.Sorted(maps.Keys(m)) {
key := name
if !labels {
key = strings.ToLower(name)
}
p := path + "." + key
if r, removed := removedConfigKey(p); removed && !labels {
add(p, r)
delete(m, name)
continue
}
if child, ok := m[name].(map[string]any); ok {
walkRemoved(p, child, !labels && hsdns.IsProviderMapSetting(key), add)
}
}
}
// hintAs says what replaces r, spelling each key with name and a key set
// to Value with assign, so one table serves files and the environment.
func (r removedKey) hintAs(name func(string) string, assign string) string {
switch {
case r.Hint != "":
return r.Hint
case r.Value != "":
return "use " + fmt.Sprintf(assign, name(r.New), r.Value)
case r.New != "":
return "use " + r.New
keys := strings.Fields(r.New)
for i, k := range keys {
keys[i] = name(k)
}
last := len(keys) - 1
if last == 0 {
return "use " + keys[0]
}
return "use " + strings.Join(keys[:last], ", ") + " and " + keys[last]
}
return fmt.Sprintf("remove %s; see the CHANGELOG for context", r.Old)
return fmt.Sprintf("remove %s; see the CHANGELOG for context", name(r.Old))
}
func (r removedKey) hint() string {
return r.hintAs(func(key string) string { return key }, `%s: %q`)
}
// envHint is hint for a variable. A removed block has no variable of its
// own, so it names the variables replacing its removed keys.
func (r removedKey) envHint() string {
var leaves []string
for _, l := range removedKeys {
if strings.HasPrefix(l.Old, r.Old+".") && l.New != "" {
leaves = append(leaves, l.New)
}
}
if len(leaves) > 0 {
r = removedKey{Old: r.Old, New: strings.Join(leaves, " ")}
}
return r.hintAs(configEnvName, "%s=%s")
}
func (r removedKey) reason(what, name string) string {
return fmt.Sprintf("configuration %s %s was removed in %s", what, name, r.Since)
}
func (r removedKey) envHint() string {
if r.New != "" && r.Hint == "" {
return "use " + configEnvName(r.New)
}
return r.hint()
}
// checkKeys adds an error for every removed or unknown key in the file.
func (s *configSource) checkKeys(v *configValidator, m map[string]any) {
leaf, branch := configKeySets()
@@ -412,15 +488,27 @@ func (s *configSource) checkKeys(v *configValidator, m map[string]any) {
Hint: r.hint(),
})
case isOpenMapPath(path):
// The contents are the user's.
// The contents are the user's, but for a removed form. A dotted
// key below the open map (provider.config) is walked from the
// map, so its contents get the role they have when nested.
root, below := path, child
if !slices.Contains(openMapKeys, path) {
parts := configPathParts(path)
root = strings.Join(parts[:len(parts)-1], ".")
below = map[string]any{parts[len(parts)-1]: val}
}
walkRemoved(root, below, false, func(p string, r removedKey) {
v.Add(&ConfigError{Reason: r.reason("key", p) + s.position(p), Hint: r.hint()})
})
case leaf[path] && !isMap:
case (leaf[path] || branch[path]) && isMap:
// Under a plain setting every child is unknown.
walk(path, child)
case branch[path]:
// The value is not shown: a misplaced block may hold secrets.
v.Add(&ConfigError{
Reason: fmt.Sprintf("configuration key %s must be a mapping%s", path, s.position(path)),
Current: []KV{{path, val}},
Reason: fmt.Sprintf("configuration key %s must be a mapping%s", path, s.position(path)),
})
default:
v.Add(&ConfigError{Reason: fmt.Sprintf("unknown configuration key %s%s", path, s.position(path))})
@@ -472,44 +560,57 @@ func (s *configSource) loadEnv(environ []string) error {
}
}
v := &configValidator{}
// Other software shares the prefix (a Kubernetes Service named
// headscale-db sets HEADSCALE_DB_PORT), so variables only ever warn.
for _, name := range slices.Sorted(maps.Keys(env)) {
if names[name] || reservedEnv(name) {
if names[name] {
continue
}
// Before reservedEnv, which spares every provider variable.
if r, ok := removedEnv(name); ok {
v.Add(&ConfigError{
Reason: r.reason("variable", name),
Hint: r.envHint(),
})
s.warnings = append(s.warnings, r.reason("variable", name)+"; "+r.envHint())
continue
}
if reservedEnv(name) {
continue
}
s.warnings = append(s.warnings, "unknown environment variable "+name)
}
if v.HasErrors() {
return v.Err()
}
// A variable for an open map replaces the file's map instead of merging
// into it. The value stays a raw string, which the cast accessors parse as
// JSON, unless a per-field variable (HEADSCALE_DNS_CHALLENGE_PROVIDER_NAME)
// has to be layered on top: then the JSON object is parsed here.
for key, val := range openLayer {
// JSON, unless the JSON object held a removed form, dropped here, or a
// per-field variable (HEADSCALE_DNS_CHALLENGE_PROVIDER_NAME) has to be
// layered on top: then the parsed object is set.
for _, key := range slices.Sorted(maps.Keys(openLayer)) {
val := openLayer[key]
s.k.Delete(key)
var parsed map[string]any
dropped := false
// A failed decode may still have filled part of parsed: never used.
decoded := stdjson.Unmarshal([]byte(val), &parsed) == nil && parsed != nil
if decoded {
// The hint names keys: inside the JSON they are keys, not variables.
name := configEnvName(key)
walkRemoved(key, parsed, false, func(p string, r removedKey) {
s.warnings = append(s.warnings, r.reason("key", p+" in "+name)+"; "+r.hint())
dropped = true
})
}
shared := slices.ContainsFunc(slices.Collect(maps.Keys(layer)), func(k string) bool {
return strings.HasPrefix(k, key+".")
})
var v any = val
if shared && stdjson.Unmarshal([]byte(val), &parsed) == nil && parsed != nil {
if decoded && (dropped || shared) {
v = parsed
}
@@ -543,6 +644,10 @@ func removedEnv(name string) (removedKey, bool) {
}
}
if field, ok := strings.CutPrefix(name, configEnvName("dns.challenge.provider")+"_"); ok {
return removedProviderPath("dns.challenge.provider." + strings.ToLower(field))
}
return removedKey{}, false
}
+68 -47
View File
@@ -2,6 +2,7 @@ package types
import (
"cmp"
"errors"
"go/ast"
"go/parser"
"go/token"
@@ -61,9 +62,9 @@ func TestConfigSource(t *testing.T) {
errs: []string{"grpc_listen_addr", "bogus"},
},
{
name: "removed env",
env: []string{"HEADSCALE_EPHEMERAL_NODE_INACTIVITY_TIMEOUT=30m"},
errs: []string{"HEADSCALE_EPHEMERAL_NODE_INACTIVITY_TIMEOUT", "HEADSCALE_NODE_EPHEMERAL_INACTIVITY_TIMEOUT"},
name: "removed env warns",
env: []string{"HEADSCALE_EPHEMERAL_NODE_INACTIVITY_TIMEOUT=30m"},
warns: []string{"configuration variable HEADSCALE_EPHEMERAL_NODE_INACTIVITY_TIMEOUT was removed in 0.30; use HEADSCALE_NODE_EPHEMERAL_INACTIVITY_TIMEOUT"},
},
{
name: "unknown env warns",
@@ -78,6 +79,12 @@ func TestConfigSource(t *testing.T) {
"HEADSCALE_INTEGRATION_X=1", "HEADSCALE_UPDATE_GOLDEN=1",
},
},
{
// What Kubernetes sets for a Service named headscale-db.
name: "service variable named like a removed key warns",
env: []string{"HEADSCALE_DB_PORT=tcp://10.0.0.5:5432"},
warns: []string{"configuration variable HEADSCALE_DB_PORT was removed in 0.30; use HEADSCALE_DATABASE_POSTGRES_PORT"},
},
{
name: "env shared with a removed key still sets the new key",
env: []string{"HEADSCALE_LOG_LEVEL=debug", "HEADSCALE_TLS_CERT_PATH=/c"},
@@ -242,14 +249,22 @@ func TestConfigSource(t *testing.T) {
},
},
{
name: "removed dns_config env",
name: "removed dns_config env warns",
env: []string{"HEADSCALE_DNS_CONFIG_MAGIC_DNS=false", "HEADSCALE_DNS_CONFIG_NAMESERVERS=1.1.1.1"},
errs: []string{"variable HEADSCALE_DNS_CONFIG_MAGIC_DNS was removed", "HEADSCALE_DNS_CONFIG_NAMESERVERS", "use HEADSCALE_DNS_MAGIC_DNS"},
warns: []string{
"variable HEADSCALE_DNS_CONFIG_MAGIC_DNS was removed in 0.30; use HEADSCALE_DNS_MAGIC_DNS",
"variable HEADSCALE_DNS_CONFIG_NAMESERVERS was removed in 0.30; use HEADSCALE_DNS_NAMESERVERS_GLOBAL",
},
},
{
name: "removed env names the new variable",
env: []string{"HEADSCALE_EPHEMERAL_NODE_INACTIVITY_TIMEOUT=30m"},
errs: []string{"variable HEADSCALE_EPHEMERAL_NODE_INACTIVITY_TIMEOUT was removed in 0.29", "use HEADSCALE_NODE_EPHEMERAL_INACTIVITY_TIMEOUT"},
name: "removed block env names the variables replacing it",
env: []string{`HEADSCALE_DNS_CONFIG={"magic_dns":true}`, "HEADSCALE_RANDOMIZE_CLIENT_PORT=true"},
warns: []string{
"variable HEADSCALE_DNS_CONFIG was removed in 0.30; use HEADSCALE_DNS_MAGIC_DNS, HEADSCALE_DNS_BASE_DOMAIN, " +
"HEADSCALE_DNS_OVERRIDE_LOCAL_DNS, HEADSCALE_DNS_NAMESERVERS_GLOBAL, HEADSCALE_DNS_NAMESERVERS_SPLIT, " +
"HEADSCALE_DNS_SEARCH_DOMAINS and HEADSCALE_DNS_EXTRA_RECORDS",
`variable HEADSCALE_RANDOMIZE_CLIENT_PORT was removed in 0.29; set "randomizeClientPort": true at the top level of the policy file`,
},
},
{
name: "exact reserved names do not exempt near misses",
@@ -391,15 +406,11 @@ var parityRejected = func() map[string][]string {
"nixos-nixpkgs": {
"tls_letsencrypt_cache_dir", "tls_letsencrypt_challenge_type", "tls_letsencrypt_hostname", "tls_letsencrypt_listen",
},
"env-legacy-ignored": {
"HEADSCALE_DATABASE_GORM_PREPARE_STMT", "HEADSCALE_DB_TYPE", "HEADSCALE_DNS_CONFIG_MAGIC_DNS",
"HEADSCALE_EPHEMERAL_NODE_INACTIVITY_TIMEOUT", "HEADSCALE_PRIVATE_KEY_PATH",
},
"env-legacy-removed": {"HEADSCALE_ACL_POLICY_PATH", "HEADSCALE_OIDC_EXPIRY", "HEADSCALE_RANDOMIZE_CLIENT_PORT"},
"file-everything": {"oidc.client_secret_path"},
}
}()
var removedKeyInReason = regexp.MustCompile(`configuration (?:key|variable) (\S+) was removed|unknown configuration key (\S+)`)
var removedKeyInReason = regexp.MustCompile(`configuration key (\S+) was removed|unknown configuration key (\S+)`)
// TestConfigSourceParity checks the source against viper on every Phase-0
// fixture: same set-ness and same value for each coercion.
@@ -412,11 +423,8 @@ func TestConfigSourceParity(t *testing.T) {
for _, tt := range rows {
t.Run(tt.name, func(t *testing.T) {
viper.Reset()
t.Cleanup(viper.Reset)
dir := stageCompat(t, tt.file, tt.envFile)
require.NoError(t, LoadConfig(dir, false))
loadViper(t, dir)
s, err := newConfigSource(dir, false, os.Environ())
@@ -466,9 +474,7 @@ func TestConfigSourceUnmarshalParity(t *testing.T) {
dir := t.TempDir()
require.NoError(t, os.WriteFile(filepath.Join(dir, "config.yaml"), []byte(content), 0o600))
viper.Reset()
t.Cleanup(viper.Reset)
require.NoError(t, LoadConfig(dir, false))
loadViper(t, dir)
var want []rec
@@ -485,9 +491,6 @@ func TestConfigSourceUnmarshalParity(t *testing.T) {
}
}
// pendingKeys are read by the viper loader but replaced by file: secrets later.
var pendingKeys = map[string]bool{"oidc.client_secret_path": true}
func TestConfigKeysComplete(t *testing.T) {
read := map[string]bool{}
@@ -501,23 +504,13 @@ func TestConfigKeysComplete(t *testing.T) {
return true
}
var name string
switch fn := call.Fun.(type) {
case *ast.SelectorExpr:
if obj, ok := fn.X.(*ast.Ident); !ok || obj.Name != "viper" {
return true
}
name = fn.Sel.Name
case *ast.Ident:
name = fn.Name
default:
// Every src accessor takes the key first.
fn, ok := call.Fun.(*ast.SelectorExpr)
if !ok {
return true
}
if !strings.HasPrefix(name, "Get") && name != "IsSet" && name != "InConfig" &&
name != "UnmarshalKey" && name != "tlsKey" {
if obj, ok := fn.X.(*ast.Ident); !ok || obj.Name != "src" {
return true
}
@@ -532,23 +525,17 @@ func TestConfigKeysComplete(t *testing.T) {
})
}
removed := map[string]bool{}
for _, r := range removedKeys {
removed[r.Old] = true
}
all := slices.Concat(configKeys, openMapKeys)
for key := range read {
ok := slices.Contains(all, key) || removed[key] || key == "dns" ||
strings.HasPrefix(key, "dns.challenge.provider")
ok := slices.Contains(all, key) || strings.HasPrefix(key, "dns.challenge.provider")
assert.Truef(t, ok, "%s is read but missing from the key tables", key)
}
for _, key := range configKeys {
_, hasDefault := configDefaults[key]
assert.Truef(t, read[key] || hasDefault || pendingKeys[key], "%s is listed but never read", key)
assert.Truef(t, read[key] || hasDefault, "%s is listed but never read", key)
}
for key := range configDefaults {
@@ -565,11 +552,28 @@ func TestConfigKeysComplete(t *testing.T) {
}
}
// loadViper loads the config file in dir as the viper loader did, for the
// parity checks.
func loadViper(t *testing.T, dir string) {
t.Helper()
viper.Reset()
t.Cleanup(viper.Reset)
require.NoError(t, LoadConfig(dir, false))
viper.SetConfigName("config")
viper.AddConfigPath(dir)
viper.SetEnvPrefix("headscale")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()
for k, v := range configDefaults {
viper.SetDefault(k, v)
}
err := viper.ReadInConfig()
if _, ok := errors.AsType[viper.ConfigFileNotFoundError](err); !ok {
require.NoError(t, err)
}
}
// TestConfigSourceDottedOverlap reloads the file each time: map iteration
@@ -675,6 +679,23 @@ func TestConfigSourceDottedNoOverlap(t *testing.T) {
}
}
// TestConfigSourceShapeErrorsHideValues: a block in the wrong shape may hold
// credentials, so the error names the key without its value.
func TestConfigSourceShapeErrorsHideValues(t *testing.T) {
for name, file := range map[string]string{
"list under oidc": "oidc:\n - client_secret: marker-secret\n",
"scalar under postgres": "database:\n postgres: \"pass: marker-secret\"\n",
"scalar under oidc.pkce": "oidc:\n pkce: marker-secret\n",
"list under database.sqlite": "database:\n sqlite: [marker-secret]\n",
} {
t.Run(name, func(t *testing.T) {
_, err := newConfigSource(writeConfig(t, "config.yaml", file), true, nil)
require.ErrorContains(t, err, "must be a mapping")
assert.NotContains(t, err.Error(), "marker-secret")
})
}
}
func TestConfigSourceStrictBeforeExpansion(t *testing.T) {
dir := t.TempDir()
require.NoError(t, os.WriteFile(filepath.Join(dir, "config.yaml"), []byte("log:\n format:\n typo: json\nlog.format: json\n"), 0o600))
File diff suppressed because it is too large. Load diff
+3 -8
View File
@@ -2,8 +2,6 @@ package types
import (
"testing"
"github.com/spf13/viper"
)
// TestDerpConfigSkipsMalformedURL ensures a malformed derp.urls entry is
@@ -11,15 +9,12 @@ import (
// nil *url.URL that url.Parse returns on error, which crashed the server at
// startup.
func TestDerpConfigSkipsMalformedURL(t *testing.T) {
viper.Reset()
defer viper.Reset()
viper.Set("derp.urls", []string{
useConfig(t, map[string]any{"derp.urls": []string{
"https://controlplane.tailscale.com/derpmap/default",
"://bad",
})
}})
cfg := derpConfig()
cfg := derpConfig("")
if len(cfg.URLs) != 1 {
t.Fatalf("expected the malformed derp.urls entry to be skipped, got %d urls: %v",
+5 -9
View File
@@ -5,8 +5,6 @@ import (
"fmt"
"net"
"strconv"
"github.com/spf13/viper"
)
var errEmptyListenAddr = errors.New("address is empty")
@@ -106,21 +104,19 @@ func validateListenerCollisions(v *configValidator) {
active bool
}
listenAddr := viper.GetString("listen_addr")
grpcAddr := viper.GetString("grpc_listen_addr")
metricsAddr := viper.GetString("metrics_listen_addr")
acmeAddr := tlsKey("tls.acme.http_listen")
listenAddr := src.String("listen_addr")
metricsAddr := src.String("metrics_listen_addr")
acmeAddr := src.String("tls.acme.http_listen")
listeners := []spec{
{key: "listen_addr", addr: listenAddr, active: listenAddr != ""},
{key: "grpc_listen_addr", addr: grpcAddr, active: grpcAddr != ""},
{key: "metrics_listen_addr", addr: metricsAddr, active: metricsAddr != ""},
{
key: "tls.acme.http_listen",
addr: acmeAddr,
active: acmeAddr != "" &&
tlsKey("tls.acme.hostname") != "" &&
tlsKey("tls.acme.challenge_type") == HTTP01ChallengeType,
src.String("tls.acme.hostname") != "" &&
src.String("tls.acme.challenge_type") == HTTP01ChallengeType,
},
}
+2 -6
View File
@@ -7,7 +7,6 @@ import (
"syscall"
"testing"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -82,15 +81,12 @@ func TestValidateListenerCollisions_BlamesParseFailure(t *testing.T) {
good string // sibling key with a valid addr
badAddr string
}{
{"bad-listen_addr", "listen_addr", "grpc_listen_addr", "garbage"},
{"bad-grpc_listen_addr", "grpc_listen_addr", "listen_addr", "also-garbage"},
{"bad-listen_addr", "listen_addr", "metrics_listen_addr", "garbage"},
{"bad-metrics_listen_addr", "metrics_listen_addr", "listen_addr", "no-port"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
viper.Reset()
viper.Set(tt.bad, tt.badAddr)
viper.Set(tt.good, ":9999")
useConfig(t, map[string]any{tt.bad: tt.badAddr, tt.good: ":9999"})
v := &configValidator{}
validateListenerCollisions(v)
+68
View File
@@ -0,0 +1,68 @@
package types
import (
"errors"
"fmt"
"os"
"strings"
hsdns "github.com/juanfont/headscale/hscontrol/dns"
)
var errSecretEmpty = errors.New("file is empty")
// resolveSecret returns value, or the trimmed contents of the file named
// by "file:<path>" (Tailscale's form), which keeps the secret out of the
// config and the environment. Variables in the path are expanded so a
// systemd credential can be named by ${CREDENTIALS_DIRECTORY}.
func resolveSecret(key, value string) (string, error) {
path, ok := strings.CutPrefix(value, "file:")
if !ok {
return value, nil
}
path = os.ExpandEnv(path)
b, err := os.ReadFile(path)
if err != nil {
return "", fmt.Errorf("%s: %w", key, err)
}
// An empty file is a credential that was not written, not a choice.
secret := strings.TrimSpace(string(b))
if secret == "" {
return "", fmt.Errorf("%s: %s: %w", key, path, errSecretEmpty)
}
return secret, nil
}
// keepSecret leaves a file: secret unread, for checking a config without
// reading the files it names; checks that need the secret skip it.
func keepSecret(_, value string) (string, error) {
if strings.HasPrefix(value, "file:") {
return value, hsdns.ErrSecretUnread
}
return value, nil
}
// configSecret resolves the secret setting key, recording a failure in v.
func configSecret(v *configValidator, resolve func(key, value string) (string, error), key, value string) string {
secret, err := resolve(key, value)
if errors.Is(err, hsdns.ErrSecretUnread) {
return value
}
if err != nil {
v.Add(&ConfigError{
Reason: key + " cannot be read",
Current: []KV{{key, value}},
Detail: err.Error(),
Hint: "ensure the file exists, is not empty and is readable by the user running headscale",
Cause: err,
})
}
return secret
}
+46
View File
@@ -0,0 +1,46 @@
package types
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestResolveSecret(t *testing.T) {
dir := t.TempDir()
require.NoError(t, os.WriteFile(filepath.Join(dir, "s"), []byte(" from-file\n"), 0o600))
require.NoError(t, os.WriteFile(filepath.Join(dir, "empty"), []byte(" \n"), 0o600))
t.Setenv("SECRET_DIR", dir)
tests := []struct {
name string
value string
want string
wantErr string
}{
{name: "literal", value: "hunter2", want: "hunter2"},
{name: "empty", value: "", want: ""},
{name: "file is read and trimmed", value: "file:" + filepath.Join(dir, "s"), want: "from-file"},
{name: "env in path is expanded", value: "file:${SECRET_DIR}/s", want: "from-file"},
{name: "missing file names the key", value: "file:" + filepath.Join(dir, "missing"), wantErr: "no such file or directory"},
{name: "empty file", value: "file:" + filepath.Join(dir, "empty"), wantErr: "is empty"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := resolveSecret("oidc.client_secret", tt.value)
if tt.wantErr != "" {
require.ErrorContains(t, err, tt.wantErr)
require.ErrorContains(t, err, "oidc.client_secret: ")
return
}
require.NoError(t, err)
assert.Equal(t, tt.want, got)
})
}
}
+169
View File
@@ -0,0 +1,169 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "10.0.0.0/8",
"PrefixV6": null,
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"Log": {
"Format": "",
"Level": "debug"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "sqlite3",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 0,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "/var/lib/headscale/db.sqlite",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "",
"Port": 0,
"Name": "",
"User": "",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": false,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 0,
"ServerRegionCode": "",
"ServerRegionName": "",
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
}
},
"TailcfgDNSConfig": {},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/var/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": null,
"AllowedUsers": null,
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 0,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
},
"warnings": [
"\n################################################################\n### __ __ _ _ ###\n### \\ \\ / / (_) | | ###\n### \\ \\ /\\ / /_ _ _ __ _ __ _ _ __ __ _| | ###\n### \\ \\/ \\/ / _` | '__| '_ \\| | '_ \\ / _` | | ###\n### \\ /\\ / (_| | | | | | | | | | | (_| |_| ###\n### \\/ \\/ \\__,_|_| |_| |_|_|_| |_|\\__, (_) ###\n### __/ | ###\n### |___/ ###\n################################################################\n### ###\n### You have overridden the default Headscale IP prefixes ###\n### with a range outside of the standard CGNAT and/or ULA ###\n### ranges. This is NOT a supported configuration. ###\n### ###\n### Using subsets of the default ranges (100.64.0.0/10 for ###\n### IPv4, fd7a:115c:a1e0::/48 for IPv6) is fine. Using ###\n### ranges outside of these will cause undefined behaviour ###\n### as the Tailscale client is NOT designed to operate on ###\n### any other ranges. ###\n### ###\n### Please revert your prefixes to subsets of the standard ###\n### ranges as described in the example configuration. ###\n### ###\n### Any issue raised using a range outside of the ###\n### supported range will be labelled as wontfix ###\n### and closed. ###\n### ###\n################################################################"
],
"log_errors": [
"Could not parse log format: xml. Valid choices are 'json' or 'text'",
"Failed to parse url, ignoring..."
]
}
+21
View File
@@ -0,0 +1,21 @@
# Input today's loader accepts but mangles or ignores.
server_url: https://hs.example.com
noise:
private_key_path: /var/lib/headscale/noise.key
prefixes:
v4: 10.0.0.0/8
database:
type: sqlite
sqlite:
path: /var/lib/headscale/db.sqlite
dns:
magic_dns: false
override_local_dns: false
log:
level: verbose
format: xml
tuning:
notifier_send_timeout: abc
derp:
urls:
- "://not-a-url"
+1 -168
View File
@@ -1,170 +1,3 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "10.0.0.0/8",
"PrefixV6": null,
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"Log": {
"Format": "",
"Level": "debug"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "sqlite3",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 0,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "/var/lib/headscale/db.sqlite",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "",
"Port": 0,
"Name": "",
"User": "",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": false,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 0,
"ServerRegionCode": "",
"ServerRegionName": "",
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
}
},
"TailcfgDNSConfig": {},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/var/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": null,
"AllowedUsers": null,
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 0,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
},
"warnings": [
"configuration key \"ephemeral_node_inactivity_timeout\" is deprecated; use \"node.ephemeral.inactivity_timeout\" instead",
"\n################################################################\n### __ __ _ _ ###\n### \\ \\ / / (_) | | ###\n### \\ \\ /\\ / /_ _ _ __ _ __ _ _ __ __ _| | ###\n### \\ \\/ \\/ / _` | '__| '_ \\| | '_ \\ / _` | | ###\n### \\ /\\ / (_| | | | | | | | | | | (_| |_| ###\n### \\/ \\/ \\__,_|_| |_| |_|_|_| |_|\\__, (_) ###\n### __/ | ###\n### |___/ ###\n################################################################\n### ###\n### You have overridden the default Headscale IP prefixes ###\n### with a range outside of the standard CGNAT and/or ULA ###\n### ranges. This is NOT a supported configuration. ###\n### ###\n### Using subsets of the default ranges (100.64.0.0/10 for ###\n### IPv4, fd7a:115c:a1e0::/48 for IPv6) is fine. Using ###\n### ranges outside of these will cause undefined behaviour ###\n### as the Tailscale client is NOT designed to operate on ###\n### any other ranges. ###\n### ###\n### Please revert your prefixes to subsets of the standard ###\n### ranges as described in the example configuration. ###\n### ###\n### Any issue raised using a range outside of the ###\n### supported range will be labelled as wontfix ###\n### and closed. ###\n### ###\n################################################################"
],
"log_errors": [
"Could not parse log format: xml. Valid choices are 'json' or 'text'",
"Failed to parse url, ignoring..."
]
"error": "Fatal config error: unknown configuration key dns.magic_dsn ($DIR/config.yaml:13:3)\n\nFatal config error: configuration key ephemeral_node_inactivity_timeout was removed in 0.30 ($DIR/config.yaml:23:1)\n hint: use node.ephemeral.inactivity_timeout\n"
}
+5 -3
View File
@@ -161,8 +161,10 @@
},
"warnings": [
"no config file found, using defaults",
"configuration key \"dns_config.magic_dns\" is deprecated; use \"dns.magic_dns\" instead",
"configuration key \"ephemeral_node_inactivity_timeout\" is deprecated; use \"node.ephemeral.inactivity_timeout\" instead",
"configuration key \"database.gorm.prepare_stmt\" is ignored"
"configuration variable HEADSCALE_DATABASE_GORM_PREPARE_STMT was removed in 0.30; remove HEADSCALE_DATABASE_GORM_PREPARE_STMT; see the CHANGELOG for context",
"configuration variable HEADSCALE_DB_TYPE was removed in 0.30; use HEADSCALE_DATABASE_TYPE",
"configuration variable HEADSCALE_DNS_CONFIG_MAGIC_DNS was removed in 0.30; use HEADSCALE_DNS_MAGIC_DNS",
"configuration variable HEADSCALE_EPHEMERAL_NODE_INACTIVITY_TIMEOUT was removed in 0.30; use HEADSCALE_NODE_EPHEMERAL_INACTIVITY_TIMEOUT",
"configuration variable HEADSCALE_PRIVATE_KEY_PATH was removed in 0.23; use HEADSCALE_NOISE_PRIVATE_KEY_PATH"
]
}
+165 -3
View File
@@ -1,6 +1,168 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": null,
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"Log": {
"Format": "text",
"Level": "info"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "sqlite3",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 0,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "/var/lib/headscale/db.sqlite",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "",
"Port": 0,
"Name": "",
"User": "",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": false,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 0,
"ServerRegionCode": "",
"ServerRegionName": "",
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
}
},
"TailcfgDNSConfig": {},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/var/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": null,
"AllowedUsers": null,
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 800000000,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
},
"warnings": [
"no config file found, using defaults"
],
"error": "Fatal config error: configuration key acl_policy_path has been removed; use policy.path instead\n current: acl_policy_path: \"/etc/headscale/acl.hujson\"\n hint: remove acl_policy_path and set policy.path\n\nFatal config error: configuration key randomize_client_port has been removed\n current: randomize_client_port: \"true\"\n hint: Set \"randomizeClientPort\": true at the top level of your policy file (see policy.path / policy.mode), or grant the cap per-node via a \"nodeAttrs\" entry. See CHANGELOG.md (BREAKING / Configuration).\n\nFatal config error: configuration key oidc.expiry has been removed; use node.expiry instead\n current: oidc.expiry: \"1d\"\n hint: remove oidc.expiry and set node.expiry\n"
"no config file found, using defaults",
"configuration variable HEADSCALE_ACL_POLICY_PATH was removed in 0.30; use HEADSCALE_POLICY_PATH",
"configuration variable HEADSCALE_OIDC_EXPIRY was removed in 0.29; use HEADSCALE_NODE_EXPIRY",
"configuration variable HEADSCALE_RANDOMIZE_CLIENT_PORT was removed in 0.29; set \"randomizeClientPort\": true at the top level of the policy file, or grant the cap per node via a \"nodeAttrs\" entry"
]
}
-1
View File
@@ -160,7 +160,6 @@
}
},
"secrets": {
"cli.api_key": "marker-cli-api-key",
"database.postgres.pass": "marker-postgres-pass",
"oidc.client_secret": "marker-oidc-secret"
},
+1 -5
View File
@@ -1,7 +1,3 @@
{
"warnings": [
"configuration key \"ephemeral_node_inactivity_timeout\" is deprecated; use \"node.ephemeral.inactivity_timeout\" instead",
"configuration key \"database.gorm.prepare_stmt\" is ignored"
],
"error": "Fatal config error: configuration key dns.use_username_in_magic_dns has been removed\n current: dns.use_username_in_magic_dns: false\n hint: remove dns.use_username_in_magic_dns; see the CHANGELOG for context\n\nFatal config error: configuration key randomize_client_port has been removed\n current: randomize_client_port: false\n hint: Set \"randomizeClientPort\": true at the top level of your policy file (see policy.path / policy.mode), or grant the cap per-node via a \"nodeAttrs\" entry. See CHANGELOG.md (BREAKING / Configuration).\n"
"error": "Fatal config error: configuration key acme_email was removed in 0.30 ($DIR/config.yaml:200:1)\n hint: use tls.acme.email\n\nFatal config error: configuration key acme_url was removed in 0.30 ($DIR/config.yaml:197:1)\n hint: use tls.acme.url\n\nFatal config error: configuration key database.gorm.prepare_stmt was removed in 0.30 ($DIR/config.yaml:152:5)\n hint: remove database.gorm.prepare_stmt; see the CHANGELOG for context\n\nFatal config error: configuration key dns.use_username_in_magic_dns was removed in 0.24 ($DIR/config.yaml:317:3)\n hint: remove dns.use_username_in_magic_dns; see the CHANGELOG for context\n\nFatal config error: configuration key ephemeral_node_inactivity_timeout was removed in 0.30 ($DIR/config.yaml:138:1)\n hint: use node.ephemeral.inactivity_timeout\n\nFatal config error: configuration key grpc_allow_insecure was removed in 0.30 ($DIR/config.yaml:41:1)\n hint: remove grpc_allow_insecure; see the CHANGELOG for context\n\nFatal config error: configuration key grpc_listen_addr was removed in 0.30 ($DIR/config.yaml:35:1)\n hint: remove grpc_listen_addr; see the CHANGELOG for context\n\nFatal config error: configuration key randomize_client_port was removed in 0.29 ($DIR/config.yaml:387:1)\n hint: set \"randomizeClientPort\": true at the top level of the policy file, or grant the cap per node via a \"nodeAttrs\" entry\n\nFatal config error: configuration key tls_cert_path was removed in 0.30 ($DIR/config.yaml:220:1)\n hint: use tls.cert_path\n\nFatal config error: configuration key tls_key_path was removed in 0.30 ($DIR/config.yaml:221:1)\n hint: use tls.key_path\n\nFatal config error: configuration key tls_letsencrypt_cache_dir was removed in 0.30 ($DIR/config.yaml:208:1)\n hint: use tls.acme.cache_dir\n\nFatal config error: configuration key tls_letsencrypt_challenge_type was removed in 0.30 ($DIR/config.yaml:213:1)\n hint: use tls.acme.challenge_type\n\nFatal config error: configuration key tls_letsencrypt_hostname was removed in 0.30 ($DIR/config.yaml:203:1)\n hint: use tls.acme.hostname\n\nFatal config error: configuration key tls_letsencrypt_listen was removed in 0.30 ($DIR/config.yaml:217:1)\n hint: use tls.acme.http_listen\n"
}
+1 -5
View File
@@ -1,7 +1,3 @@
{
"warnings": [
"configuration key \"ephemeral_node_inactivity_timeout\" is deprecated; use \"node.ephemeral.inactivity_timeout\" instead",
"configuration key \"database.gorm.prepare_stmt\" is ignored"
],
"error": "Fatal config error: configuration key randomize_client_port has been removed\n current: randomize_client_port: false\n hint: Set \"randomizeClientPort\": true at the top level of your policy file (see policy.path / policy.mode), or grant the cap per-node via a \"nodeAttrs\" entry. See CHANGELOG.md (BREAKING / Configuration).\n"
"error": "Fatal config error: configuration key acme_email was removed in 0.30 ($DIR/config.yaml:205:1)\n hint: use tls.acme.email\n\nFatal config error: configuration key acme_url was removed in 0.30 ($DIR/config.yaml:202:1)\n hint: use tls.acme.url\n\nFatal config error: configuration key database.gorm.prepare_stmt was removed in 0.30 ($DIR/config.yaml:152:5)\n hint: remove database.gorm.prepare_stmt; see the CHANGELOG for context\n\nFatal config error: configuration key ephemeral_node_inactivity_timeout was removed in 0.30 ($DIR/config.yaml:138:1)\n hint: use node.ephemeral.inactivity_timeout\n\nFatal config error: configuration key grpc_allow_insecure was removed in 0.30 ($DIR/config.yaml:41:1)\n hint: remove grpc_allow_insecure; see the CHANGELOG for context\n\nFatal config error: configuration key grpc_listen_addr was removed in 0.30 ($DIR/config.yaml:35:1)\n hint: remove grpc_listen_addr; see the CHANGELOG for context\n\nFatal config error: configuration key randomize_client_port was removed in 0.29 ($DIR/config.yaml:404:1)\n hint: set \"randomizeClientPort\": true at the top level of the policy file, or grant the cap per node via a \"nodeAttrs\" entry\n\nFatal config error: configuration key tls_cert_path was removed in 0.30 ($DIR/config.yaml:225:1)\n hint: use tls.cert_path\n\nFatal config error: configuration key tls_key_path was removed in 0.30 ($DIR/config.yaml:226:1)\n hint: use tls.key_path\n\nFatal config error: configuration key tls_letsencrypt_cache_dir was removed in 0.30 ($DIR/config.yaml:213:1)\n hint: use tls.acme.cache_dir\n\nFatal config error: configuration key tls_letsencrypt_challenge_type was removed in 0.30 ($DIR/config.yaml:218:1)\n hint: use tls.acme.challenge_type\n\nFatal config error: configuration key tls_letsencrypt_hostname was removed in 0.30 ($DIR/config.yaml:208:1)\n hint: use tls.acme.hostname\n\nFatal config error: configuration key tls_letsencrypt_listen was removed in 0.30 ($DIR/config.yaml:222:1)\n hint: use tls.acme.http_listen\n"
}
+1 -5
View File
@@ -1,7 +1,3 @@
{
"warnings": [
"configuration key \"ephemeral_node_inactivity_timeout\" is deprecated; use \"node.ephemeral.inactivity_timeout\" instead",
"configuration key \"database.gorm.prepare_stmt\" is ignored"
],
"error": "Fatal config error: configuration key randomize_client_port has been removed\n current: randomize_client_port: false\n hint: Set \"randomizeClientPort\": true at the top level of your policy file (see policy.path / policy.mode), or grant the cap per-node via a \"nodeAttrs\" entry. See CHANGELOG.md (BREAKING / Configuration).\n"
"error": "Fatal config error: configuration key acme_email was removed in 0.30 ($DIR/config.yaml:205:1)\n hint: use tls.acme.email\n\nFatal config error: configuration key acme_url was removed in 0.30 ($DIR/config.yaml:202:1)\n hint: use tls.acme.url\n\nFatal config error: configuration key database.gorm.prepare_stmt was removed in 0.30 ($DIR/config.yaml:152:5)\n hint: remove database.gorm.prepare_stmt; see the CHANGELOG for context\n\nFatal config error: configuration key ephemeral_node_inactivity_timeout was removed in 0.30 ($DIR/config.yaml:138:1)\n hint: use node.ephemeral.inactivity_timeout\n\nFatal config error: configuration key grpc_allow_insecure was removed in 0.30 ($DIR/config.yaml:41:1)\n hint: remove grpc_allow_insecure; see the CHANGELOG for context\n\nFatal config error: configuration key grpc_listen_addr was removed in 0.30 ($DIR/config.yaml:35:1)\n hint: remove grpc_listen_addr; see the CHANGELOG for context\n\nFatal config error: configuration key randomize_client_port was removed in 0.29 ($DIR/config.yaml:404:1)\n hint: set \"randomizeClientPort\": true at the top level of the policy file, or grant the cap per node via a \"nodeAttrs\" entry\n\nFatal config error: configuration key tls_cert_path was removed in 0.30 ($DIR/config.yaml:225:1)\n hint: use tls.cert_path\n\nFatal config error: configuration key tls_key_path was removed in 0.30 ($DIR/config.yaml:226:1)\n hint: use tls.key_path\n\nFatal config error: configuration key tls_letsencrypt_cache_dir was removed in 0.30 ($DIR/config.yaml:213:1)\n hint: use tls.acme.cache_dir\n\nFatal config error: configuration key tls_letsencrypt_challenge_type was removed in 0.30 ($DIR/config.yaml:218:1)\n hint: use tls.acme.challenge_type\n\nFatal config error: configuration key tls_letsencrypt_hostname was removed in 0.30 ($DIR/config.yaml:208:1)\n hint: use tls.acme.hostname\n\nFatal config error: configuration key tls_letsencrypt_listen was removed in 0.30 ($DIR/config.yaml:222:1)\n hint: use tls.acme.http_listen\n"
}
+1 -5
View File
@@ -1,7 +1,3 @@
{
"warnings": [
"configuration key \"ephemeral_node_inactivity_timeout\" is deprecated; use \"node.ephemeral.inactivity_timeout\" instead",
"configuration key \"database.gorm.prepare_stmt\" is ignored"
],
"error": "Fatal config error: configuration key randomize_client_port has been removed\n current: randomize_client_port: false\n hint: Set \"randomizeClientPort\": true at the top level of your policy file (see policy.path / policy.mode), or grant the cap per-node via a \"nodeAttrs\" entry. See CHANGELOG.md (BREAKING / Configuration).\n"
"error": "Fatal config error: configuration key acme_email was removed in 0.30 ($DIR/config.yaml:201:1)\n hint: use tls.acme.email\n\nFatal config error: configuration key acme_url was removed in 0.30 ($DIR/config.yaml:198:1)\n hint: use tls.acme.url\n\nFatal config error: configuration key database.gorm.prepare_stmt was removed in 0.30 ($DIR/config.yaml:148:5)\n hint: remove database.gorm.prepare_stmt; see the CHANGELOG for context\n\nFatal config error: configuration key ephemeral_node_inactivity_timeout was removed in 0.30 ($DIR/config.yaml:134:1)\n hint: use node.ephemeral.inactivity_timeout\n\nFatal config error: configuration key grpc_allow_insecure was removed in 0.30 ($DIR/config.yaml:39:1)\n hint: remove grpc_allow_insecure; see the CHANGELOG for context\n\nFatal config error: configuration key grpc_listen_addr was removed in 0.30 ($DIR/config.yaml:33:1)\n hint: remove grpc_listen_addr; see the CHANGELOG for context\n\nFatal config error: configuration key randomize_client_port was removed in 0.29 ($DIR/config.yaml:391:1)\n hint: set \"randomizeClientPort\": true at the top level of the policy file, or grant the cap per node via a \"nodeAttrs\" entry\n\nFatal config error: configuration key tls_cert_path was removed in 0.30 ($DIR/config.yaml:221:1)\n hint: use tls.cert_path\n\nFatal config error: configuration key tls_key_path was removed in 0.30 ($DIR/config.yaml:222:1)\n hint: use tls.key_path\n\nFatal config error: configuration key tls_letsencrypt_cache_dir was removed in 0.30 ($DIR/config.yaml:209:1)\n hint: use tls.acme.cache_dir\n\nFatal config error: configuration key tls_letsencrypt_challenge_type was removed in 0.30 ($DIR/config.yaml:214:1)\n hint: use tls.acme.challenge_type\n\nFatal config error: configuration key tls_letsencrypt_hostname was removed in 0.30 ($DIR/config.yaml:204:1)\n hint: use tls.acme.hostname\n\nFatal config error: configuration key tls_letsencrypt_listen was removed in 0.30 ($DIR/config.yaml:218:1)\n hint: use tls.acme.http_listen\n"
}
+1 -5
View File
@@ -1,7 +1,3 @@
{
"warnings": [
"configuration key \"ephemeral_node_inactivity_timeout\" is deprecated; use \"node.ephemeral.inactivity_timeout\" instead",
"configuration key \"database.gorm.prepare_stmt\" is ignored"
],
"error": "Fatal config error: configuration key randomize_client_port has been removed\n current: randomize_client_port: false\n hint: Set \"randomizeClientPort\": true at the top level of your policy file (see policy.path / policy.mode), or grant the cap per-node via a \"nodeAttrs\" entry. See CHANGELOG.md (BREAKING / Configuration).\n"
"error": "Fatal config error: configuration key acme_email was removed in 0.30 ($DIR/config.yaml:206:1)\n hint: use tls.acme.email\n\nFatal config error: configuration key acme_url was removed in 0.30 ($DIR/config.yaml:203:1)\n hint: use tls.acme.url\n\nFatal config error: configuration key database.gorm.prepare_stmt was removed in 0.30 ($DIR/config.yaml:153:5)\n hint: remove database.gorm.prepare_stmt; see the CHANGELOG for context\n\nFatal config error: configuration key ephemeral_node_inactivity_timeout was removed in 0.30 ($DIR/config.yaml:139:1)\n hint: use node.ephemeral.inactivity_timeout\n\nFatal config error: configuration key grpc_allow_insecure was removed in 0.30 ($DIR/config.yaml:39:1)\n hint: remove grpc_allow_insecure; see the CHANGELOG for context\n\nFatal config error: configuration key grpc_listen_addr was removed in 0.30 ($DIR/config.yaml:33:1)\n hint: remove grpc_listen_addr; see the CHANGELOG for context\n\nFatal config error: configuration key randomize_client_port was removed in 0.29 ($DIR/config.yaml:409:1)\n hint: set \"randomizeClientPort\": true at the top level of the policy file, or grant the cap per node via a \"nodeAttrs\" entry\n\nFatal config error: configuration key tls_cert_path was removed in 0.30 ($DIR/config.yaml:226:1)\n hint: use tls.cert_path\n\nFatal config error: configuration key tls_key_path was removed in 0.30 ($DIR/config.yaml:227:1)\n hint: use tls.key_path\n\nFatal config error: configuration key tls_letsencrypt_cache_dir was removed in 0.30 ($DIR/config.yaml:214:1)\n hint: use tls.acme.cache_dir\n\nFatal config error: configuration key tls_letsencrypt_challenge_type was removed in 0.30 ($DIR/config.yaml:219:1)\n hint: use tls.acme.challenge_type\n\nFatal config error: configuration key tls_letsencrypt_hostname was removed in 0.30 ($DIR/config.yaml:209:1)\n hint: use tls.acme.hostname\n\nFatal config error: configuration key tls_letsencrypt_listen was removed in 0.30 ($DIR/config.yaml:223:1)\n hint: use tls.acme.http_listen\n"
}
+1 -5
View File
@@ -1,7 +1,3 @@
{
"warnings": [
"configuration key \"ephemeral_node_inactivity_timeout\" is deprecated; use \"node.ephemeral.inactivity_timeout\" instead",
"configuration key \"database.gorm.prepare_stmt\" is ignored"
],
"error": "Fatal config error: configuration key randomize_client_port has been removed\n current: randomize_client_port: false\n hint: Set \"randomizeClientPort\": true at the top level of your policy file (see policy.path / policy.mode), or grant the cap per-node via a \"nodeAttrs\" entry. See CHANGELOG.md (BREAKING / Configuration).\n"
"error": "Fatal config error: configuration key acme_email was removed in 0.30 ($DIR/config.yaml:207:1)\n hint: use tls.acme.email\n\nFatal config error: configuration key acme_url was removed in 0.30 ($DIR/config.yaml:204:1)\n hint: use tls.acme.url\n\nFatal config error: configuration key database.gorm.prepare_stmt was removed in 0.30 ($DIR/config.yaml:154:5)\n hint: remove database.gorm.prepare_stmt; see the CHANGELOG for context\n\nFatal config error: configuration key ephemeral_node_inactivity_timeout was removed in 0.30 ($DIR/config.yaml:140:1)\n hint: use node.ephemeral.inactivity_timeout\n\nFatal config error: configuration key grpc_allow_insecure was removed in 0.30 ($DIR/config.yaml:40:1)\n hint: remove grpc_allow_insecure; see the CHANGELOG for context\n\nFatal config error: configuration key grpc_listen_addr was removed in 0.30 ($DIR/config.yaml:34:1)\n hint: remove grpc_listen_addr; see the CHANGELOG for context\n\nFatal config error: configuration key randomize_client_port was removed in 0.29 ($DIR/config.yaml:416:1)\n hint: set \"randomizeClientPort\": true at the top level of the policy file, or grant the cap per node via a \"nodeAttrs\" entry\n\nFatal config error: configuration key tls_cert_path was removed in 0.30 ($DIR/config.yaml:227:1)\n hint: use tls.cert_path\n\nFatal config error: configuration key tls_key_path was removed in 0.30 ($DIR/config.yaml:228:1)\n hint: use tls.key_path\n\nFatal config error: configuration key tls_letsencrypt_cache_dir was removed in 0.30 ($DIR/config.yaml:215:1)\n hint: use tls.acme.cache_dir\n\nFatal config error: configuration key tls_letsencrypt_challenge_type was removed in 0.30 ($DIR/config.yaml:220:1)\n hint: use tls.acme.challenge_type\n\nFatal config error: configuration key tls_letsencrypt_hostname was removed in 0.30 ($DIR/config.yaml:210:1)\n hint: use tls.acme.hostname\n\nFatal config error: configuration key tls_letsencrypt_listen was removed in 0.30 ($DIR/config.yaml:224:1)\n hint: use tls.acme.http_listen\n"
}
+1 -201
View File
@@ -1,203 +1,3 @@
{
"config": {
"ServerURL": "http://127.0.0.1:8080",
"Addr": "127.0.0.1:8080",
"MetricsAddr": "127.0.0.1:9090",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise_private.key",
"BaseDomain": "example.com",
"Log": {
"Format": "text",
"Level": "info"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "sqlite3",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 1000000000,
"SkipErrRecordNotFound": true,
"ParameterizedQueries": true
},
"Sqlite": {
"Path": "/var/lib/headscale/db.sqlite",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "",
"Port": 0,
"Name": "",
"User": "",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": false,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 999,
"ServerRegionCode": "headscale",
"ServerRegionName": "Headscale Embedded DERP",
"ServerPrivateKeyPath": "/var/lib/headscale/derp_server_private.key",
"ServerVerifyClients": true,
"STUNAddr": "0.0.0.0:3478",
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": [],
"DERPMap": null,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "198.51.100.1",
"IPv6": "2001:db8::1"
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "https://acme-v02.api.letsencrypt.org/directory",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "example.com",
"OverrideLocalDNS": true,
"Nameservers": {
"Global": [
"1.1.1.1",
"1.0.0.1",
"2606:4700:4700::1111",
"2606:4700:4700::1001"
],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": [],
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "example.com"
}
},
"TailcfgDNSConfig": {
"Resolvers": [
{
"Addr": "1.1.1.1"
},
{
"Addr": "1.0.0.1"
},
{
"Addr": "2606:4700:4700::1111"
},
{
"Addr": "2606:4700:4700::1001"
}
],
"Domains": [
"example.com"
],
"Proxied": true
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/var/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": null,
"AllowedUsers": null,
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 800000000,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
},
"warnings": [
"configuration key \"database.gorm.prepare_stmt\" is ignored"
]
"error": "Fatal config error: configuration key acme_email was removed in 0.30 ($DIR/config.yaml:259:1)\n hint: use tls.acme.email\n\nFatal config error: configuration key acme_url was removed in 0.30 ($DIR/config.yaml:256:1)\n hint: use tls.acme.url\n\nFatal config error: configuration key database.gorm.prepare_stmt was removed in 0.30 ($DIR/config.yaml:206:5)\n hint: remove database.gorm.prepare_stmt; see the CHANGELOG for context\n\nFatal config error: configuration key grpc_allow_insecure was removed in 0.30 ($DIR/config.yaml:40:1)\n hint: remove grpc_allow_insecure; see the CHANGELOG for context\n\nFatal config error: configuration key grpc_listen_addr was removed in 0.30 ($DIR/config.yaml:34:1)\n hint: remove grpc_listen_addr; see the CHANGELOG for context\n\nFatal config error: configuration key tls_cert_path was removed in 0.30 ($DIR/config.yaml:279:1)\n hint: use tls.cert_path\n\nFatal config error: configuration key tls_key_path was removed in 0.30 ($DIR/config.yaml:280:1)\n hint: use tls.key_path\n\nFatal config error: configuration key tls_letsencrypt_cache_dir was removed in 0.30 ($DIR/config.yaml:267:1)\n hint: use tls.acme.cache_dir\n\nFatal config error: configuration key tls_letsencrypt_challenge_type was removed in 0.30 ($DIR/config.yaml:272:1)\n hint: use tls.acme.challenge_type\n\nFatal config error: configuration key tls_letsencrypt_hostname was removed in 0.30 ($DIR/config.yaml:262:1)\n hint: use tls.acme.hostname\n\nFatal config error: configuration key tls_letsencrypt_listen was removed in 0.30 ($DIR/config.yaml:276:1)\n hint: use tls.acme.http_listen\n"
}
+1 -201
View File
@@ -1,203 +1,3 @@
{
"config": {
"ServerURL": "http://127.0.0.1:8080",
"Addr": "127.0.0.1:8080",
"MetricsAddr": "127.0.0.1:9090",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise_private.key",
"BaseDomain": "example.com",
"Log": {
"Format": "text",
"Level": "info"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "sqlite3",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 1000000000,
"SkipErrRecordNotFound": true,
"ParameterizedQueries": true
},
"Sqlite": {
"Path": "/var/lib/headscale/db.sqlite",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "",
"Port": 0,
"Name": "",
"User": "",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": false,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 999,
"ServerRegionCode": "headscale",
"ServerRegionName": "Headscale Embedded DERP",
"ServerPrivateKeyPath": "/var/lib/headscale/derp_server_private.key",
"ServerVerifyClients": true,
"STUNAddr": "0.0.0.0:3478",
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": [],
"DERPMap": null,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "198.51.100.1",
"IPv6": "2001:db8::1"
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "https://acme-v02.api.letsencrypt.org/directory",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "example.com",
"OverrideLocalDNS": true,
"Nameservers": {
"Global": [
"1.1.1.1",
"1.0.0.1",
"2606:4700:4700::1111",
"2606:4700:4700::1001"
],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": [],
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "example.com"
}
},
"TailcfgDNSConfig": {
"Resolvers": [
{
"Addr": "1.1.1.1"
},
{
"Addr": "1.0.0.1"
},
{
"Addr": "2606:4700:4700::1111"
},
{
"Addr": "2606:4700:4700::1001"
}
],
"Domains": [
"example.com"
],
"Proxied": true
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/var/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": null,
"AllowedUsers": null,
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 800000000,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
},
"warnings": [
"configuration key \"database.gorm.prepare_stmt\" is ignored"
]
"error": "Fatal config error: configuration key acme_email was removed in 0.30 ($DIR/config.yaml:259:1)\n hint: use tls.acme.email\n\nFatal config error: configuration key acme_url was removed in 0.30 ($DIR/config.yaml:256:1)\n hint: use tls.acme.url\n\nFatal config error: configuration key database.gorm.prepare_stmt was removed in 0.30 ($DIR/config.yaml:206:5)\n hint: remove database.gorm.prepare_stmt; see the CHANGELOG for context\n\nFatal config error: configuration key grpc_allow_insecure was removed in 0.30 ($DIR/config.yaml:40:1)\n hint: remove grpc_allow_insecure; see the CHANGELOG for context\n\nFatal config error: configuration key grpc_listen_addr was removed in 0.30 ($DIR/config.yaml:34:1)\n hint: remove grpc_listen_addr; see the CHANGELOG for context\n\nFatal config error: configuration key tls_cert_path was removed in 0.30 ($DIR/config.yaml:279:1)\n hint: use tls.cert_path\n\nFatal config error: configuration key tls_key_path was removed in 0.30 ($DIR/config.yaml:280:1)\n hint: use tls.key_path\n\nFatal config error: configuration key tls_letsencrypt_cache_dir was removed in 0.30 ($DIR/config.yaml:267:1)\n hint: use tls.acme.cache_dir\n\nFatal config error: configuration key tls_letsencrypt_challenge_type was removed in 0.30 ($DIR/config.yaml:272:1)\n hint: use tls.acme.challenge_type\n\nFatal config error: configuration key tls_letsencrypt_hostname was removed in 0.30 ($DIR/config.yaml:262:1)\n hint: use tls.acme.hostname\n\nFatal config error: configuration key tls_letsencrypt_listen was removed in 0.30 ($DIR/config.yaml:276:1)\n hint: use tls.acme.http_listen\n"
}
@@ -0,0 +1 @@
COMPAT_SECRETS=testdata/compat
+252
View File
@@ -0,0 +1,252 @@
{
"config": {
"ServerURL": "https://headscale.example.com",
"Addr": "0.0.0.0:8443",
"MetricsAddr": "127.0.0.1:9091",
"TrustedProxies": [
"10.0.0.0/8",
"192.168.0.0/16"
],
"Node": {
"Expiry": 7776000000000000,
"Ephemeral": {
"InactivityTimeout": 2700000000000
},
"Routes": {
"HA": {
"ProbeInterval": 20000000000,
"ProbeTimeout": 7000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 259200000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "random",
"NoisePrivateKeyPath": "$DIR/noise_private.key",
"BaseDomain": "tailnet.example.net",
"Log": {
"Format": "json",
"Level": "debug"
},
"DisableUpdateCheck": true,
"Database": {
"Type": "postgres",
"Debug": true,
"Gorm": {
"Debug": true,
"SlowThreshold": 2000000000,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": true
},
"Sqlite": {
"Path": "",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "db.example.com",
"Port": 5433,
"Name": "headscale",
"User": "headscale",
"Ssl": "true",
"MaxOpenConnections": 20,
"MaxIdleConnections": 5,
"ConnMaxIdleTimeSecs": 1800
}
},
"DERP": {
"ServerEnabled": true,
"AutomaticallyAddEmbeddedDerpRegion": false,
"ServerRegionID": 900,
"ServerRegionCode": "hs",
"ServerRegionName": "Headscale Embedded DERP",
"ServerPrivateKeyPath": "$DIR/derp_server_private.key",
"ServerVerifyClients": false,
"STUNAddr": "0.0.0.0:3479",
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
},
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "derp.example.com",
"Path": "/map.json",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": [
"/etc/headscale/derp.yaml"
],
"DERPMap": null,
"AutoUpdate": false,
"UpdateFrequency": 3600000000000,
"IPv4": "198.51.100.1",
"IPv6": "2001:db8::1"
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "headscale.example.com",
"ChallengeType": "TLS-ALPN-01",
"HTTPListen": ":8081",
"URL": "https://acme-staging-v02.api.letsencrypt.org/directory",
"Email": "admin@example.com",
"CacheDir": "$DIR/acme-cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "tailnet.example.net",
"OverrideLocalDNS": true,
"Nameservers": {
"Global": [
"1.1.1.1",
"https://dns.nextdns.io/abc123"
],
"Split": {
"corp.example.com": [
"10.0.0.1"
]
}
},
"SearchDomains": [
"corp.example.com"
],
"ExtraRecords": [
{
"Name": "grafana.tailnet.example.net",
"Type": "A",
"Value": "100.64.0.3"
}
],
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "tailnet.example.net"
}
},
"TailcfgDNSConfig": {
"Resolvers": [
{
"Addr": "1.1.1.1"
},
{
"Addr": "https://dns.nextdns.io/abc123"
}
],
"Routes": {
"corp.example.com": [
{
"Addr": "10.0.0.1"
}
]
},
"Domains": [
"tailnet.example.net",
"corp.example.com"
],
"Proxied": true,
"ExtraRecords": [
{
"Name": "grafana.tailnet.example.net",
"Type": "A",
"Value": "100.64.0.3"
}
]
},
"DNSChallenge": {
"PropagationTimeout": 180000000000,
"Resolvers": [
"9.9.9.9:53"
],
"ProviderName": ""
},
"UnixSocket": "/run/headscale/headscale.sock",
"UnixSocketPermission": 448,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": false,
"Issuer": "https://idp.example.com",
"ClientID": "headscale",
"Scope": [
"openid",
"profile",
"email",
"groups"
],
"ExtraParams": {
"login_hint": "file"
},
"AllowedDomains": [
"example.com"
],
"AllowedUsers": [
"alice@example.com"
],
"AllowedGroups": [
"/headscale"
],
"EmailVerifiedRequired": false,
"UseExpiryFromToken": true,
"PKCE": {
"Enabled": true,
"Method": "plain"
}
},
"LogTail": {
"Enabled": true
},
"Taildrop": {
"Enabled": false
},
"AutoUpdate": {
"Enabled": true
},
"CLI": {
"Address": "headscale.example.com:443",
"Timeout": 15000000000,
"Insecure": true
},
"Policy": {
"Path": "",
"Mode": "database"
},
"Tuning": {
"NotifierSendTimeout": 1000000000,
"BatchChangeDelay": 500000000,
"NodeMapSessionBufferedChanSize": 50,
"BatcherWorkers": 4096,
"RegisterCacheExpiration": 1200000000000,
"RegisterCacheMaxEntries": 2000,
"NodeStoreBatchSize": 50,
"NodeStoreBatchTimeout": 250000000
}
},
"secrets": {
"database.postgres.pass": "marker-postgres-pass",
"oidc.client_secret": "marker-oidc-secret-from-file"
},
"warnings": [
"Warning: when using tls.acme.hostname with TLS-ALPN-01 as challenge type, headscale must be reachable on port 443, i.e. listen_addr should probably end in :443"
]
}
@@ -0,0 +1,143 @@
# Every key the loader reads, set to a valid non-default value.
server_url: https://headscale.example.com
listen_addr: 0.0.0.0:8443
metrics_listen_addr: 127.0.0.1:9091
trusted_proxies: [10.0.0.0/8, 192.168.0.0/16]
disable_check_updates: true
unix_socket: /run/headscale/headscale.sock
unix_socket_permission: "0700"
noise:
private_key_path: ./noise_private.key
prefixes:
v4: 100.64.0.0/10
v6: fd7a:115c:a1e0::/48
allocation: random
derp:
server:
enabled: true
region_id: 900
region_code: hs
region_name: Headscale Embedded DERP
verify_clients: false
stun_listen_addr: 0.0.0.0:3479
private_key_path: ./derp_server_private.key
automatically_add_embedded_derp_region: false
ipv4: 198.51.100.1
ipv6: 2001:db8::1
urls:
- https://controlplane.tailscale.com/derpmap/default
- https://derp.example.com/map.json
paths:
- /etc/headscale/derp.yaml
auto_update_enabled: false
update_frequency: 1h
node:
expiry: 90d
ephemeral:
inactivity_timeout: 45m
routes:
ha:
probe_interval: 20s
probe_timeout: 7s
preauth_keys:
revoked_retention: 72h
database:
type: postgres
debug: true
gorm:
parameterized_queries: true
skip_err_record_not_found: false
slow_threshold: 2000
postgres:
host: db.example.com
port: 5433
name: headscale
user: headscale
pass: marker-postgres-pass
max_open_conns: 20
max_idle_conns: 5
conn_max_idle_time_secs: 1800
ssl: true
tls:
acme:
hostname: headscale.example.com
challenge_type: TLS-ALPN-01
http_listen: :8081
url: https://acme-staging-v02.api.letsencrypt.org/directory
email: admin@example.com
cache_dir: ./acme-cache
log:
format: json
level: debug
policy:
mode: database
dns:
magic_dns: true
base_domain: tailnet.example.net
override_local_dns: true
nameservers:
global:
- 1.1.1.1
- https://dns.nextdns.io/abc123
split:
Corp.Example.COM:
- 10.0.0.1
search_domains: [corp.example.com]
extra_records:
- name: grafana.tailnet.example.net
type: A
value: 100.64.0.3
challenge:
propagation_timeout: 3m
resolvers: [9.9.9.9]
oidc:
only_start_if_oidc_is_available: false
issuer: https://idp.example.com
client_id: headscale
# os.ExpandEnv, then read relative to the test's working directory.
client_secret: file:${COMPAT_SECRETS}/oidc-secret.txt
scope: [openid, profile, email, groups]
extra_params:
Login_Hint: file
allowed_domains: [example.com]
allowed_users: [alice@example.com]
allowed_groups: [/headscale]
email_verified_required: false
use_expiry_from_token: true
pkce:
enabled: true
method: plain
logtail:
enabled: true
taildrop:
enabled: false
auto_update:
enabled: true
cli:
address: headscale.example.com:443
api_key: marker-cli-api-key
timeout: 15s
insecure: true
tuning:
notifier_send_timeout: 1s
batch_change_delay: 500ms
node_mapsession_buffered_chan_size: 50
batcher_workers: 4096
register_cache_expiration: 20m
register_cache_max_entries: 2000
node_store_batch_size: 50
node_store_batch_timeout: 250ms
+1 -251
View File
@@ -1,253 +1,3 @@
{
"config": {
"ServerURL": "https://headscale.example.com",
"Addr": "0.0.0.0:8443",
"MetricsAddr": "127.0.0.1:9091",
"TrustedProxies": [
"10.0.0.0/8",
"192.168.0.0/16"
],
"Node": {
"Expiry": 7776000000000000,
"Ephemeral": {
"InactivityTimeout": 2700000000000
},
"Routes": {
"HA": {
"ProbeInterval": 20000000000,
"ProbeTimeout": 7000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 259200000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "random",
"NoisePrivateKeyPath": "$DIR/noise_private.key",
"BaseDomain": "tailnet.example.net",
"Log": {
"Format": "json",
"Level": "debug"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "postgres",
"Debug": true,
"Gorm": {
"Debug": true,
"SlowThreshold": 2000000000,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": true
},
"Sqlite": {
"Path": "",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "db.example.com",
"Port": 5433,
"Name": "headscale",
"User": "headscale",
"Ssl": "true",
"MaxOpenConnections": 20,
"MaxIdleConnections": 5,
"ConnMaxIdleTimeSecs": 1800
}
},
"DERP": {
"ServerEnabled": true,
"AutomaticallyAddEmbeddedDerpRegion": false,
"ServerRegionID": 900,
"ServerRegionCode": "hs",
"ServerRegionName": "Headscale Embedded DERP",
"ServerPrivateKeyPath": "$DIR/derp_server_private.key",
"ServerVerifyClients": false,
"STUNAddr": "0.0.0.0:3479",
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
},
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "derp.example.com",
"Path": "/map.json",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": [
"/etc/headscale/derp.yaml"
],
"DERPMap": null,
"AutoUpdate": false,
"UpdateFrequency": 3600000000000,
"IPv4": "198.51.100.1",
"IPv6": "2001:db8::1"
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "headscale.example.com",
"ChallengeType": "TLS-ALPN-01",
"HTTPListen": ":8081",
"URL": "https://acme-staging-v02.api.letsencrypt.org/directory",
"Email": "admin@example.com",
"CacheDir": "$DIR/acme-cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "tailnet.example.net",
"OverrideLocalDNS": true,
"Nameservers": {
"Global": [
"1.1.1.1",
"https://dns.nextdns.io/abc123"
],
"Split": {
"corp.example.com": [
"10.0.0.1"
]
}
},
"SearchDomains": [
"corp.example.com"
],
"ExtraRecords": [
{
"Name": "grafana.tailnet.example.net",
"Type": "A",
"Value": "100.64.0.3"
}
],
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "tailnet.example.net"
}
},
"TailcfgDNSConfig": {
"Resolvers": [
{
"Addr": "1.1.1.1"
},
{
"Addr": "https://dns.nextdns.io/abc123"
}
],
"Routes": {
"corp.example.com": [
{
"Addr": "10.0.0.1"
}
]
},
"Domains": [
"tailnet.example.net",
"corp.example.com"
],
"Proxied": true,
"ExtraRecords": [
{
"Name": "grafana.tailnet.example.net",
"Type": "A",
"Value": "100.64.0.3"
}
]
},
"DNSChallenge": {
"PropagationTimeout": 180000000000,
"Resolvers": [
"9.9.9.9:53"
],
"ProviderName": ""
},
"UnixSocket": "/run/headscale/headscale.sock",
"UnixSocketPermission": 448,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": false,
"Issuer": "https://idp.example.com",
"ClientID": "headscale",
"Scope": [
"openid",
"profile",
"email",
"groups"
],
"ExtraParams": {
"login_hint": "file"
},
"AllowedDomains": [
"example.com"
],
"AllowedUsers": [
"alice@example.com"
],
"AllowedGroups": [
"/headscale"
],
"EmailVerifiedRequired": false,
"UseExpiryFromToken": true,
"PKCE": {
"Enabled": true,
"Method": "plain"
}
},
"LogTail": {
"Enabled": true
},
"Taildrop": {
"Enabled": false
},
"AutoUpdate": {
"Enabled": true
},
"CLI": {
"Address": "headscale.example.com:443",
"Timeout": 15000000000,
"Insecure": true
},
"Policy": {
"Path": "",
"Mode": "database"
},
"Tuning": {
"NotifierSendTimeout": 1000000000,
"BatchChangeDelay": 500000000,
"NodeMapSessionBufferedChanSize": 50,
"BatcherWorkers": 4096,
"RegisterCacheExpiration": 1200000000000,
"RegisterCacheMaxEntries": 2000,
"NodeStoreBatchSize": 50,
"NodeStoreBatchTimeout": 250000000
}
},
"secrets": {
"cli.api_key": "marker-cli-api-key",
"database.postgres.pass": "marker-postgres-pass",
"oidc.client_secret": "marker-oidc-secret-from-file"
},
"warnings": [
"Warning: when using tls.acme.hostname with TLS-ALPN-01 as challenge type, headscale must be reachable on port 443, i.e. listen_addr should probably end in :443"
]
"error": "Fatal config error: configuration key oidc.client_secret_path was removed in 0.30 ($DIR/config.yaml:109:3)\n hint: use oidc.client_secret: \"file:\u003cpath\u003e\"\n"
}
+30
View File
@@ -0,0 +1,30 @@
HEADSCALE_LOG_LEVEL=trace
HEADSCALE_POLICY_PATH=
HEADSCALE_DATABASE_TYPE=sqlite
HEADSCALE_DATABASE_SQLITE_PATH=/tmp/integration_test_db.sqlite3
HEADSCALE_DATABASE_DEBUG=0
HEADSCALE_DATABASE_GORM_SLOW_THRESHOLD=1
HEADSCALE_NODE_EPHEMERAL_INACTIVITY_TIMEOUT=30m
HEADSCALE_PREFIXES_V4=100.64.0.0/10
HEADSCALE_PREFIXES_V6=fd7a:115c:a1e0::/48
HEADSCALE_DNS_BASE_DOMAIN=headscale.net
HEADSCALE_DNS_MAGIC_DNS=true
HEADSCALE_DNS_OVERRIDE_LOCAL_DNS=false
HEADSCALE_DNS_NAMESERVERS_GLOBAL=127.0.0.11 1.1.1.1
HEADSCALE_NOISE_PRIVATE_KEY_PATH=/tmp/noise_private.key
HEADSCALE_METRICS_LISTEN_ADDR=0.0.0.0:9090
HEADSCALE_DERP_URLS=
HEADSCALE_DERP_AUTO_UPDATE_ENABLED=false
HEADSCALE_DERP_UPDATE_FREQUENCY=1m
HEADSCALE_DERP_SERVER_ENABLED=true
HEADSCALE_DERP_SERVER_REGION_ID=999
HEADSCALE_DERP_SERVER_REGION_CODE=headscale
HEADSCALE_DERP_SERVER_REGION_NAME=Headscale Embedded DERP
HEADSCALE_DERP_SERVER_STUN_LISTEN_ADDR=0.0.0.0:3478
HEADSCALE_DERP_SERVER_PRIVATE_KEY_PATH=/tmp/derp.key
DERP_DEBUG_LOGS=true
DERP_PROBER_DEBUG_LOGS=true
HEADSCALE_PREFIXES_ALLOCATION=sequential
# hsic.go sets these per container, outside DefaultConfigEnv.
HEADSCALE_SERVER_URL=http://hs-compat:8080
HEADSCALE_LISTEN_ADDR=0.0.0.0:8080
+178
View File
@@ -0,0 +1,178 @@
{
"config": {
"ServerURL": "http://hs-compat:8080",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "0.0.0.0:9090",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/tmp/noise_private.key",
"BaseDomain": "headscale.net",
"Log": {
"Format": "text",
"Level": "trace"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "sqlite3",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 1000000,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "/tmp/integration_test_db.sqlite3",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "",
"Port": 0,
"Name": "",
"User": "",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": true,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 999,
"ServerRegionCode": "headscale",
"ServerRegionName": "Headscale Embedded DERP",
"ServerPrivateKeyPath": "/tmp/derp.key",
"ServerVerifyClients": true,
"STUNAddr": "0.0.0.0:3478",
"URLs": [],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"UpdateFrequency": 60000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "headscale.net",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [
"127.0.0.11",
"1.1.1.1"
],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "headscale.net"
}
},
"TailcfgDNSConfig": {
"FallbackResolvers": [
{
"Addr": "127.0.0.11"
},
{
"Addr": "1.1.1.1"
}
],
"Domains": [
"headscale.net"
],
"Proxied": true
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/var/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": null,
"AllowedUsers": null,
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 800000000,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
}
@@ -0,0 +1,2 @@
noise:
private_key_path: /tmp/noise_private.key
+1 -179
View File
@@ -1,181 +1,3 @@
{
"config": {
"ServerURL": "http://hs-compat:8080",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "0.0.0.0:9090",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/tmp/noise_private.key",
"BaseDomain": "headscale.net",
"Log": {
"Format": "text",
"Level": "trace"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "sqlite3",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 1000000,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "/tmp/integration_test_db.sqlite3",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "",
"Port": 0,
"Name": "",
"User": "",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": true,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 999,
"ServerRegionCode": "headscale",
"ServerRegionName": "Headscale Embedded DERP",
"ServerPrivateKeyPath": "/tmp/derp.key",
"ServerVerifyClients": true,
"STUNAddr": "0.0.0.0:3478",
"URLs": [],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"UpdateFrequency": 60000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "headscale.net",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [
"127.0.0.11",
"1.1.1.1"
],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "headscale.net"
}
},
"TailcfgDNSConfig": {
"FallbackResolvers": [
{
"Addr": "127.0.0.11"
},
{
"Addr": "1.1.1.1"
}
],
"Domains": [
"headscale.net"
],
"Proxied": true
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/var/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": null,
"AllowedUsers": null,
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 800000000,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
},
"warnings": [
"configuration key \"ephemeral_node_inactivity_timeout\" is deprecated; use \"node.ephemeral.inactivity_timeout\" instead"
]
"error": "Fatal config error: configuration key private_key_path was removed in 0.23 ($DIR/config.yaml:1:1)\n hint: use noise.private_key_path\n"
}
@@ -0,0 +1,34 @@
HEADSCALE_LOG_LEVEL=trace
HEADSCALE_POLICY_PATH=
HEADSCALE_DATABASE_DEBUG=0
HEADSCALE_DATABASE_GORM_SLOW_THRESHOLD=1
HEADSCALE_NODE_EPHEMERAL_INACTIVITY_TIMEOUT=30m
HEADSCALE_PREFIXES_V4=100.64.0.0/10
HEADSCALE_PREFIXES_V6=fd7a:115c:a1e0::/48
HEADSCALE_DNS_BASE_DOMAIN=headscale.net
HEADSCALE_DNS_MAGIC_DNS=true
HEADSCALE_DNS_OVERRIDE_LOCAL_DNS=false
HEADSCALE_DNS_NAMESERVERS_GLOBAL=127.0.0.11 1.1.1.1
HEADSCALE_NOISE_PRIVATE_KEY_PATH=/tmp/noise_private.key
HEADSCALE_METRICS_LISTEN_ADDR=0.0.0.0:9090
HEADSCALE_DERP_URLS=
HEADSCALE_DERP_AUTO_UPDATE_ENABLED=false
HEADSCALE_DERP_UPDATE_FREQUENCY=1m
HEADSCALE_DERP_SERVER_ENABLED=true
HEADSCALE_DERP_SERVER_REGION_ID=999
HEADSCALE_DERP_SERVER_REGION_CODE=headscale
HEADSCALE_DERP_SERVER_REGION_NAME=Headscale Embedded DERP
HEADSCALE_DERP_SERVER_STUN_LISTEN_ADDR=0.0.0.0:3478
HEADSCALE_DERP_SERVER_PRIVATE_KEY_PATH=/tmp/derp.key
DERP_DEBUG_LOGS=true
DERP_PROBER_DEBUG_LOGS=true
HEADSCALE_PREFIXES_ALLOCATION=sequential
# hsic.go sets these per container, outside DefaultConfigEnv.
HEADSCALE_SERVER_URL=http://hs-compat:8080
HEADSCALE_LISTEN_ADDR=0.0.0.0:8080
# hsic.WithPostgres overrides.
HEADSCALE_DATABASE_TYPE=postgres
HEADSCALE_DATABASE_POSTGRES_HOST=postgres-compat
HEADSCALE_DATABASE_POSTGRES_USER=headscale
HEADSCALE_DATABASE_POSTGRES_PASS=headscale
HEADSCALE_DATABASE_POSTGRES_NAME=headscale
+181
View File
@@ -0,0 +1,181 @@
{
"config": {
"ServerURL": "http://hs-compat:8080",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "0.0.0.0:9090",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/tmp/noise_private.key",
"BaseDomain": "headscale.net",
"Log": {
"Format": "text",
"Level": "trace"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "postgres",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 1000000,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "postgres-compat",
"Port": 0,
"Name": "headscale",
"User": "headscale",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": true,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 999,
"ServerRegionCode": "headscale",
"ServerRegionName": "Headscale Embedded DERP",
"ServerPrivateKeyPath": "/tmp/derp.key",
"ServerVerifyClients": true,
"STUNAddr": "0.0.0.0:3478",
"URLs": [],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"UpdateFrequency": 60000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "headscale.net",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [
"127.0.0.11",
"1.1.1.1"
],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "headscale.net"
}
},
"TailcfgDNSConfig": {
"FallbackResolvers": [
{
"Addr": "127.0.0.11"
},
{
"Addr": "1.1.1.1"
}
],
"Domains": [
"headscale.net"
],
"Proxied": true
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/var/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": null,
"AllowedUsers": null,
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 800000000,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
},
"secrets": {
"database.postgres.pass": "headscale"
}
}
@@ -0,0 +1,2 @@
noise:
private_key_path: /tmp/noise_private.key
+1 -182
View File
@@ -1,184 +1,3 @@
{
"config": {
"ServerURL": "http://hs-compat:8080",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "0.0.0.0:9090",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/tmp/noise_private.key",
"BaseDomain": "headscale.net",
"Log": {
"Format": "text",
"Level": "trace"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "postgres",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 1000000,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "postgres-compat",
"Port": 0,
"Name": "headscale",
"User": "headscale",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": true,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 999,
"ServerRegionCode": "headscale",
"ServerRegionName": "Headscale Embedded DERP",
"ServerPrivateKeyPath": "/tmp/derp.key",
"ServerVerifyClients": true,
"STUNAddr": "0.0.0.0:3478",
"URLs": [],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"UpdateFrequency": 60000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "headscale.net",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [
"127.0.0.11",
"1.1.1.1"
],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "headscale.net"
}
},
"TailcfgDNSConfig": {
"FallbackResolvers": [
{
"Addr": "127.0.0.11"
},
{
"Addr": "1.1.1.1"
}
],
"Domains": [
"headscale.net"
],
"Proxied": true
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/var/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": null,
"AllowedUsers": null,
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 800000000,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
},
"secrets": {
"database.postgres.pass": "headscale"
},
"warnings": [
"configuration key \"ephemeral_node_inactivity_timeout\" is deprecated; use \"node.ephemeral.inactivity_timeout\" instead"
]
"error": "Fatal config error: configuration key private_key_path was removed in 0.23 ($DIR/config.yaml:1:1)\n hint: use noise.private_key_path\n"
}
+192
View File
@@ -0,0 +1,192 @@
{
"config": {
"ServerURL": "https://headscale.example.com",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise_private.key",
"BaseDomain": "tailnet.example.com",
"Log": {
"Format": "text",
"Level": "info"
},
"DisableUpdateCheck": true,
"Database": {
"Type": "sqlite3",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 0,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "/var/lib/headscale/db.sqlite",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "",
"Port": 0,
"Name": "",
"User": "",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": false,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 0,
"ServerRegionCode": "",
"ServerRegionName": "",
"ServerPrivateKeyPath": "/var/lib/headscale/derp_server_private.key",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": [],
"DERPMap": null,
"AutoUpdate": true,
"UpdateFrequency": 86400000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "tailnet.example.com",
"OverrideLocalDNS": true,
"Nameservers": {
"Global": [
"1.1.1.1",
"8.8.8.8"
],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "tailnet.example.com"
}
},
"TailcfgDNSConfig": {
"Resolvers": [
{
"Addr": "1.1.1.1"
},
{
"Addr": "8.8.8.8"
}
],
"Domains": [
"tailnet.example.com"
],
"Proxied": true
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": [],
"AllowedUsers": [],
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "/var/lib/headscale/policy.hujson",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 800000000,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
}
@@ -0,0 +1,76 @@
%YAML 1.1
---
database:
postgres:
host: null
name: null
port: null
user: null
sqlite:
path: /var/lib/headscale/db.sqlite
write_ahead_log: true
type: sqlite
derp:
auto_update_enabled: true
paths: []
server:
private_key_path: /var/lib/headscale/derp_server_private.key
update_frequency: 24h
urls:
- https://controlplane.tailscale.com/derpmap/default
disable_check_updates: true
dns:
base_domain: tailnet.example.com
certificates:
enabled: false
zone: ''
challenge:
provider: null
extra_records: null
magic_dns: true
nameservers:
global:
- 1.1.1.1
- 8.8.8.8
split: {}
override_local_dns: true
search_domains: []
listen_addr: 0.0.0.0:8080
log:
format: text
level: info
node:
ephemeral:
inactivity_timeout: 30m
expiry: '0'
noise:
private_key_path: /var/lib/headscale/noise_private.key
oidc:
allowed_domains: []
allowed_users: []
client_id: ''
extra_params: {}
issuer: ''
pkce:
enabled: false
method: S256
scope:
- openid
- profile
- email
policy:
mode: file
path: /var/lib/headscale/policy.hujson
prefixes:
allocation: sequential
v4: 100.64.0.0/10
v6: fd7a:115c:a1e0::/48
server_url: https://headscale.example.com
tls:
acme:
challenge_type: null
hostname: ''
http_listen: null
cert_path: null
key_path: null
unix_socket: /run/headscale/headscale.sock
+1 -1
View File
@@ -28,7 +28,7 @@
"Format": "text",
"Level": "info"
},
"DisableUpdateCheck": false,
"DisableUpdateCheck": true,
"Database": {
"Type": "sqlite3",
"Debug": false,
+1 -186
View File
@@ -1,188 +1,3 @@
{
"config": {
"ServerURL": "https://headscale.example.com",
"Addr": "127.0.0.1:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise_private.key",
"BaseDomain": "tailnet.example.com",
"Log": {
"Format": "text",
"Level": "info"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "sqlite3",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 0,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "/var/lib/headscale/db.sqlite",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "",
"Port": 0,
"Name": "",
"User": "",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": false,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 0,
"ServerRegionCode": "",
"ServerRegionName": "",
"ServerPrivateKeyPath": "/var/lib/headscale/derp_server_private.key",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": [],
"DERPMap": null,
"AutoUpdate": true,
"UpdateFrequency": 86400000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/.cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "tailnet.example.com",
"OverrideLocalDNS": true,
"Nameservers": {
"Global": [
"1.1.1.1"
],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "tailnet.example.com"
}
},
"TailcfgDNSConfig": {
"Resolvers": [
{
"Addr": "1.1.1.1"
}
],
"Domains": [
"tailnet.example.com"
],
"Proxied": true
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": [],
"AllowedUsers": [],
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 800000000,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
"error": "Fatal config error: configuration key tls_letsencrypt_cache_dir was removed in 0.30 ($DIR/config.yaml:56:1)\n hint: use tls.acme.cache_dir\n\nFatal config error: configuration key tls_letsencrypt_challenge_type was removed in 0.30 ($DIR/config.yaml:57:1)\n hint: use tls.acme.challenge_type\n\nFatal config error: configuration key tls_letsencrypt_hostname was removed in 0.30 ($DIR/config.yaml:58:1)\n hint: use tls.acme.hostname\n\nFatal config error: configuration key tls_letsencrypt_listen was removed in 0.30 ($DIR/config.yaml:59:1)\n hint: use tls.acme.http_listen\n"
}
@@ -0,0 +1,162 @@
{
"config": {
"ServerURL": "https://derp.no",
"Addr": "",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "$DIR/private_key.pem",
"BaseDomain": "",
"Log": {
"Format": "text",
"Level": "info"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "sqlite3",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 0,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "",
"Port": 0,
"Name": "",
"User": "",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": false,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 0,
"ServerRegionCode": "",
"ServerRegionName": "",
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
}
},
"TailcfgDNSConfig": {},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/var/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": null,
"AllowedUsers": null,
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "/etc/policy.hujson",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 800000000,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
}
+1 -163
View File
@@ -1,165 +1,3 @@
{
"config": {
"ServerURL": "https://derp.no",
"Addr": "",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
},
"Routes": {
"HA": {
"ProbeInterval": 10000000000,
"ProbeTimeout": 5000000000
}
}
},
"PreAuthKeys": {
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "$DIR/private_key.pem",
"BaseDomain": "",
"Log": {
"Format": "text",
"Level": "info"
},
"DisableUpdateCheck": false,
"Database": {
"Type": "sqlite3",
"Debug": false,
"Gorm": {
"Debug": false,
"SlowThreshold": 0,
"SkipErrRecordNotFound": false,
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
"Postgres": {
"Host": "",
"Port": 0,
"Name": "",
"User": "",
"Ssl": "false",
"MaxOpenConnections": 10,
"MaxIdleConnections": 10,
"ConnMaxIdleTimeSecs": 3600
}
},
"DERP": {
"ServerEnabled": false,
"AutomaticallyAddEmbeddedDerpRegion": true,
"ServerRegionID": 0,
"ServerRegionCode": "",
"ServerRegionName": "",
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
}
},
"TailcfgDNSConfig": {},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"1.1.1.1:53",
"8.8.8.8:53"
],
"ProviderName": ""
},
"UnixSocket": "/var/run/headscale/headscale.sock",
"UnixSocketPermission": 504,
"OIDC": {
"OnlyStartIfOIDCIsAvailable": true,
"Issuer": "",
"ClientID": "",
"Scope": [
"openid",
"profile",
"email"
],
"ExtraParams": {},
"AllowedDomains": null,
"AllowedUsers": null,
"AllowedGroups": null,
"EmailVerifiedRequired": true,
"UseExpiryFromToken": false,
"PKCE": {
"Enabled": false,
"Method": "S256"
}
},
"LogTail": {
"Enabled": false
},
"Taildrop": {
"Enabled": true
},
"AutoUpdate": {
"Enabled": false
},
"CLI": {
"Address": "",
"Timeout": 5000000000,
"Insecure": false
},
"Policy": {
"Path": "/etc/policy.hujson",
"Mode": "file"
},
"Tuning": {
"NotifierSendTimeout": 800000000,
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 0,
"RegisterCacheMaxEntries": 0,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
},
"warnings": [
"configuration key \"acl_policy_path\" is deprecated; use \"policy.path\" instead"
]
"error": "Fatal config error: configuration key acl_policy_path was removed in 0.30 ($DIR/config.yaml:13:1)\n hint: use policy.path\n\nFatal config error: unknown configuration key policy.type ($DIR/config.yaml:15:3)\n"
}
@@ -0,0 +1,18 @@
noise:
private_key_path: "private_key.pem"
prefixes:
v6: fd7a:115c:a1e0::/48
v4: 100.64.0.0/10
database:
type: sqlite3
server_url: "https://derp.no"
policy:
path: "/etc/policy.hujson"
dns:
magic_dns: false
override_local_dns: false
+5 -9
View File
@@ -12,7 +12,6 @@ import (
"strconv"
"strings"
"github.com/spf13/viper"
"github.com/tailscale/hujson"
"gopkg.in/yaml.v3"
)
@@ -99,14 +98,11 @@ func ReadFileByExt[T any](path string) (T, error) {
return UnmarshalByExt[T](path, data)
}
func AbsolutePathFromConfigPath(path string) string {
// If a relative path is provided, prefix it with the directory where
// the config file was found.
if (path != "") && !strings.HasPrefix(path, string(os.PathSeparator)) {
dir, _ := filepath.Split(viper.ConfigFileUsed())
if dir != "" {
path = filepath.Join(dir, path)
}
// AbsolutePath resolves a relative path from the configuration against
// configDir, the directory relative paths are read from.
func AbsolutePath(configDir, path string) string {
if path != "" && configDir != "" && !filepath.IsAbs(path) {
return filepath.Join(configDir, path)
}
return path
+48 -43
View File
@@ -25,6 +25,12 @@ import (
"tailscale.com/tailcfg"
)
// oidcClientFileRef is HEADSCALE_OIDC_CLIENT_SECRET for tests that write the
// mock provider's client secret to /tmp/hs_client_oidc_secret and set
// CREDENTIALS_DIRECTORY_TEST=/tmp. A named reference, not a literal per map,
// keeps gosec from reading it as a hardcoded credential.
const oidcClientFileRef = "file:${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret"
func TestOIDCAuthenticationPingAll(t *testing.T) {
IntegrationSkip(t)
@@ -46,10 +52,10 @@ func TestOIDCAuthenticationPingAll(t *testing.T) {
defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
}
// OIDC tests configure the mock OIDC provider via environment
@@ -364,10 +370,10 @@ func TestOIDC024UserCreation(t *testing.T) {
defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
}
maps.Copy(oidcMap, tt.config)
@@ -421,11 +427,11 @@ func TestOIDCAuthenticationWithPKCE(t *testing.T) {
defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_PKCE_ENABLED": "1", // Enable PKCE
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_PKCE_ENABLED": "1", // Enable PKCE
}
err = scenario.CreateHeadscaleEnvWithLoginURL(
@@ -477,10 +483,10 @@ func TestOIDCReloginSameNodeNewUser(t *testing.T) {
defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
}
err = scenario.CreateHeadscaleEnvWithLoginURL(
@@ -883,12 +889,11 @@ func TestOIDCFollowUpUrl(t *testing.T) {
defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
// smaller cache expiration time to quickly expire AuthURL
"HEADSCALE_TUNING_REGISTER_CACHE_CLEANUP": "10s",
"HEADSCALE_TUNING_REGISTER_CACHE_EXPIRATION": "1m30s",
}
@@ -997,10 +1002,10 @@ func TestOIDCMultipleOpenedLoginUrls(t *testing.T) {
defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
}
err = scenario.CreateHeadscaleEnvWithLoginURL(
@@ -1129,10 +1134,10 @@ func TestOIDCReloginSameNodeSameUser(t *testing.T) {
defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
}
err = scenario.CreateHeadscaleEnvWithLoginURL(
@@ -1353,11 +1358,11 @@ func TestOIDCExpiryAfterRestart(t *testing.T) {
defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"HEADSCALE_NODE_EXPIRY": "72h",
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
"HEADSCALE_NODE_EXPIRY": "72h",
}
err = scenario.CreateHeadscaleEnvWithLoginURL(
@@ -1498,10 +1503,10 @@ func TestOIDCACLPolicyOnJoin(t *testing.T) {
defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
}
// Create headscale environment with ACL policy that allows OIDC user
@@ -1776,10 +1781,10 @@ func TestOIDCReloginSameUserRoutesPreserved(t *testing.T) {
defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
}
err = scenario.CreateHeadscaleEnvWithLoginURL(
+1 -1
View File
@@ -231,7 +231,7 @@ func TestEphemeral2006DeletedTooQuickly(t *testing.T) {
headscale, err := scenario.Headscale(
hsic.WithTestName("ephemeral2006"),
hsic.WithConfigEnv(map[string]string{
"HEADSCALE_EPHEMERAL_NODE_INACTIVITY_TIMEOUT": "1m6s",
"HEADSCALE_NODE_EPHEMERAL_INACTIVITY_TIMEOUT": "1m6s",
}),
)
requireNoErrHeadscaleEnv(t, err)
+1 -4
View File
@@ -4,7 +4,6 @@ import "github.com/juanfont/headscale/hscontrol/types"
func MinimumConfigYAML() string {
return `
private_key_path: /tmp/private.key
noise:
private_key_path: /tmp/noise_private.key
`
@@ -18,17 +17,15 @@ func DefaultConfigEnv() map[string]string {
"HEADSCALE_DATABASE_SQLITE_PATH": "/tmp/integration_test_db.sqlite3",
"HEADSCALE_DATABASE_DEBUG": "0",
"HEADSCALE_DATABASE_GORM_SLOW_THRESHOLD": "1",
"HEADSCALE_EPHEMERAL_NODE_INACTIVITY_TIMEOUT": "30m",
"HEADSCALE_NODE_EPHEMERAL_INACTIVITY_TIMEOUT": "30m",
"HEADSCALE_PREFIXES_V4": "100.64.0.0/10",
"HEADSCALE_PREFIXES_V6": "fd7a:115c:a1e0::/48",
"HEADSCALE_DNS_BASE_DOMAIN": "headscale.net",
"HEADSCALE_DNS_MAGIC_DNS": "true",
"HEADSCALE_DNS_OVERRIDE_LOCAL_DNS": "false",
"HEADSCALE_DNS_NAMESERVERS_GLOBAL": "127.0.0.11 1.1.1.1",
"HEADSCALE_PRIVATE_KEY_PATH": "/tmp/private.key",
"HEADSCALE_NOISE_PRIVATE_KEY_PATH": "/tmp/noise_private.key",
"HEADSCALE_METRICS_LISTEN_ADDR": "0.0.0.0:9090",
"HEADSCALE_DEBUG_PORT": "40000",
// Embedded DERP is the default for test isolation.
// Tests should not depend on external DERP infrastructure.
+8 -9
View File
@@ -1053,10 +1053,10 @@ func TestSSHOneUserToOneCheckModeOIDC(t *testing.T) {
// defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
}
err = scenario.CreateHeadscaleEnvWithLoginURL(
@@ -1174,7 +1174,6 @@ func TestSSHCheckModeUnapprovedTimeout(t *testing.T) {
hsic.WithTestName("sshchecktimeout"),
hsic.WithConfigEnv(map[string]string{
"HEADSCALE_TUNING_REGISTER_CACHE_EXPIRATION": "15s",
"HEADSCALE_TUNING_REGISTER_CACHE_CLEANUP": "5s",
}),
)
require.NoError(t, err)
@@ -1666,10 +1665,10 @@ func TestSSHLocalpart(t *testing.T) {
defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
}
err = scenario.CreateHeadscaleEnvWithLoginURL(
+4 -4
View File
@@ -3642,10 +3642,10 @@ func TestTagsOIDCReauthAddOwnedTag(t *testing.T) {
defer scenario.ShutdownAssertNoPanics(t)
oidcMap := map[string]string{
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET_PATH": "${CREDENTIALS_DIRECTORY_TEST}/hs_client_oidc_secret",
"HEADSCALE_OIDC_ISSUER": scenario.mockOIDC.Issuer(),
"HEADSCALE_OIDC_CLIENT_ID": scenario.mockOIDC.ClientID(),
"CREDENTIALS_DIRECTORY_TEST": "/tmp",
"HEADSCALE_OIDC_CLIENT_SECRET": oidcClientFileRef,
}
// The OIDC user owns both tags. Ownership is what authorises the reauth tag
+12 -4
View File
@@ -20,8 +20,9 @@
services.headscale = {
enable = true;
# Optional: Use a specific package (defaults to pkgs.headscale)
# package = pkgs.headscale;
# Use this flake's headscale. The default, pkgs.headscale from nixpkgs,
# may predate settings this module writes, such as "file:" secrets.
# package = inputs.headscale.packages.${pkgs.stdenv.hostPlatform.system}.headscale;
# Listen on all interfaces (default is 127.0.0.1)
address = "0.0.0.0";
@@ -86,7 +87,7 @@
# port = 5432;
# name = "headscale";
# user = "headscale";
# password_file = "/run/secrets/headscale-db-password";
# pass = "file:\${CREDENTIALS_DIRECTORY}/db-password";
# };
};
@@ -100,7 +101,7 @@
# oidc = {
# issuer = "https://accounts.google.com";
# client_id = "your-client-id";
# client_secret_path = "/run/secrets/oidc-client-secret";
# client_secret = "file:\${CREDENTIALS_DIRECTORY}/oidc-client-secret";
# scope = [ "openid" "profile" "email" ];
# allowed_domains = [ "example.com" ];
# };
@@ -128,6 +129,13 @@
};
};
# Secrets: systemd copies each file into $CREDENTIALS_DIRECTORY, readable
# only by the service, and the settings above read it with "file:".
# systemd.services.headscale.serviceConfig.LoadCredential = [
# "db-password:/run/secrets/headscale-db-password"
# "oidc-client-secret:/run/secrets/oidc-client-secret"
# ];
# Optional: Open firewall ports
networking.firewall = {
allowedTCPPorts = [ 8080 ];
+19 -32
View File
@@ -290,16 +290,6 @@ in
example = "headscale";
description = "Database user.";
};
password_file = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
example = "/run/keys/headscale-dbpassword";
description = ''
A file containing the password corresponding to
{option}`database.user`.
'';
};
};
};
@@ -466,12 +456,12 @@ in
description = ''
DNS provider for ACME DNS-01 challenges. Every key besides
`name` is a setting of the provider; a text setting can be read
from a file by adding `_path` to its name.
from a file by setting it to `file:<path>`.
'';
example = lib.literalExpression ''
{
name = "cloudflare";
api_token_path = "''${CREDENTIALS_DIRECTORY}/cloudflare-token";
api_token = "file:\''${CREDENTIALS_DIRECTORY}/cloudflare-token";
}
'';
};
@@ -495,14 +485,6 @@ in
'';
};
client_secret_path = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
Path to OpenID Connect client secret file. Expands environment variables in format ''${VAR}.
'';
};
scope = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
@@ -597,8 +579,7 @@ in
'';
};
# Defaults are null so headscale falls back to the flat
# tls_letsencrypt_* keys still set in older configurations.
# Null is written as YAML null, which headscale treats as unset.
challenge_type = lib.mkOption {
type = lib.types.nullOr (
lib.types.enum [
@@ -688,10 +669,9 @@ in
[ "services" "headscale" "openIdConnect" "clientId" ]
[ "services" "headscale" "settings" "oidc" "client_id" ]
)
(mkRenamedOptionModule
[ "services" "headscale" "openIdConnect" "clientSecretFile" ]
[ "services" "headscale" "settings" "oidc" "client_secret_path" ]
)
(mkRemovedOptionModule [ "services" "headscale" "openIdConnect" "clientSecretFile" ] ''
Load the secret with systemd.services.headscale.serviceConfig.LoadCredential and set services.headscale.settings.oidc.client_secret = "file:\''${CREDENTIALS_DIRECTORY}/<name>".
'')
(mkRenamedOptionModule
[ "services" "headscale" "openIdConnect" "issuer" ]
[ "services" "headscale" "settings" "oidc" "issuer" ]
@@ -722,7 +702,7 @@ in
)
(mkRemovedOptionModule [ "services" "headscale" "openIdConnect" "domainMap" ] ''
Headscale no longer uses domain_map. If you're using an old version of headscale you can still set this option via services.headscale.settings.oidc.domain_map.
Headscale no longer uses domain_map.
'')
];
@@ -755,7 +735,7 @@ in
(assertRemovedOption [
"settings"
"db_password_file"
] "Use `database.postgres.password_file` instead.")
] "Use `database.postgres.pass = \"file:<path>\"` instead.")
(assertRemovedOption [ "settings" "db_path" ] "Use `database.sqlite.path` instead.")
(assertRemovedOption [ "settings" "db_port" ] "Use `database.postgres.port` instead.")
(assertRemovedOption [ "settings" "db_type" ] "Use `database.type` instead.")
@@ -777,6 +757,17 @@ in
"settings"
"ephemeral_node_inactivity_timeout"
] "Use `node.ephemeral.inactivity_timeout` instead.")
(assertRemovedOption [
"settings"
"database"
"postgres"
"password_file"
] "Use `database.postgres.pass = \"file:<path>\"` instead.")
(assertRemovedOption [
"settings"
"oidc"
"client_secret_path"
] "Use `oidc.client_secret = \"file:<path>\"` instead.")
];
services.headscale.settings = lib.mkMerge [
@@ -810,10 +801,6 @@ in
wantedBy = [ "multi-user.target" ];
script = ''
${lib.optionalString (cfg.settings.database.postgres.password_file != null) ''
export HEADSCALE_DATABASE_POSTGRES_PASS="$(head -n1 ${lib.escapeShellArg cfg.settings.database.postgres.password_file})"
''}
exec ${lib.getExe cfg.package} serve --config ${cfg.configFile}
'';
+3
View File
@@ -37,6 +37,9 @@ in
challenge.provider = {
name = "rfc2136";
server = "127.0.0.1:53";
key_name = "headscale.";
key_alg = "hmac-sha256.";
key = "c2VjcmV0";
};
};
};