config: give every key but server_url a working default

server_url alone, in a file or HEADSCALE_SERVER_URL, now passes check config.

Fixes #3567
Updates #1926
This commit is contained in:
Kristoffer Dalby committed 2026-11-11 15:02:16 +01:00
1 parent 57a18b8c41
commit 542fe8dd55
52 files changed
+2057 -201

No files matched your search

+35
View File
@@ -10,6 +10,7 @@ import (
"strings"
"testing"
"github.com/juanfont/headscale/hscontrol/config"
policyv2 "github.com/juanfont/headscale/hscontrol/policy/v2"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
@@ -200,6 +201,21 @@ func TestCheckConfig(t *testing.T) {
require.Equal(t, []string{"config.yaml"}, dirNames(t, dir))
})
t.Run("server_url only", func(t *testing.T) {
dir := t.TempDir()
cfg := writeFile(t, dir, "config.yaml", "server_url: https://headscale.example.com\n")
d := config.Default()
paths := []string{filepath.Dir(d.Noise.PrivateKeyPath), d.Noise.PrivateKeyPath, d.Database.Sqlite.Path}
before := existing(paths)
out, err := runCheck(t, checkConfigCmd, cfg)
require.NoError(t, err)
require.Equal(t, "Configuration "+cfg+" is valid\n", out)
require.Equal(t, []string{"config.yaml"}, dirNames(t, dir))
require.Equal(t, before, existing(paths), "the check created a default path")
})
t.Run("named files are not checked", func(t *testing.T) {
dir := t.TempDir()
writeFile(t, dir, "policy.hujson", badGroupPolicy)
@@ -229,6 +245,25 @@ func TestCheckConfig(t *testing.T) {
})
}
// TestCheckConfigEnvOnly: HEADSCALE_SERVER_URL alone, without a file, is a
// valid configuration.
func TestCheckConfigEnvOnly(t *testing.T) {
stdout, stderr, err := runHeadscale(t, []string{"HOME=" + t.TempDir(), "HEADSCALE_SERVER_URL=https://headscale.example.com"}, "check", "config")
require.NoError(t, err, stderr)
require.Equal(t, "Configuration (defaults and environment) is valid\n", stdout)
}
// existing reports, for each path, whether it exists.
func existing(paths []string) []bool {
out := make([]bool, len(paths))
for i, p := range paths {
_, err := os.Stat(p)
out[i] = err == nil
}
return out
}
func TestCheckAll(t *testing.T) {
t.Run("one line per file", func(t *testing.T) {
dir := t.TempDir()
+3
View File
@@ -73,6 +73,9 @@ func TestGenerateConfigRunningRoundTrip(t *testing.T) {
written[f.Path] = v
}
// database.type's example is its default, which would hide a dropped key.
written["database.type"] = string(types.DatabasePostgres)
// literal is written with a credential in every place one can hide.
literal := maps.Clone(written)
markers := []string{"marker-user", "marker-pass"}
+2 -2
View File
@@ -443,7 +443,7 @@ func (h *Headscale) refreshDERPMap(ctx context.Context) {
log.Info().Msg("fetching DERPMap updates")
derpMap, err := backoff.Retry(ctx, func() (*tailcfg.DERPMap, error) { //nolint:contextcheck
derpMap, err := derp.GetDERPMap(h.cfg.DERP, h.cfg.DNSConfig.BaseDomain)
derpMap, err := derp.GetDERPMap(h.cfg.DERP, h.cfg.DERPShuffleSeed())
if err != nil {
return nil, err
}
@@ -628,7 +628,7 @@ func (h *Headscale) Serve() error {
// Start on the sources that loaded; only a map with no region at all,
// after the embedded region and the policy's derpMap, is fatal.
derpMap, derpErr := derp.GetDERPMap(h.cfg.DERP, h.cfg.DNSConfig.BaseDomain)
derpMap, derpErr := derp.GetDERPMap(h.cfg.DERP, h.cfg.DERPShuffleSeed())
if derpErr != nil {
log.Warn().Err(derpErr).Msg("skipping DERP map sources that failed to load")
}
+4 -3
View File
@@ -277,9 +277,9 @@ func TestNewHeadscaleSecrets(t *testing.T) {
}
}
// validConfig is config.Default with what an operator must set, its files
// under a fresh temp dir, and the batcher quick and single-threaded for
// tests.
// validConfig is config.Default with a local server URL, its files under a
// fresh temp dir, the policy in the database, DNS off, and the batcher
// quick and single-threaded for tests.
func validConfig(t *testing.T) types.Config {
t.Helper()
@@ -297,6 +297,7 @@ func validConfig(t *testing.T) types.Config {
cfg.Policy.Mode = types.PolicyModeDB
cfg.DNSConfig.MagicDNS = false
cfg.DNSConfig.OverrideLocalDNS = false
cfg.DNSConfig.BaseDomain = ""
cfg.Tuning.BatchChangeDelay = 100 * time.Millisecond
cfg.Tuning.BatcherWorkers = 1
+17 -5
View File
@@ -1,6 +1,7 @@
package config
import (
"net/netip"
"time"
"github.com/coreos/go-oidc/v3/oidc"
@@ -8,16 +9,22 @@ import (
)
// Default is the configuration before a file or variable sets
// anything. database.type has no default.
// anything. Every key but server_url has a value a server starts with.
func Default() types.Config {
return types.Config{
Addr: "0.0.0.0:8080",
UnixSocket: "/var/run/headscale/headscale.sock",
UnixSocketPermission: 0o770,
Prefixes: types.PrefixesConfig{Allocation: types.IPAllocationStrategySequential},
Policy: types.PolicyConfig{Mode: types.PolicyModeFile},
Log: types.LogConfig{Level: "info", Format: types.TextLogFormat},
Noise: types.NoiseConfig{PrivateKeyPath: "/var/lib/headscale/noise_private.key"},
Prefixes: types.PrefixesConfig{
V4: new(netip.MustParsePrefix("100.64.0.0/10")),
V6: new(netip.MustParsePrefix("fd7a:115c:a1e0::/48")),
Allocation: types.IPAllocationStrategySequential,
},
Policy: types.PolicyConfig{Mode: types.PolicyModeFile},
Log: types.LogConfig{Level: "info", Format: types.TextLogFormat},
Node: types.NodeConfig{
Ephemeral: types.EphemeralConfig{InactivityTimeout: 120 * time.Second},
Ephemeral: types.EphemeralConfig{InactivityTimeout: 30 * time.Minute},
Routes: types.RouteConfig{HA: types.HARouteConfig{
ProbeInterval: 10 * time.Second,
ProbeTimeout: 5 * time.Second,
@@ -29,10 +36,14 @@ func Default() types.Config {
VerifyClients: true,
AutomaticallyAddEmbeddedDerpRegion: true,
},
URLs: []types.HTTPURL{"https://controlplane.tailscale.com/derpmap/default"},
AutoUpdate: true,
UpdateFrequency: 3 * time.Hour,
},
Database: types.DatabaseConfig{
Type: types.DatabaseSqliteShort,
Sqlite: types.SqliteConfig{
Path: "/var/lib/headscale/db.sqlite",
WriteAheadLog: true,
WALAutoCheckPoint: 1000, // SQLite default
},
@@ -45,6 +56,7 @@ func Default() types.Config {
},
DNSConfig: types.DNSConfig{
MagicDNS: true,
BaseDomain: types.DefaultBaseDomain,
OverrideLocalDNS: true,
Nameservers: types.Nameservers{Global: []string{}, Split: map[string][]string{}},
SearchDomains: []string{},
+45 -11
View File
@@ -13,8 +13,8 @@ import (
"github.com/stretchr/testify/require"
)
// validConfig is Default with the values it leaves to the operator set, so
// it passes Validate.
// validConfig is Default with a server URL, the one key Default leaves
// empty, so it passes Validate, and its own DNS base domain and resolver.
func validConfig() types.Config {
v4 := netip.MustParsePrefix("100.64.0.0/10")
@@ -40,8 +40,30 @@ func TestDefaultHoldsDefaults(t *testing.T) {
assert.Zero(t, d.Tuning.BatcherWorkers, "auto: its count depends on the host")
require.Equal(t, []string{"9.9.9.9:53", "149.112.112.112:53"}, d.DNSConfig.Challenge.Resolvers)
assert.Equal(t, types.ListenAddr("0.0.0.0:8080"), d.Addr)
assert.Empty(t, d.MetricsAddr)
assert.Equal(t, "/var/lib/headscale/noise_private.key", d.Noise.PrivateKeyPath)
require.NotNil(t, d.Prefixes.V4)
require.NotNil(t, d.Prefixes.V6)
assert.Equal(t, netip.MustParsePrefix("100.64.0.0/10"), *d.Prefixes.V4)
assert.Equal(t, netip.MustParsePrefix("fd7a:115c:a1e0::/48"), *d.Prefixes.V6)
assert.Equal(t, types.DatabaseSqliteShort, d.Database.Type)
assert.Equal(t, "/var/lib/headscale/db.sqlite", d.Database.Sqlite.Path)
assert.Equal(t, []types.HTTPURL{"https://controlplane.tailscale.com/derpmap/default"}, d.DERP.URLs)
assert.True(t, d.DERP.AutoUpdate)
assert.Equal(t, 3*time.Hour, d.DERP.UpdateFrequency)
assert.Equal(t, 30*time.Minute, d.Node.Ephemeral.InactivityTimeout)
assert.Equal(t, "tailnet.internal", d.DNSConfig.BaseDomain)
assert.Empty(t, d.DNSConfig.Nameservers.Global, "no third-party resolver unless the operator lists one")
d.DNSConfig.Challenge.Resolvers[0] = "changed"
assert.Equal(t, "9.9.9.9:53", Default().DNSConfig.Challenge.Resolvers[0], "each Default is its own copy")
d.DERP.URLs[0] = "https://changed.example.com/derpmap"
*d.Prefixes.V4 = netip.MustParsePrefix("10.0.0.0/8")
fresh := Default()
assert.Equal(t, "9.9.9.9:53", fresh.DNSConfig.Challenge.Resolvers[0], "each Default is its own copy")
assert.Equal(t, types.HTTPURL("https://controlplane.tailscale.com/derpmap/default"), fresh.DERP.URLs[0], "each Default is its own copy")
assert.Equal(t, netip.MustParsePrefix("100.64.0.0/10"), *fresh.Prefixes.V4, "each Default is its own copy")
}
// TestValidateHintsNameDefaults: the defaults Validate's hints quote, which
@@ -65,14 +87,7 @@ func TestValidateHintsNameDefaults(t *testing.T) {
func TestValidateGoData(t *testing.T) {
t.Run("default needs the operator's values", func(t *testing.T) {
d := Default()
assert.Equal(t, []string{
"noise.private_key_path is required",
"server_url is missing a scheme",
"dns.nameservers.global is required when dns.override_local_dns is true",
"database.type has an unsupported value",
"dns.base_domain is required when dns.magic_dns is true",
"no IP prefix configured for the tailnet",
}, reasons(types.ConfigErrors(Validate(&d))))
assert.Equal(t, []string{"server_url is missing a scheme"}, reasons(types.ConfigErrors(Validate(&d))))
})
t.Run("zero config", func(t *testing.T) {
@@ -212,6 +227,25 @@ func TestValidateGoData(t *testing.T) {
set: func(c *types.Config) { c.ServerURL = "headscale.example.com" },
wantErr: `server_url: "headscale.example.com"`,
},
// A variable cannot clear a key: `""` in one is the text itself.
{
name: "base domain quotes",
set: func(c *types.Config) { c.DNSConfig.BaseDomain = `""` },
wantErr: "dns.base_domain is not a DNS name",
},
{
name: "base domain underscore",
set: func(c *types.Config) { c.DNSConfig.BaseDomain = "tail_net.example.com" },
wantErr: "dns.base_domain is not a DNS name",
},
{
name: "base domain trailing dot",
set: func(c *types.Config) { c.DNSConfig.BaseDomain = "tailnet.example.com." },
},
{
name: "base domain uppercase",
set: func(c *types.Config) { c.DNSConfig.BaseDomain = "Tailnet.Example.com" },
},
// One error per problem: the rules that predate the value checks
// keep only the empty value.
{
+2 -1
View File
@@ -146,7 +146,8 @@ func TestGenerateExample(t *testing.T) {
assert.Contains(t, above, types.ConfigFields(&d)[serverURL].Doc)
assert.Contains(t, above, "Required. Example: https://headscale.example.com")
assert.Contains(t, commentAbove(text, ` level: info`), "One of: `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `panic`, `disabled`.")
assert.Contains(t, commentAbove(text, ` base_domain: ""`), "Required when `dns.magic_dns` is true.")
require.Contains(t, text, "\n base_domain: tailnet.internal\n")
assert.NotContains(t, commentAbove(text, ` base_domain: tailnet.internal`), "Required when")
assert.Contains(t, commentAbove(text, ` batcher_workers: 0`), "Default: three quarters of the CPU cores, at least one.")
assert.Equal(t, len(wantTop), strings.Count(text, "\n\n"), "one blank line before each top-level key")
})
+79 -4
View File
@@ -16,6 +16,7 @@ import (
"slices"
"strconv"
"strings"
"sync"
"time"
"github.com/go-viper/mapstructure/v2"
@@ -62,6 +63,9 @@ type configSource struct {
// keys is the file parsed for the positions of its keys, or nil.
keys *keyNode
warnings []string
// nulls are the file's keys written with no value whose default
// clearableDefaults holds.
nulls []string
// envVars names the variable that set each key, for errors.
envVars map[string]string
}
@@ -439,6 +443,9 @@ func Load(path string, isFile bool, environ []string) (*Loaded, error) {
}
l.Config, err = s.decode()
if err == nil {
l.Warnings = append(l.Warnings, s.nullWarnings()...)
}
return l, err
}
@@ -504,6 +511,8 @@ func (s *configSource) loadFile() error {
return fmt.Errorf("fatal error reading config file %s: %w", s.file, err)
}
s.findNulls(m, "")
var errs []error
m = normaliseConfigMap(m, "", func(path, a, b string) {
@@ -528,6 +537,68 @@ func (s *configSource) loadFile() error {
return nil
}
// findNulls records each key of m, written below path, that is null where
// clearableDefaults has its default.
func (s *configSource) findNulls(m map[string]any, path string) {
for _, k := range slices.Sorted(maps.Keys(m)) {
p := joinConfigPath(path, keyCase(path, k))
switch v := m[k].(type) {
case map[string]any:
s.findNulls(v, p)
case nil:
if _, ok := clearableDefaults()[p]; ok {
s.nulls = append(s.nulls, p)
}
}
}
}
// nullWarnings warns for each of s.nulls no variable sets: null means
// unset, so the key keeps a default its writer most likely meant to clear.
func (s *configSource) nullWarnings() []string {
out := make([]string, 0, len(s.nulls))
for _, p := range s.nulls {
if _, env := s.envVars[p]; env {
continue
}
def := clearableDefaults()[p]
text, err := flowYAML(def)
if err != nil {
text = fmt.Sprint(def)
}
out = append(out, fmt.Sprintf("%s has no value in %s, so it takes its default %s", p, s.file, text))
}
return out
}
// clearableDefaults are the leaves of Default that "" or [] empties, by
// path, each with its default as plainFields writes it: the non-empty
// texts, lists and prefixes. An enum has no empty value.
var clearableDefaults = sync.OnceValue(func() map[string]any {
d := Default()
out := map[string]any{}
for _, f := range types.ConfigFields(&d) {
_, enum := reflect.TypeAssert[interface{ Allowed() []string }](f.Value)
switch k := f.Value.Kind(); {
case enum:
case k == reflect.String && f.Value.Len() > 0,
k == reflect.Slice && f.Value.Len() > 0,
k == reflect.Pointer && !f.Value.IsNil():
out[f.Path] = plainValue(f.Value, true)
}
}
return out
})
// configKeySets derives the lookup sets the strict pass needs.
func configKeySets() (map[string]bool, map[string]bool) {
leaf, branch := map[string]bool{}, map[string]bool{}
@@ -1354,10 +1425,11 @@ func plainMap(cfg *types.Config, redact bool) map[string]any {
}
// plainFields is every leaf of cfg by path, as a parser writes it: nil
// for a nil list or map, "" for a nil prefix. With redact, a secret shows
// only a file: reference, a URL no userinfo, and every DNS provider
// setting but a scalar name and file: references is hidden: any of them,
// a number included, may be a credential.
// for a nil list or map, [] for a nil list whose default is not empty, ""
// for a nil prefix. With redact, a secret shows only a file: reference, a
// URL no userinfo, and every DNS provider setting but a scalar name and
// file: references is hidden: any of them, a number included, may be a
// credential.
func plainFields(cfg *types.Config, redact bool) map[string]any {
out := map[string]any{}
@@ -1374,6 +1446,9 @@ func plainFields(cfg *types.Config, redact bool) map[string]any {
case f.Field.Type == prefixPtrType && f.Value.IsNil():
// An explicit unset, which survives a default.
v = ""
case f.Value.Kind() == reflect.Slice && f.Value.IsNil() && clearableDefaults()[f.Path] != nil:
// An explicit empty list, which survives a non-empty default.
v = []any{}
case redact && isMap && f.Path == providerKey:
v = redactProvider(settings)
}
+172 -11
View File
@@ -863,11 +863,174 @@ func TestDefaultsFitTypes(t *testing.T) {
cfg, err := decodeInput(t, "", "")
require.NoError(t, err)
if diff := gocmp.Diff(d, *cfg, cmpopts.IgnoreFields(types.Config{}, "ConfigDir"), cmpopts.IgnoreUnexported(types.Config{})); diff != "" {
if diff := gocmp.Diff(d, *cfg, cmpopts.IgnoreFields(types.Config{}, "ConfigDir"), cmpopts.IgnoreUnexported(types.Config{}), cmpopts.EquateComparable(netip.Prefix{})); diff != "" {
t.Errorf("defaults layer (-Default +decoded):\n%s", diff)
}
}
// TestDefaultsCanBeCleared: a key with a default can still be emptied, in
// the file or, for a list, with "[]" in a variable. An empty variable
// counts as unset, so a variable cannot empty a text or a prefix.
func TestDefaultsCanBeCleared(t *testing.T) {
const serverURL = "server_url: https://headscale.example.com\n"
d := Default()
tests := []struct {
name string
file string
env []string
check func(*testing.T, *types.Config)
wantErr string // a reason Validate gives
}{
{
name: "file derp urls",
file: "derp:\n urls: []\n",
check: func(t *testing.T, c *types.Config) { t.Helper(); assert.Empty(t, c.DERP.URLs) },
},
{
name: "file prefix v4",
file: "prefixes:\n v4: \"\"\n",
check: func(t *testing.T, c *types.Config) {
t.Helper()
assert.Nil(t, c.Prefixes.V4)
require.NotNil(t, c.Prefixes.V6)
assert.Equal(t, *d.Prefixes.V6, *c.Prefixes.V6)
},
},
{
name: "file base domain",
file: "dns:\n magic_dns: false\n base_domain: \"\"\n",
check: func(t *testing.T, c *types.Config) { t.Helper(); assert.Empty(t, c.DNSConfig.BaseDomain) },
},
{
name: "env derp urls",
env: []string{"HEADSCALE_DERP_URLS=[]"},
check: func(t *testing.T, c *types.Config) { t.Helper(); assert.Empty(t, c.DERP.URLs) },
},
{
name: "empty env keeps the default",
env: []string{"HEADSCALE_DERP_URLS="},
check: func(t *testing.T, c *types.Config) { t.Helper(); assert.Equal(t, d.DERP.URLs, c.DERP.URLs) },
},
{
name: "empty env keeps a prefix",
env: []string{"HEADSCALE_PREFIXES_V6="},
check: func(t *testing.T, c *types.Config) {
t.Helper()
require.NotNil(t, c.Prefixes.V6)
assert.Equal(t, *d.Prefixes.V6, *c.Prefixes.V6)
},
},
{
name: "quotes in env are text",
env: []string{"HEADSCALE_DNS_MAGIC_DNS=false", `HEADSCALE_DNS_BASE_DOMAIN=""`},
wantErr: "dns.base_domain is not a DNS name",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
l, err := Load(writeConfig(t, serverURL+tt.file), true, tt.env)
require.NoError(t, err)
err = Validate(l.Config)
if tt.wantErr != "" {
assert.Equal(t, []string{tt.wantErr}, reasons(types.ConfigErrors(err)))
return
}
require.NoError(t, err)
tt.check(t, l.Config)
})
}
}
// TestNullTakesDefault: a key written with no value is unset and takes its
// default, so where that default is a non-empty text, list or prefix and
// no variable sets the key, loading warns.
func TestNullTakesDefault(t *testing.T) {
const serverURL = "server_url: https://headscale.example.com\n"
tests := []struct {
name string
file string
ext string // ".yaml" when ""
env []string
warns []string
check func(*testing.T, *types.Config)
}{
{
name: "list",
file: serverURL + "derp:\n urls:\n",
warns: []string{"derp.urls has no value in $FILE, so it takes its default ['https://controlplane.tailscale.com/derpmap/default']"},
check: func(t *testing.T, c *types.Config) { t.Helper(); assert.Equal(t, Default().DERP.URLs, c.DERP.URLs) },
},
{
name: "prefix",
file: serverURL + "prefixes:\n v6:\n",
warns: []string{`prefixes.v6 has no value in $FILE, so it takes its default fd7a:115c:a1e0::/48`},
check: func(t *testing.T, c *types.Config) { t.Helper(); assert.NotNil(t, c.Prefixes.V6) },
},
{
name: "text, dotted",
file: serverURL + "dns.magic_dns: false\ndns.base_domain:\n",
warns: []string{`dns.base_domain has no value in $FILE, so it takes its default tailnet.internal`},
},
{
name: "required while magic_dns is on",
file: serverURL + "dns:\n base_domain:\n",
warns: []string{`dns.base_domain has no value in $FILE, so it takes its default tailnet.internal`},
},
{
name: "required",
file: serverURL + "noise:\n private_key_path:\n",
warns: []string{`noise.private_key_path has no value in $FILE, so it takes its default /var/lib/headscale/noise_private.key`},
},
{
name: "json null",
file: `{"server_url": "https://headscale.example.com", "dns": {"magic_dns": false, "base_domain": null}}`,
ext: ".json",
warns: []string{`dns.base_domain has no value in $FILE, so it takes its default tailnet.internal`},
},
{
name: "set by a variable",
file: serverURL + "derp:\n urls:\n",
env: []string{`HEADSCALE_DERP_URLS=["https://d.example.com/m.json"]`},
check: func(t *testing.T, c *types.Config) {
t.Helper()
assert.Equal(t, []types.HTTPURL{"https://d.example.com/m.json"}, c.DERP.URLs)
},
},
{name: "enum", file: serverURL + "log:\n level:\n"},
{name: "empty default", file: serverURL + "derp:\n paths:\n"},
{name: "section", file: serverURL + "derp:\n"},
{name: "empty list", file: serverURL + "derp:\n urls: []\n"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
path := filepath.Join(t.TempDir(), "config"+cmp.Or(tt.ext, ".yaml"))
require.NoError(t, os.WriteFile(path, []byte(tt.file), 0o600))
l, err := Load(path, true, tt.env)
require.NoError(t, err)
var want []string
for _, w := range tt.warns {
want = append(want, strings.ReplaceAll(w, "$FILE", path))
}
assert.Equal(t, want, l.Warnings)
if tt.check != nil {
tt.check(t, l.Config)
}
})
}
}
func TestPlainMap(t *testing.T) {
v4 := netip.MustParsePrefix("100.64.0.0/10")
cfg := &types.Config{
@@ -1238,14 +1401,6 @@ func TestReadConfig(t *testing.T) {
},
wantErr: "",
},
{
name: "dns-override-true-errors",
configPath: "testdata/dns-override-true-error.yaml",
setup: func(t *testing.T, cfg *types.Config) (any, error) { //nolint:thelper
return nil, Validate(cfg)
},
wantErr: "Fatal config error: dns.nameservers.global is required when dns.override_local_dns is true",
},
{
name: "dns-override-true",
configPath: "testdata/dns-override-true.yaml",
@@ -3054,7 +3209,10 @@ func unsetHeadscaleEnv(t *testing.T) {
// hsic-* mirror integration/hsic's
// MinimumConfigYAML and DefaultConfigEnv. <name>-strict is the same source
// as updated for the strict loader, <name>-pruned without the keys removed
// for having no effect.
// for having no effect. hsic-default-derp-urls is hsic-default-strict with
// HEADSCALE_DERP_URLS=[], as hsic writes it to clear the default map.
// server-url-only and env-server-url-only set only server_url, in the file
// and in a variable.
func TestConfigCompat(t *testing.T) {
rows := compatRows(t)
update := os.Getenv("HEADSCALE_UPDATE_GOLDEN") != ""
@@ -3766,8 +3924,11 @@ dns:
listen_addr: 0.0.0.0:8080
metrics_listen_addr: 0.0.0.0:8080
trusted_proxies: [0.0.0.0/0]
noise:
private_key_path: ""
prefixes:
v4: ""
v6: ""
allocation: ""
policy:
mode: ""
@@ -3787,6 +3948,7 @@ database:
type: ""
dns:
magic_dns: true
base_domain: ""
override_local_dns: true
extra_records: [{name: a.example.com, type: A, value: 100.64.0.1}]
extra_records_path: /var/lib/headscale/records.json
@@ -3814,7 +3976,6 @@ oidc:
"tls.acme.challenge_type has an unsupported value",
"server_url is missing a scheme",
"node.ephemeral.inactivity_timeout is below the minimum",
"dns.nameservers.global is required when dns.override_local_dns is true",
"node.routes.ha.probe_interval is below the minimum",
"node.routes.ha.probe_timeout must be less than node.routes.ha.probe_interval",
"tuning.node_store_batch_size must be positive",
+13 -4
View File
@@ -56,16 +56,25 @@ var roundTripOpts = gocmp.Options{
func TestRoundTrip(t *testing.T) {
unsetHeadscaleEnv(t)
rows := append([]compatRow{{name: "default"}}, compatRows(t)...)
rows := append([]compatRow{{name: "default"}, {name: "nil lists"}}, compatRows(t)...)
for _, row := range rows {
t.Run(row.name, func(t *testing.T) {
var cfg *types.Config
if row.name == "default" {
switch row.name {
case "default":
d := Default()
cfg = &d
} else {
case "nil lists":
// A Go-built config's nil lists must not reload as their defaults.
d := Default()
d.DERP.URLs = nil
d.DNSConfig.Nameservers.Global = nil
d.DNSConfig.Challenge.Resolvers = nil
d.OIDC.Scope = nil
cfg = &d
default:
l, err := Load(stageCompat(t, row.file, row.envFile), false, os.Environ())
if err != nil {
t.Skipf("does not load: %v", err)
@@ -210,7 +219,7 @@ func TestRoundTripValues(t *testing.T) {
// which wins over a layer below that sets it.
func TestMarshalNullablePrefix(t *testing.T) {
cfg := Default()
require.Nil(t, cfg.Prefixes.V4)
cfg.Prefixes.V4 = nil
yamlOut, err := Marshal(&cfg, ".yaml")
require.NoError(t, err)
+12 -1
View File
@@ -188,7 +188,7 @@ func TestGenerateNixOptions(t *testing.T) {
hide []string
}{
{path: "server_url", want: []string{"\n example = \"https://", "Required."}, hide: []string{"\n default = "}},
{path: "dns.base_domain", want: []string{"\n default = \"\";\n", "Required when `dns.magic_dns`"}},
{path: "dns.base_domain", want: []string{"\n default = \"tailnet.internal\";\n"}, hide: []string{"Required"}},
{
path: "database.type",
want: []string{
@@ -257,6 +257,17 @@ func TestGenerateNixOptions(t *testing.T) {
}
})
}
// Built by hand, so the rendering is pinned whatever Default requires.
t.Run("required when", func(t *testing.T) {
k := schemaByPath(t)["dns.base_domain"]
k.Required, k.RequiredWhen = true, "`dns.magic_dns` is true"
opt, err := nixOption(k, 0)
require.NoError(t, err)
assert.Contains(t, opt, "\n default = \"tailnet.internal\";\n")
assert.Contains(t, opt, "Required when `dns.magic_dns` is true.")
})
}
func TestNixLiteral(t *testing.T) {
+4 -1
View File
@@ -29,7 +29,10 @@ const (
referenceEnv = "### Environment variables { #env }\n\n" +
"Every key can also be set with an environment variable: `HEADSCALE_` and the key's path in capitals, with `_` for\n" +
"`.`, e.g. `HEADSCALE_LOG_LEVEL` for `log.level`. Each key below names its variable. A variable wins over the\n" +
"configuration file, which wins over the default; an empty variable counts as unset.\n\n" +
"configuration file, which wins over the default. An empty variable, like a key written with no value in the\n" +
"file, counts as unset and keeps the default. Clear a list with `[]`, as in `HEADSCALE_DERP_URLS='[]'` or\n" +
"`HEADSCALE_DNS_NAMESERVERS_GLOBAL='[]'`; any other key with a default clears only in the configuration file, as\n" +
"in `prefixes.v6: \"\"`.\n\n" +
"A list is a JSON array or, unless its values are objects, its values separated by spaces. A map is a JSON object,\n" +
"which replaces the map in the configuration file instead of merging into it. The examples below write every list\n" +
"and map as JSON.\n\n" +
+12 -2
View File
@@ -188,10 +188,10 @@ func TestReferenceKeys(t *testing.T) {
{path: "server_url", want: []string{"\n- **Required**\n", "\n export HEADSCALE_SERVER_URL=https://headscale.example.com\n"}},
{path: "database.type", want: []string{
"- **Type:** [enum](#type-enum): `sqlite`, `sqlite3`, `postgres`\n",
"- **Required**\n",
"- **Default:** `sqlite`\n",
"| `postgres` | PostgreSQL, at [`database.postgres.host`](#database.postgres.host). ",
}},
{path: "dns.base_domain", want: []string{"- **Default:** `\"\"`; required when [`dns.magic_dns`](#dns.magic_dns) is true\n"}},
{path: "dns.base_domain", want: []string{"- **Default:** `tailnet.internal`\n"}, hide: []string{"required"}},
{path: "tuning.batcher_workers", want: []string{"- **Default:** `0` (three quarters of the CPU cores, at least one)\n"}},
{path: "unix_socket_permission", want: []string{"- **Type:** [file mode](#type-file-mode)\n", "- **Default:** `\"0770\"`\n"}},
{path: "dns.nameservers.split", want: []string{
@@ -242,6 +242,16 @@ func TestReferenceKeys(t *testing.T) {
}
})
}
// Built by hand, so the rendering is pinned whatever Default requires.
t.Run("required when", func(t *testing.T) {
k := schemaByPath(t)["dns.base_domain"]
k.Required, k.RequiredWhen = true, "`dns.magic_dns` is true"
r := &reference{paths: map[string]bool{"dns.magic_dns": true}}
require.NoError(t, r.facts(k))
require.Contains(t, r.String(), "- **Default:** `tailnet.internal`; required when [`dns.magic_dns`](#dns.magic_dns) is true\n")
})
}
// TestOpenMapDocs: the page prints an open map's key case only through its
+9 -12
View File
@@ -77,7 +77,7 @@ func TestSchemaTypes(t *testing.T) {
want: typeInfo{Label: "list of prefixes", Anchor: "#type-list", Env: "space-separated or JSON array", Nix: "lib.types.listOf t.prefix"},
def: []any{},
},
{path: "prefixes.v4", want: typeInfo{Label: "prefix", Anchor: "#type-prefix", Nix: "t.prefix"}, def: ""},
{path: "prefixes.v4", want: typeInfo{Label: "prefix", Anchor: "#type-prefix", Nix: "t.prefix"}, def: "100.64.0.0/10"},
{
path: "dns.nameservers.split",
want: typeInfo{Label: "map of `<domain>` → list of strings", Anchor: "#type-map", Env: "JSON object", Nix: "lib.types.attrsOf (lib.types.listOf lib.types.str)"},
@@ -97,11 +97,11 @@ func TestSchemaTypes(t *testing.T) {
mapKey: "setting",
},
{path: "database.postgres.pass", want: typeInfo{Label: "secret", Anchor: "#secrets", Nix: "t.secretFile"}, def: ""},
{path: "database.type", want: typeInfo{Label: "enum", Anchor: "#type-enum", Enum: types.DatabaseType("").Allowed()}, def: ""},
{path: "database.type", want: typeInfo{Label: "enum", Anchor: "#type-enum", Enum: types.DatabaseType("").Allowed()}, def: "sqlite"},
{path: "dns.extra_records", want: typeInfo{Label: "list of DNS records", Anchor: "#type-list", Env: "JSON array"}, def: []any{}},
{path: "derp.urls", want: typeInfo{Label: "list of URLs", Anchor: "#type-list", Env: "space-separated or JSON array", Nix: "lib.types.listOf t.httpURL"}, def: []any{}},
{path: "derp.urls", want: typeInfo{Label: "list of URLs", Anchor: "#type-list", Env: "space-separated or JSON array", Nix: "lib.types.listOf t.httpURL"}, def: []any{"https://controlplane.tailscale.com/derpmap/default"}},
{path: "derp.server.region_id", want: typeInfo{Label: "integer", Anchor: "#type-integer", Nix: "lib.types.int"}, def: 0},
{path: "listen_addr", want: typeInfo{Label: "listen address", Anchor: "#type-listen-address", Nix: "t.listenAddr"}, def: ""},
{path: "listen_addr", want: typeInfo{Label: "listen address", Anchor: "#type-listen-address", Nix: "t.listenAddr"}, def: "0.0.0.0:8080"},
{path: "dns.magic_dns", want: typeInfo{Label: "boolean", Anchor: "#type-boolean", Nix: "lib.types.bool"}, def: true},
{
path: "tuning.batcher_workers",
@@ -243,7 +243,10 @@ func TestExamples(t *testing.T) {
example := jsonText(t, k.Example)
require.JSONEq(t, tag, example)
require.NotEqual(t, jsonText(t, k.Default), example, "example equals the default")
// Any other backend as the example would recommend postgres.
if k.Path != "database.type" {
require.NotEqual(t, jsonText(t, k.Default), example, "example equals the default")
}
if k.Field.Type == reflect.TypeFor[types.Secret]() {
require.True(t, strings.HasPrefix(k.Example.(string), "file:/run/secrets/"), k.Example) //nolint:forcetypeassert // a secret is text
@@ -286,13 +289,7 @@ func TestExamples(t *testing.T) {
}
func TestRequiredKeys(t *testing.T) {
want := map[string]string{
"server_url": "",
"noise.private_key_path": "",
"database.type": "",
"dns.base_domain": "`dns.magic_dns` is true",
"dns.nameservers.global": "`dns.override_local_dns` is true",
}
want := map[string]string{"server_url": ""}
got, err := requiredKeys()
require.NoError(t, err)
+7 -7
View File
@@ -1,13 +1,13 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -20,10 +20,10 @@
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": null,
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"Log": {
"Format": "text",
"Level": "debug"
@@ -80,7 +80,7 @@
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
@@ -99,7 +99,7 @@
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
@@ -110,7 +110,7 @@
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {},
+22 -8
View File
@@ -1,13 +1,13 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -20,10 +20,10 @@
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": null,
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"Log": {
"Format": "text",
"Level": "info"
@@ -63,10 +63,24 @@
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
@@ -85,7 +99,7 @@
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
@@ -102,7 +116,7 @@
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {
+22 -8
View File
@@ -1,13 +1,13 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -20,10 +20,10 @@
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": null,
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"Log": {
"Format": "text",
"Level": "info"
@@ -63,10 +63,24 @@
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
@@ -85,7 +99,7 @@
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
@@ -96,7 +110,7 @@
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {},
+22 -8
View File
@@ -1,13 +1,13 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -20,10 +20,10 @@
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": null,
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"Log": {
"Format": "text",
"Level": "info"
@@ -63,10 +63,24 @@
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
@@ -85,7 +99,7 @@
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
@@ -96,7 +110,7 @@
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {},
+22 -8
View File
@@ -1,13 +1,13 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -20,10 +20,10 @@
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": null,
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"Log": {
"Format": "text",
"Level": "info"
@@ -63,10 +63,24 @@
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
@@ -85,7 +99,7 @@
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [
@@ -106,7 +120,7 @@
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {
+22 -8
View File
@@ -1,13 +1,13 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -20,10 +20,10 @@
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": null,
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"Log": {
"Format": "text",
"Level": "info"
@@ -63,10 +63,24 @@
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
@@ -85,7 +99,7 @@
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
@@ -100,7 +114,7 @@
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {
+22 -8
View File
@@ -1,13 +1,13 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -20,10 +20,10 @@
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": null,
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"Log": {
"Format": "text",
"Level": "info"
@@ -63,10 +63,24 @@
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
@@ -85,7 +99,7 @@
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
@@ -96,7 +110,7 @@
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {},
+22 -8
View File
@@ -1,13 +1,13 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -20,10 +20,10 @@
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": null,
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"Log": {
"Format": "text",
"Level": "warn"
@@ -63,10 +63,24 @@
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
@@ -85,7 +99,7 @@
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
@@ -102,7 +116,7 @@
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {
+22 -8
View File
@@ -1,13 +1,13 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -20,10 +20,10 @@
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": null,
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"Log": {
"Format": "text",
"Level": "info"
@@ -63,10 +63,24 @@
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
@@ -85,7 +99,7 @@
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
@@ -96,7 +110,7 @@
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {},
@@ -0,0 +1 @@
HEADSCALE_SERVER_URL=https://headscale.example.com
+180
View File
@@ -0,0 +1,180 @@
{
"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.internal",
"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": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": true,
"Nameservers": {
"Global": [],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {
"Domains": [
"tailnet.internal"
],
"Proxied": true
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"9.9.9.9:53",
"149.112.112.112: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": {
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 900000000000,
"RegisterCacheMaxEntries": 1024,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
}
+7 -7
View File
@@ -1,7 +1,7 @@
{
"config": {
"ServerURL": "https://hs.example.com",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": [
"10.0.0.0/8",
@@ -10,7 +10,7 @@
"Node": {
"Expiry": 7776000000000000,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -23,10 +23,10 @@
"RevokedRetention": 604800000000000
},
"PrefixV4": "100.64.0.0/10",
"PrefixV6": null,
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "/var/lib/headscale/noise.key",
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"Log": {
"Format": "text",
"Level": "info"
@@ -96,7 +96,7 @@
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 30000000000,
"IPv4": "",
"IPv6": ""
@@ -115,7 +115,7 @@
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [
@@ -135,7 +135,7 @@
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {
+1 -1
View File
@@ -42,7 +42,7 @@
"ParameterizedQueries": true
},
"Sqlite": {
"Path": "",
"Path": "/var/lib/headscale/db.sqlite",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
@@ -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
+177
View File
@@ -0,0 +1,177 @@
{
"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": [
"9.9.9.9:53",
"149.112.112.112: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": {
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 900000000000,
"RegisterCacheMaxEntries": 1024,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
}
@@ -0,0 +1,2 @@
noise:
private_key_path: /tmp/noise_private.key
+15 -1
View File
@@ -63,7 +63,21 @@
"ServerPrivateKeyPath": "/tmp/derp.key",
"ServerVerifyClients": true,
"STUNAddr": "0.0.0.0:3478",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
+16 -2
View File
@@ -39,7 +39,7 @@
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "",
"Path": "/var/lib/headscale/db.sqlite",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
@@ -63,7 +63,21 @@
"ServerPrivateKeyPath": "/tmp/derp.key",
"ServerVerifyClients": true,
"STUNAddr": "0.0.0.0:3478",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
+4 -1
View File
@@ -187,5 +187,8 @@
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
},
"warnings": [
"tls.acme.http_listen has no value in $DIR/config.yaml, so it takes its default :http"
]
}
+4 -1
View File
@@ -187,5 +187,8 @@
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
},
"warnings": [
"tls.acme.http_listen has no value in $DIR/config.yaml, so it takes its default :http"
]
}
+4 -1
View File
@@ -187,5 +187,8 @@
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
},
"warnings": [
"tls.acme.http_listen has no value in $DIR/config.yaml, so it takes its default :http"
]
}
+180
View File
@@ -0,0 +1,180 @@
{
"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.internal",
"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": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": true,
"Nameservers": {
"Global": [],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {
"Domains": [
"tailnet.internal"
],
"Proxied": true
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"9.9.9.9:53",
"149.112.112.112: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": {
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 900000000000,
"RegisterCacheMaxEntries": 1024,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
}
+1
View File
@@ -0,0 +1 @@
server_url: https://headscale.example.com
@@ -1,13 +1,13 @@
{
"config": {
"ServerURL": "https://derp.no",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -39,7 +39,7 @@
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "",
"Path": "/var/lib/headscale/db.sqlite",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
@@ -63,10 +63,24 @@
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
@@ -1,3 +1,3 @@
{
"error": "Fatal config error: dns.nameservers.global is required when dns.override_local_dns is true\n current: dns.override_local_dns: true, dns.nameservers.global: \"[]\"\n hint: list at least one upstream nameserver, or set dns.override_local_dns: false\n see: https://headscale.net/stable/ref/dns/\n\nFatal config error: server_url is a subdomain of dns.base_domain\n current: server_url: \"https://server.derp.no\", dns.base_domain: \"derp.no\"\n hint: host headscale on a domain outside dns.base_domain (Tailscale takes over base_domain via MagicDNS)\n see: https://headscale.net/stable/ref/dns/\n"
"error": "Fatal config error: server_url is a subdomain of dns.base_domain\n current: server_url: \"https://server.derp.no\", dns.base_domain: \"derp.no\"\n hint: host headscale on a domain outside dns.base_domain (Tailscale takes over base_domain via MagicDNS)\n see: https://headscale.net/stable/ref/dns/\n"
}
+19 -5
View File
@@ -1,13 +1,13 @@
{
"config": {
"ServerURL": "https://server.derp.no",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -39,7 +39,7 @@
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "",
"Path": "/var/lib/headscale/db.sqlite",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
@@ -63,10 +63,24 @@
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
+252 -1
View File
@@ -1,3 +1,254 @@
{
"error": "Fatal config error: database.type has an unsupported value\n current: database.type: \"\"\n allowed: \"sqlite\", \"sqlite3\", \"postgres\"\n hint: pick one of the allowed values; sqlite is the default for single-host deployments\n see: https://headscale.net/stable/ref/database/\n\nFatal config error: no IP prefix configured for the tailnet\n current: prefixes.v4: \"\", prefixes.v6: \"\"\n hint: set at least one of prefixes.v4 (default: \"100.64.0.0/10\") or prefixes.v6 (default: \"fd7a:115c:a1e0::/48\")\n"
"config": {
"ServerURL": "https://derp.no",
"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": "$DIR/private_key.pem",
"BaseDomain": "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": "",
"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": null,
"DERPMap": null,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "example.com",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [
"1.1.1.1",
"1.0.0.1",
"2606:4700:4700::1111",
"2606:4700:4700::1001",
"https://dns.nextdns.io/abc123"
],
"Split": {
"darp.headscale.net": [
"1.1.1.1",
"8.8.8.8"
],
"foo.bar.com": [
"1.1.1.1"
]
}
},
"SearchDomains": [
"test.com",
"bar.com"
],
"ExtraRecords": [
{
"Name": "grafana.myvpn.example.com",
"Type": "A",
"Value": "100.64.0.3"
},
{
"Name": "prometheus.myvpn.example.com",
"Type": "A",
"Value": "100.64.0.4"
}
],
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "example.com"
}
},
"TailcfgDNSConfig": {
"Routes": {
"darp.headscale.net": [
{
"Addr": "1.1.1.1"
},
{
"Addr": "8.8.8.8"
}
],
"foo.bar.com": [
{
"Addr": "1.1.1.1"
}
]
},
"FallbackResolvers": [
{
"Addr": "1.1.1.1"
},
{
"Addr": "1.0.0.1"
},
{
"Addr": "2606:4700:4700::1111"
},
{
"Addr": "2606:4700:4700::1001"
},
{
"Addr": "https://dns.nextdns.io/abc123"
}
],
"Domains": [
"example.com",
"test.com",
"bar.com"
],
"Proxied": true,
"ExtraRecords": [
{
"Name": "grafana.myvpn.example.com",
"Type": "A",
"Value": "100.64.0.3"
},
{
"Name": "prometheus.myvpn.example.com",
"Type": "A",
"Value": "100.64.0.4"
}
]
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"9.9.9.9:53",
"149.112.112.112: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": {
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 900000000000,
"RegisterCacheMaxEntries": 1024,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
}
+250 -1
View File
@@ -1,3 +1,252 @@
{
"error": "Fatal config error: database.type has an unsupported value\n current: database.type: \"\"\n allowed: \"sqlite\", \"sqlite3\", \"postgres\"\n hint: pick one of the allowed values; sqlite is the default for single-host deployments\n see: https://headscale.net/stable/ref/database/\n\nFatal config error: no IP prefix configured for the tailnet\n current: prefixes.v4: \"\", prefixes.v6: \"\"\n hint: set at least one of prefixes.v4 (default: \"100.64.0.0/10\") or prefixes.v6 (default: \"fd7a:115c:a1e0::/48\")\n"
"config": {
"ServerURL": "https://derp.no",
"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": "$DIR/private_key.pem",
"BaseDomain": "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": "",
"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": null,
"DERPMap": null,
"AutoUpdate": true,
"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": "example.com",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [
"1.1.1.1",
"1.0.0.1",
"2606:4700:4700::1111",
"2606:4700:4700::1001",
"https://dns.nextdns.io/abc123"
],
"Split": {
"darp.headscale.net": [
"1.1.1.1",
"8.8.8.8"
],
"foo.bar.com": [
"1.1.1.1"
]
}
},
"SearchDomains": [
"test.com",
"bar.com"
],
"ExtraRecords": [
{
"Name": "grafana.myvpn.example.com",
"Type": "A",
"Value": "100.64.0.3"
},
{
"Name": "prometheus.myvpn.example.com",
"Type": "A",
"Value": "100.64.0.4"
}
],
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "example.com"
}
},
"TailcfgDNSConfig": {
"Routes": {
"darp.headscale.net": [
{
"Addr": "1.1.1.1"
},
{
"Addr": "8.8.8.8"
}
],
"foo.bar.com": [
{
"Addr": "1.1.1.1"
}
]
},
"FallbackResolvers": [
{
"Addr": "1.1.1.1"
},
{
"Addr": "1.0.0.1"
},
{
"Addr": "2606:4700:4700::1111"
},
{
"Addr": "2606:4700:4700::1001"
},
{
"Addr": "https://dns.nextdns.io/abc123"
}
],
"Domains": [
"test.com",
"bar.com"
],
"ExtraRecords": [
{
"Name": "grafana.myvpn.example.com",
"Type": "A",
"Value": "100.64.0.3"
},
{
"Name": "prometheus.myvpn.example.com",
"Type": "A",
"Value": "100.64.0.4"
}
]
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"9.9.9.9:53",
"149.112.112.112: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": {
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 900000000000,
"RegisterCacheMaxEntries": 1024,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
}
+178 -1
View File
@@ -1,3 +1,180 @@
{
"error": "Fatal config error: dns.nameservers.global is required when dns.override_local_dns is true\n current: dns.override_local_dns: true, dns.nameservers.global: \"[]\"\n hint: list at least one upstream nameserver, or set dns.override_local_dns: false\n see: https://headscale.net/stable/ref/dns/\n\nFatal config error: database.type has an unsupported value\n current: database.type: \"\"\n allowed: \"sqlite\", \"sqlite3\", \"postgres\"\n hint: pick one of the allowed values; sqlite is the default for single-host deployments\n see: https://headscale.net/stable/ref/database/\n\nFatal config error: dns.base_domain is required when dns.magic_dns is true\n current: dns.magic_dns: true, dns.base_domain: \"\"\n hint: set dns.base_domain to a domain you control (e.g. \"ts.example.net\"), or set dns.magic_dns: false\n see: https://headscale.net/stable/ref/dns/\n\nFatal config error: no IP prefix configured for the tailnet\n current: prefixes.v4: \"\", prefixes.v6: \"\"\n hint: set at least one of prefixes.v4 (default: \"100.64.0.0/10\") or prefixes.v6 (default: \"fd7a:115c:a1e0::/48\")\n"
"config": {
"ServerURL": "https://derp.no",
"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": "$DIR/private_key.pem",
"BaseDomain": "tailnet.internal",
"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": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
},
"TLS": {
"CertPath": "",
"KeyPath": "",
"ACME": {
"Hostname": "",
"ChallengeType": "HTTP-01",
"HTTPListen": ":http",
"URL": "",
"Email": "",
"CacheDir": "/var/lib/headscale/cache"
}
},
"DNSConfig": {
"MagicDNS": true,
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": true,
"Nameservers": {
"Global": [],
"Split": {}
},
"SearchDomains": [],
"ExtraRecords": null,
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {
"Domains": [
"tailnet.internal"
],
"Proxied": true
},
"DNSChallenge": {
"PropagationTimeout": 120000000000,
"Resolvers": [
"9.9.9.9:53",
"149.112.112.112: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": {
"BatchChangeDelay": 800000000,
"NodeMapSessionBufferedChanSize": 30,
"BatcherWorkers": 0,
"RegisterCacheExpiration": 900000000000,
"RegisterCacheMaxEntries": 1024,
"NodeStoreBatchSize": 100,
"NodeStoreBatchTimeout": 500000000
}
}
}
@@ -1,13 +1,13 @@
{
"config": {
"ServerURL": "https://derp.no",
"Addr": "",
"Addr": "0.0.0.0:8080",
"MetricsAddr": "",
"TrustedProxies": null,
"Node": {
"Expiry": 0,
"Ephemeral": {
"InactivityTimeout": 120000000000
"InactivityTimeout": 1800000000000
},
"Routes": {
"HA": {
@@ -23,7 +23,7 @@
"PrefixV6": "fd7a:115c:a1e0::/48",
"IPAllocation": "sequential",
"NoisePrivateKeyPath": "$DIR/private_key.pem",
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"Log": {
"Format": "text",
"Level": "info"
@@ -39,7 +39,7 @@
"ParameterizedQueries": false
},
"Sqlite": {
"Path": "",
"Path": "/var/lib/headscale/db.sqlite",
"WriteAheadLog": true,
"WALAutoCheckPoint": 1000
},
@@ -63,10 +63,24 @@
"ServerPrivateKeyPath": "",
"ServerVerifyClients": true,
"STUNAddr": "",
"URLs": [],
"URLs": [
{
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "controlplane.tailscale.com",
"Path": "/derpmap/default",
"Fragment": "",
"RawQuery": "",
"RawPath": "",
"RawFragment": "",
"ForceQuery": false,
"OmitHost": false
}
],
"Paths": null,
"DERPMap": null,
"AutoUpdate": false,
"AutoUpdate": true,
"UpdateFrequency": 10800000000000,
"IPv4": "",
"IPv6": ""
@@ -85,7 +99,7 @@
},
"DNSConfig": {
"MagicDNS": false,
"BaseDomain": "",
"BaseDomain": "tailnet.internal",
"OverrideLocalDNS": false,
"Nameservers": {
"Global": [],
@@ -96,7 +110,7 @@
"ExtraRecordsPath": "",
"Certificates": {
"Enabled": false,
"Zone": ""
"Zone": "tailnet.internal"
}
},
"TailcfgDNSConfig": {},
+19 -13
View File
@@ -138,18 +138,6 @@ func Validate(c *types.Config) error {
})
}
if c.DNSConfig.OverrideLocalDNS && len(c.DNSConfig.Nameservers.Global) == 0 {
v.Add(&types.ConfigError{
Reason: "dns.nameservers.global is required when dns.override_local_dns is true",
Current: []types.KV{
{Key: "dns.override_local_dns", Value: true},
{Key: "dns.nameservers.global", Value: "[]"},
},
Hint: "list at least one upstream nameserver, or set dns.override_local_dns: false",
See: dnsDocsURL,
})
}
// Validate HA health probing parameters
if ha := c.Node.Routes.HA; ha.ProbeInterval > 0 {
if ha.ProbeInterval < 2*time.Second {
@@ -212,6 +200,7 @@ func Validate(c *types.Config) error {
validateDatabase(c, v)
validatePolicy(c, v)
validateMagicDNS(c, v)
validateBaseDomain(c, v)
validateCertificates(c, v)
validatePrefixes(c, v)
validateDNSProvider(c, v)
@@ -430,6 +419,22 @@ func validateMagicDNS(c *types.Config, v *configValidator) {
}
}
// validateBaseDomain records a ConfigError for a dns.base_domain that is
// not a DNS name, such as `""` in a variable, which is the text itself.
func validateBaseDomain(c *types.Config, v *configValidator) {
base := strings.TrimSuffix(c.DNSConfig.BaseDomain, ".")
if base == "" || dnsname.ValidHostname(base) == nil {
return
}
v.Add(&types.ConfigError{
Reason: "dns.base_domain is not a DNS name",
Current: []types.KV{{Key: "dns.base_domain", Value: c.DNSConfig.BaseDomain}},
Hint: `use letters, digits, "-" and "."; to clear it, write dns.base_domain: "" in the configuration file, as a variable cannot`,
See: dnsDocsURL,
})
}
// validateCertificates records ConfigErrors when node certificates are
// enabled without what the Tailscale client needs: a MagicDNS name it can
// match exactly, and a provider to publish the challenge.
@@ -470,8 +475,9 @@ func validateCertificates(c *types.Config, v *configValidator) {
})
}
// validateBaseDomain reports a non-empty name that is not a DNS name.
base := strings.TrimSuffix(c.DNSConfig.BaseDomain, ".")
if base != strings.ToLower(base) || dnsname.ValidHostname(base) != nil {
if base == "" || (base != strings.ToLower(base) && dnsname.ValidHostname(base) == nil) {
v.Add(&types.ConfigError{
Reason: "dns.base_domain must be a lowercase DNS name for dns.certificates",
Current: []types.KV{{Key: "dns.base_domain", Value: base}},
+3 -2
View File
@@ -186,10 +186,11 @@ func NewServer(tb testing.TB, opts ...ServerOption) *TestServer {
cfg.Tuning.NodeStoreBatchTimeout = sc.nodeStoreBatchTimeout
}
// Off unless an option sets them: each needs a value Default leaves
// to the operator.
// Off unless an option sets them: tests get no DNS they did not ask
// for.
cfg.DNSConfig.MagicDNS = false
cfg.DNSConfig.OverrideLocalDNS = false
cfg.DNSConfig.BaseDomain = ""
if sc.magicDNSDomain != "" {
cfg.DNSConfig.MagicDNS = true
+41 -13
View File
@@ -45,6 +45,10 @@ var (
ErrInvalidAllocationStrategy = errors.New("invalid prefix allocation strategy")
)
// DefaultBaseDomain is dns.base_domain's default. `.internal` is reserved
// for private use and never delegated, so MagicDNS shadows no public name.
const DefaultBaseDomain = "tailnet.internal"
// DefaultChallengeResolvers find a zone's nameservers when
// dns.challenge.resolvers is empty. The system resolver is not used: on a
// host running MagicDNS it answers for base_domain itself instead of
@@ -83,7 +87,7 @@ type EphemeralConfig struct {
// InactivityTimeout is how long an ephemeral node can be offline
// before it is automatically deleted. It must exceed 65s, the client
// keepalive plus a margin.
InactivityTimeout time.Duration `example:"\"30m\"" koanf:"inactivity_timeout"`
InactivityTimeout time.Duration `example:"\"1h\"" koanf:"inactivity_timeout"`
}
// HARouteConfig contains configuration for HA subnet router health probing.
@@ -152,8 +156,9 @@ type Config struct { //nolint:recvcheck // MarshalJSON reads a value, so a Confi
// Addr is the host:port the server listens on for clients, the API and
// the web pages. It serves HTTPS when `tls.cert_path` or
// `tls.acme.hostname` is set, plain HTTP otherwise.
Addr ListenAddr `example:"\"0.0.0.0:8080\"" koanf:"listen_addr"`
// `tls.acme.hostname` is set, plain HTTP otherwise. The default listens
// on every address, IPv4 and IPv6 alike.
Addr ListenAddr `example:"\"127.0.0.1:8080\"" koanf:"listen_addr"`
// MetricsAddr is the host:port serving `/metrics` and `/debug`; keep
// it private. Empty disables this listener.
@@ -181,7 +186,7 @@ type Config struct { //nolint:recvcheck // MarshalJSON reads a value, so a Confi
// Noise is the Noise protocol (TS2021) clients connect over.
Noise NoiseConfig `koanf:"noise"`
// Prefixes are the IP ranges node addresses are allocated from. Set at
// Prefixes are the IP ranges node addresses are allocated from. Keep at
// least one of `prefixes.v4` and `prefixes.v6`. Use the Tailscale
// ranges, `100.64.0.0/10` and `fd7a:115c:a1e0::/48`, or ranges inside
// them: the client assumes them, and other ranges are unsupported.
@@ -268,7 +273,7 @@ type NoiseConfig struct {
// PrivateKeyPath is the file holding the Noise private key, which
// encrypts traffic between headscale and clients, relative to the
// configuration file. A missing file is created with a new key.
PrivateKeyPath string `example:"\"/var/lib/headscale/noise_private.key\"" koanf:"private_key_path" nix:"external"`
PrivateKeyPath string `example:"\"/opt/headscale/noise_private.key\"" koanf:"private_key_path" nix:"external"`
}
// PrefixesConfig are the ranges node IPs are allocated from. At least one
@@ -278,11 +283,11 @@ type NoiseConfig struct {
type PrefixesConfig struct {
// V4 is the IPv4 range, e.g. `100.64.0.0/10`. Empty gives nodes no
// IPv4 address.
V4 *netip.Prefix `example:"\"100.64.0.0/10\"" koanf:"v4"`
V4 *netip.Prefix `example:"\"100.64.0.0/24\"" koanf:"v4"`
// V6 is the IPv6 range, e.g. `fd7a:115c:a1e0::/48`. Empty gives nodes
// no IPv6 address.
V6 *netip.Prefix `example:"\"fd7a:115c:a1e0::/48\"" koanf:"v6"`
V6 *netip.Prefix `example:"\"fd7a:115c:a1e0::/64\"" koanf:"v6"`
// Allocation is how a new node's addresses are picked.
Allocation IPAllocationStrategy `example:"\"random\"" koanf:"allocation"`
@@ -308,11 +313,14 @@ type DNSConfig struct {
// BaseDomain is the domain MagicDNS names live under, without a
// trailing dot, e.g. `example.com`. The host of `server_url` must not
// be this domain or a name below it: clients take the domain over.
// The default is a private-use name, so `dns.certificates` needs a
// public domain you control.
BaseDomain string `example:"\"tailnet.example.com\"" koanf:"base_domain"`
// OverrideLocalDNS makes clients use `dns.nameservers.global` instead
// of their local DNS settings, which then requires at least one global
// nameserver. False sends them only as fallback resolvers.
// of their local DNS settings; with no global nameserver there is
// nothing to override with, and clients keep their own. False sends
// them only as fallback resolvers.
OverrideLocalDNS bool `koanf:"override_local_dns"`
// Nameservers are the upstream DNS servers sent to clients. An entry
@@ -459,7 +467,8 @@ func (c DNSChallengeConfig) ResolverAddrs() []string {
type Nameservers struct {
// Global are the nameservers for names `dns.nameservers.split` does not
// cover: IP addresses, or DNS-over-HTTPS URLs such as
// `https://dns.nextdns.io/<id>`.
// `https://dns.nextdns.io/<id>`. Empty by default, so clients keep
// their own DNS: headscale points them at no resolver you did not list.
Global []string `example:"[\"9.9.9.9\",\"149.112.112.112\",\"2620:fe::fe\",\"2620:fe::9\"]" koanf:"global"`
// Split maps a domain to the nameservers that answer for it (split
@@ -472,7 +481,7 @@ type Nameservers struct {
type SqliteConfig struct {
// Path is the database file, relative to the configuration file;
// `:memory:` keeps the database in memory.
Path string `example:"\"/var/lib/headscale/db.sqlite\"" koanf:"path" nix:"external"`
Path string `example:"\"/opt/headscale/db.sqlite\"" koanf:"path" nix:"external"`
// WriteAheadLog applies `database.sqlite.wal_autocheckpoint` and
// compacts the database (`VACUUM`) on shutdown. SQLite runs in WAL
@@ -745,8 +754,10 @@ type DERPConfig struct {
Server DERPServerConfig `koanf:"server"`
// URLs are DERP maps in JSON to fetch. One that fails to load is
// logged and skipped; startup fails only when no region remains.
URLs []HTTPURL `example:"[\"https://controlplane.tailscale.com/derpmap/default\"]" koanf:"urls"`
// logged and skipped; startup fails only when no region remains. The
// default is Tailscale's map: headscale fetches it from Tailscale and
// clients relay through Tailscale's servers. `[]` keeps to your own.
URLs []HTTPURL `example:"[\"https://derp.example.com/derpmap.json\"]" koanf:"urls"`
// Paths are DERP map files. The extension picks the format: `.yaml` or
// `.yml`, or Tailscale JSON as `.json` or `.hujson`, both accepting
@@ -931,6 +942,23 @@ func (t Tuning) BatcherWorkerCount() int {
return DefaultBatcherWorkers()
}
// DERPShuffleSeed seeds the DERP node order: dns.base_domain, or the
// server_url host while dns.base_domain is [DefaultBaseDomain]. Empty
// seeds randomly on each start.
func (c *Config) DERPShuffleSeed() string {
if c.DNSConfig.BaseDomain != DefaultBaseDomain {
return c.DNSConfig.BaseDomain
}
// A shared default domain would give every such server the same relay order.
u, err := url.Parse(c.ServerURL)
if err != nil {
return ""
}
return u.Hostname()
}
// Domain returns the hostname/domain part of the [Config.ServerURL].
// If the [Config.ServerURL] is not a valid URL, it returns dns.base_domain.
func (c *Config) Domain() string {
+6 -6
View File
@@ -16,7 +16,7 @@ var configFieldDocs = map[string]string{
"CLIConfig.Timeout": "Bounds each CLI command's requests to the server.",
"CertificatesConfig.Enabled": "Lets nodes run `tailscale cert`. It requires `dns.magic_dns`, a lowercase `dns.base_domain` and `dns.challenge.provider`.",
"CertificatesConfig.Zone": "The public DNS zone challenge records are written to, when `dns.base_domain` sits below the zone apex. It must contain `dns.base_domain`. Empty uses `dns.base_domain`.",
"Config.Addr": "The host:port the server listens on for clients, the API and the web pages. It serves HTTPS when `tls.cert_path` or `tls.acme.hostname` is set, plain HTTP otherwise.",
"Config.Addr": "The host:port the server listens on for clients, the API and the web pages. It serves HTTPS when `tls.cert_path` or `tls.acme.hostname` is set, plain HTTP otherwise. The default listens on every address, IPv4 and IPv6 alike.",
"Config.AutoUpdate": "The tailnet-wide default for client auto-updates.",
"Config.CLI": "How the headscale CLI reaches the server: the local `unix_socket` without authentication, or a remote `cli.address` with `cli.api_key`. The CLI reads these keys from its own configuration, such as `~/.config/headscale/config.yaml`, or from `HEADSCALE_CLI_*` variables; the server does not read them, so on NixOS they do not belong in `services.headscale.settings`. See [Remote control](https://headscale.net/stable/ref/api/#remote-control).",
"Config.DERP": "The DERP map: the relay servers clients use when they cannot connect directly, from `derp.urls`, `derp.paths` and the embedded server in `derp.server`. A region replaces an earlier one with the same ID. See [DERP](https://headscale.net/stable/ref/derp/).",
@@ -31,7 +31,7 @@ var configFieldDocs = map[string]string{
"Config.OIDC": "Login through an OpenID Connect provider. Setting `oidc.issuer` turns it on and requires `oidc.client_id` and `oidc.client_secret`. See [OpenID Connect](https://headscale.net/stable/ref/oidc/).",
"Config.Policy": "Where the access control policy is kept: in a file headscale reads, or in the database. See [Policy](https://headscale.net/stable/ref/policy/).",
"Config.PreAuthKeys": "Covers the cleanup of revoked pre-auth keys. See [Pre authenticated key](https://headscale.net/stable/ref/registration/#pre-authenticated-key).",
"Config.Prefixes": "The IP ranges node addresses are allocated from. Set at least one of `prefixes.v4` and `prefixes.v6`. Use the Tailscale ranges, `100.64.0.0/10` and `fd7a:115c:a1e0::/48`, or ranges inside them: the client assumes them, and other ranges are unsupported.",
"Config.Prefixes": "The IP ranges node addresses are allocated from. Keep at least one of `prefixes.v4` and `prefixes.v6`. Use the Tailscale ranges, `100.64.0.0/10` and `fd7a:115c:a1e0::/48`, or ranges inside them: the client assumes them, and other ranges are unsupported.",
"Config.ServerURL": "The URL clients connect to, with its `http://` or `https://` scheme, e.g. `https://headscale.example.com:443`. A trailing slash is trimmed on load. Its host must not be `dns.base_domain` or a name below it.",
"Config.TLS": "Headscale's own HTTPS certificate on `listen_addr`: from the files `tls.cert_path` and `tls.key_path`, or from ACME in `tls.acme`, not both. Without either, the server speaks plain HTTP. See [TLS](https://headscale.net/stable/ref/tls/).",
"Config.Taildrop": "Taildrop, Tailscale's file sharing between nodes.",
@@ -42,7 +42,7 @@ var configFieldDocs = map[string]string{
"DERPConfig.AutoUpdate": "Reloads `derp.urls` and `derp.paths` every `derp.update_frequency`.",
"DERPConfig.Paths": "DERP map files. The extension picks the format: `.yaml` or `.yml`, or Tailscale JSON as `.json` or `.hujson`, both accepting comments and trailing commas.",
"DERPConfig.Server": "The embedded DERP server, a relay and STUN server run by headscale itself. See [Enable embedded DERP](https://headscale.net/stable/ref/derp/#enable-embedded-derp).",
"DERPConfig.URLs": "DERP maps in JSON to fetch. One that fails to load is logged and skipped; startup fails only when no region remains.",
"DERPConfig.URLs": "DERP maps in JSON to fetch. One that fails to load is logged and skipped; startup fails only when no region remains. The default is Tailscale's map: headscale fetches it from Tailscale and clients relay through Tailscale's servers. `[]` keeps to your own.",
"DERPConfig.UpdateFrequency": "How often `derp.auto_update_enabled` reloads the DERP map. Zero disables reloading.",
"DERPServerConfig.AutomaticallyAddEmbeddedDerpRegion": "Adds the embedded server's region to the DERP map. When it is false and `derp.server.enabled` is true, `derp.paths` is required: write the region there yourself.",
"DERPServerConfig.Enabled": "Runs the embedded DERP server. DERP needs TLS, so `server_url` must be `https://`.",
@@ -57,14 +57,14 @@ var configFieldDocs = map[string]string{
"DNSChallengeConfig.PropagationTimeout": "How long to wait for a challenge record to show up on every authoritative nameserver. Zero skips the check.",
"DNSChallengeConfig.ProviderSettings": "The DNS provider that writes challenge records: `name` selects it, the other keys are its settings. Keys are lowercased on load, at every depth; two that differ only in case are an error. A string setting may be `file:<path>` to read it from a file. `headscale generate config --running` and `/debug/config` show `name` and `file:` references; every other setting is `<redacted>`, as any may be a credential. See [DNS-01 challenge provider](https://headscale.net/stable/ref/dns/#dns-01-challenge-provider) to set a provider up, acme-dns included, and to set it from environment variables.",
"DNSChallengeConfig.Resolvers": "The servers asked for the zone's nameservers, each an IP or host with an optional port (53 if omitted). Empty uses the default public resolvers. The system resolver is never used: on a host running MagicDNS it answers for `dns.base_domain` itself.",
"DNSConfig.BaseDomain": "The domain MagicDNS names live under, without a trailing dot, e.g. `example.com`. The host of `server_url` must not be this domain or a name below it: clients take the domain over.",
"DNSConfig.BaseDomain": "The domain MagicDNS names live under, without a trailing dot, e.g. `example.com`. The host of `server_url` must not be this domain or a name below it: clients take the domain over. The default is a private-use name, so `dns.certificates` needs a public domain you control.",
"DNSConfig.Certificates": "Lets nodes get TLS certificates for their MagicDNS names with `tailscale cert`. The node runs ACME itself; headscale publishes its DNS-01 challenge through `dns.challenge.provider`.",
"DNSConfig.Challenge": "The DNS provider answering ACME DNS-01 challenges, for node certificates and for headscale's own certificate when `tls.acme.challenge_type` is `DNS-01`. See [DNS-01 challenge provider](https://headscale.net/stable/ref/dns/#dns-01-challenge-provider).",
"DNSConfig.ExtraRecords": "DNS records served to clients, each with a `name`, `type` and `value`. Clients support `A` and `AAAA`. Mutually exclusive with `dns.extra_records_path`. See [Setting extra DNS records](https://headscale.net/stable/ref/dns/#setting-extra-dns-records).",
"DNSConfig.ExtraRecordsPath": "A file of extra records, reloaded when it changes. The extension picks the format: `.json`, `.hujson`, `.yaml` or `.yml`. Mutually exclusive with `dns.extra_records`.",
"DNSConfig.MagicDNS": "Gives each node a name below `dns.base_domain`, e.g. `laptop.example.com`, resolved by the client. It requires `dns.base_domain`.",
"DNSConfig.Nameservers": "The upstream DNS servers sent to clients. An entry that is neither an IP address nor a URL is skipped with a warning.",
"DNSConfig.OverrideLocalDNS": "Makes clients use `dns.nameservers.global` instead of their local DNS settings, which then requires at least one global nameserver. False sends them only as fallback resolvers.",
"DNSConfig.OverrideLocalDNS": "Makes clients use `dns.nameservers.global` instead of their local DNS settings; with no global nameserver there is nothing to override with, and clients keep their own. False sends them only as fallback resolvers.",
"DNSConfig.SearchDomains": "DNS search domains sent to clients. With MagicDNS, `dns.base_domain` comes first.",
"DatabaseConfig.Debug": "Turns on query logging: ordinary queries at log level debug, shown only when `log.level` is `debug` or `trace`, slow ones at warn and failed ones at error. Off, no query is logged. `database.gorm` shapes the query log. See [Database logging](https://headscale.net/stable/ref/debug/#database-logging).",
"DatabaseConfig.Gorm": "Query logging, applied only when `database.debug` is true.",
@@ -80,7 +80,7 @@ var configFieldDocs = map[string]string{
"LogConfig.Format": "How log lines are written.",
"LogConfig.Level": "The lowest level logged.",
"LogTailConfig.Enabled": "Lets nodes send their logs to Tailscale Inc.; headscale cannot point them at another log server. False tells nodes not to.",
"Nameservers.Global": "The nameservers for names `dns.nameservers.split` does not cover: IP addresses, or DNS-over-HTTPS URLs such as `https://dns.nextdns.io/<id>`.",
"Nameservers.Global": "The nameservers for names `dns.nameservers.split` does not cover: IP addresses, or DNS-over-HTTPS URLs such as `https://dns.nextdns.io/<id>`. Empty by default, so clients keep their own DNS: headscale points them at no resolver you did not list.",
"Nameservers.Split": "Maps a domain to the nameservers that answer for it (split DNS). Domains are lowercased on load; two that differ only in case are an error.",
"NodeConfig.Ephemeral": "Covers ephemeral nodes, which register with an ephemeral auth key and are deleted once they have been offline for `node.ephemeral.inactivity_timeout`.",
"NodeConfig.Expiry": "The key expiry given to a non-tagged node that registers without one, whatever the method (auth key, CLI, web, OIDC). An expiry the client asks for, `oidc.use_expiry_from_token` and an admin's `headscale nodes expire` still apply. Tagged nodes never get this default. Zero or negative disables the default.",
+30
View File
@@ -191,6 +191,12 @@ func TestTailcfgDNSConfig(t *testing.T) {
Routes: map[string][]*dnstype.Resolver{},
},
},
{
// Nothing to override with: clients keep their own DNS.
name: "override local dns without global nameservers",
cfg: Config{DNSConfig: DNSConfig{OverrideLocalDNS: true}},
want: &tailcfg.DNSConfig{Routes: map[string][]*dnstype.Resolver{}},
},
{
name: "fallback resolvers",
cfg: Config{DNSConfig: DNSConfig{Nameservers: Nameservers{Global: []string{"1.1.1.1"}}}},
@@ -428,6 +434,30 @@ func TestServesRoute(t *testing.T) {
assert.True(t, (&Config{Prefixes: PrefixesConfig{V4: &narrow}}).ServesRoute(netip.MustParsePrefix("100.100.0.1/32")))
}
// TestDERPShuffleSeed: servers left on the default base domain do not all
// share one DERP order; any other domain seeds it.
func TestDERPShuffleSeed(t *testing.T) {
tests := []struct {
name string
serverURL string
baseDomain string
want string
}{
{name: "default domain a", serverURL: "https://a.example.com", baseDomain: DefaultBaseDomain, want: "a.example.com"},
{name: "default domain b", serverURL: "https://b.example.com:8443", baseDomain: DefaultBaseDomain, want: "b.example.com"},
{name: "default domain unparsable url", serverURL: "https://a.example.com/%zz", baseDomain: DefaultBaseDomain, want: ""},
{name: "operator domain", serverURL: "https://a.example.com", baseDomain: "corp.example.com", want: "corp.example.com"},
{name: "empty domain", serverURL: "https://a.example.com", baseDomain: "", want: ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &Config{ServerURL: tt.serverURL, DNSConfig: DNSConfig{BaseDomain: tt.baseDomain}}
assert.Equal(t, tt.want, c.DERPShuffleSeed())
})
}
}
// TestDNSDomainsCompat: SaaS sends the tailnet domain as a search domain with
// MagicDNS on and leaves it out with MagicDNS off.
func TestDNSDomainsCompat(t *testing.T) {
+1 -1
View File
@@ -101,7 +101,7 @@ func TestResolveMagicDNSExtraRecordsPath(t *testing.T) {
hsic.WithTestName("extrarecords"),
hsic.WithConfigEnv(map[string]string{
// Disable global nameservers to make the test run offline.
"HEADSCALE_DNS_NAMESERVERS_GLOBAL": "",
"HEADSCALE_DNS_NAMESERVERS_GLOBAL": "[]",
"HEADSCALE_DNS_EXTRA_RECORDS_PATH": erPath,
}),
hsic.WithFileInContainer(erPath, b),
+1 -1
View File
@@ -31,7 +31,7 @@ func DefaultConfigEnv() map[string]string {
// Tests should not depend on external DERP infrastructure.
// Use [WithPublicDERP] to opt out for tests that explicitly
// need public DERP relays.
"HEADSCALE_DERP_URLS": "",
"HEADSCALE_DERP_URLS": "[]",
"HEADSCALE_DERP_AUTO_UPDATE_ENABLED": "false",
"HEADSCALE_DERP_UPDATE_FREQUENCY": "1m",
"HEADSCALE_DERP_SERVER_ENABLED": "true",
+1 -1
View File
@@ -259,7 +259,7 @@ func WithDERPConfig(derpMap tailcfg.DERPMap) Option {
})
// Disable global DERP server and embedded DERP server
hsic.env["HEADSCALE_DERP_URLS"] = ""
hsic.env["HEADSCALE_DERP_URLS"] = "[]"
hsic.env["HEADSCALE_DERP_SERVER_ENABLED"] = "false"
// Envknob for enabling DERP debug logs