From 46d28909893ef18f1be38d99baec4a5ecfdae617 Mon Sep 17 00:00:00 2001 From: Alexander Halbarth Date: Mon, 20 Nov 2023 14:48:20 +0100 Subject: [PATCH] Rename variables for custom DERP entry --- config-example.yaml | 8 ++++---- hscontrol/app.go | 4 ++-- hscontrol/types/config.go | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/config-example.yaml b/config-example.yaml index 57bb2ba95b..0af3612c04 100644 --- a/config-example.yaml +++ b/config-example.yaml @@ -97,13 +97,13 @@ derp: # For better connection stability (especially when using an Exit-Node and DNS is not working), # it is possible to optionall add the public IPv4 and IPv6 address to the Derp-Map using: - IPv4: 1.2.3.4 - IPv6: 2001:db8::1 + ipv4: 1.2.3.4 + ipv6: 2001:db8::1 # This flag can be used, so the DERP map entry for the embedded DERP server is not written automatically, # it enables the creation of your very own DERP map entry using a locally available file with the parameter DERP.paths - # If you enable the DERP server and set this to true, it is required to add the DERP server to the DERP map using DERP.paths - manual_derp_map: false + # If you enable the DERP server and set this to false, it is required to add the DERP server to the DERP map using DERP.paths + automatically_add_embedded_derp_region: true # List of externally available DERP maps encoded in JSON urls: diff --git a/hscontrol/app.go b/hscontrol/app.go index 462bf34a96..410d0bbed3 100644 --- a/hscontrol/app.go +++ b/hscontrol/app.go @@ -258,7 +258,7 @@ func (h *Headscale) scheduledDERPMapUpdateWorker(cancelChan <-chan struct{}) { case <-ticker.C: log.Info().Msg("Fetching DERPMap updates") h.DERPMap = derp.GetDERPMap(h.cfg.DERP) - if h.cfg.DERP.ServerEnabled && !h.cfg.DERP.ManualDerpMap { + if h.cfg.DERP.ServerEnabled && h.cfg.DERP.AutomaticallyAddEmbeddedDerpRegion { region, _ := h.DERPServer.GenerateRegion() h.DERPMap.Regions[region.RegionID] = ®ion } @@ -499,7 +499,7 @@ func (h *Headscale) Serve() error { return err } - if !h.cfg.DERP.ManualDerpMap { + if h.cfg.DERP.AutomaticallyAddEmbeddedDerpRegion { h.DERPMap.Regions[region.RegionID] = ®ion } diff --git a/hscontrol/types/config.go b/hscontrol/types/config.go index f2aafd7727..1b0652b74c 100644 --- a/hscontrol/types/config.go +++ b/hscontrol/types/config.go @@ -109,7 +109,7 @@ type OIDCConfig struct { type DERPConfig struct { ServerEnabled bool - ManualDerpMap bool + AutomaticallyAddEmbeddedDerpRegion bool ServerRegionID int ServerRegionCode string ServerRegionName string @@ -172,7 +172,7 @@ func LoadConfig(path string, isFile bool) error { viper.SetDefault("derp.server.enabled", false) viper.SetDefault("derp.server.stun.enabled", true) - viper.SetDefault("derp.server.manual_derp_map", false) + viper.SetDefault("derp.server.automatically_add_embedded_derp_region", true) viper.SetDefault("unix_socket", "/var/run/headscale/headscale.sock") viper.SetDefault("unix_socket_permission", "0o770") @@ -290,9 +290,9 @@ func GetDERPConfig() DERPConfig { serverRegionCode := viper.GetString("derp.server.region_code") serverRegionName := viper.GetString("derp.server.region_name") stunAddr := viper.GetString("derp.server.stun_listen_addr") - IPv4 := viper.GetString("derp.server.IPv4") - IPv6 := viper.GetString("derp.server.IPv6") - manual_derp_map := viper.GetBool("derp.server.manual_derp_map") + ipv4 := viper.GetString("derp.server.ipv4") + ipv6 := viper.GetString("derp.server.ipv6") + automatically_add_embedded_derp_region := viper.GetBool("derp.server.automatically_add_embedded_derp_region") if serverEnabled && stunAddr == "" { log.Fatal(). @@ -316,9 +316,9 @@ func GetDERPConfig() DERPConfig { paths := viper.GetStringSlice("derp.paths") - if serverEnabled && manual_derp_map && len(paths) == 0 { + if serverEnabled && !automatically_add_embedded_derp_region && len(paths) == 0 { log.Fatal(). - Msg("Enabling derp.server.manual_derp_map requires to configure the derp server in derp.paths") + Msg("Disabling derp.server.automatically_add_embedded_derp_region requires to configure the derp server in derp.paths") } autoUpdate := viper.GetBool("derp.auto_update_enabled") @@ -334,9 +334,9 @@ func GetDERPConfig() DERPConfig { Paths: paths, AutoUpdate: autoUpdate, UpdateFrequency: updateFrequency, - IPv4: IPv4, - IPv6: IPv6, - ManualDerpMap: manual_derp_map, + IPv4: ipv4, + IPv6: ipv6, + AutomaticallyAddEmbeddedDerpRegion: automatically_add_embedded_derp_region, } }