From 02ee113b9500c408fcc031cff9a870c2a749a499 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Thu, 12 Dec 2024 18:47:22 +0700 Subject: [PATCH] Add missing kea dhcp4 format when validating config Thanks Discord user cosmoxl for reporting this. --- config.go | 2 +- config_test.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index 3f9b2f8..4302c5d 100644 --- a/config.go +++ b/config.go @@ -205,7 +205,7 @@ type ServiceConfig struct { CacheFlushDomains []string `mapstructure:"cache_flush_domains" toml:"cache_flush_domains" validate:"max=256"` MaxConcurrentRequests *int `mapstructure:"max_concurrent_requests" toml:"max_concurrent_requests,omitempty" validate:"omitempty,gte=0"` DHCPLeaseFile string `mapstructure:"dhcp_lease_file_path" toml:"dhcp_lease_file_path" validate:"omitempty,file"` - DHCPLeaseFileFormat string `mapstructure:"dhcp_lease_file_format" toml:"dhcp_lease_file_format" validate:"required_unless=DHCPLeaseFile '',omitempty,oneof=dnsmasq isc-dhcp"` + DHCPLeaseFileFormat string `mapstructure:"dhcp_lease_file_format" toml:"dhcp_lease_file_format" validate:"required_unless=DHCPLeaseFile '',omitempty,oneof=dnsmasq isc-dhcp kea-dhcp4"` DiscoverMDNS *bool `mapstructure:"discover_mdns" toml:"discover_mdns,omitempty"` DiscoverARP *bool `mapstructure:"discover_arp" toml:"discover_arp,omitempty"` DiscoverDHCP *bool `mapstructure:"discover_dhcp" toml:"discover_dhcp,omitempty"` diff --git a/config_test.go b/config_test.go index a20b33c..cd392d5 100644 --- a/config_test.go +++ b/config_test.go @@ -111,6 +111,7 @@ func TestConfigValidation(t *testing.T) { {"doh3 endpoint without type", doh3UpstreamEndpointWithoutType(t), false}, {"sdns endpoint without type", sdnsUpstreamEndpointWithoutType(t), false}, {"maximum number of flush cache domains", configWithInvalidFlushCacheDomain(t), true}, + {"kea dhcp4 format", configWithDhcp4KeaFormat(t), false}, } for _, tc := range tests { @@ -307,6 +308,12 @@ func configWithInvalidLeaseFileFormat(t *testing.T) *ctrld.Config { return cfg } +func configWithDhcp4KeaFormat(t *testing.T) *ctrld.Config { + cfg := defaultConfig(t) + cfg.Service.DHCPLeaseFileFormat = "kea-dhcp4" + return cfg +} + func configWithInvalidDoHEndpoint(t *testing.T) *ctrld.Config { cfg := defaultConfig(t) cfg.Upstream["0"].Endpoint = "/1.1.1.1"