Validate DoH/DoH3 endpoint properly

When resolver type is doh/doh3, the endpoint must be a valid http url.

Updates #149
This commit is contained in:
Cuong Manh Le
2023-08-09 10:01:00 +07:00
committed by Cuong Manh Le
parent f7d3db06c6
commit 7ce62ccaec
3 changed files with 38 additions and 1 deletions
+8
View File
@@ -95,6 +95,7 @@ func TestConfigValidation(t *testing.T) {
{"non-existed lease file", configWithNonExistedLeaseFile(t), true},
{"lease file format required if lease file exist", configWithExistedLeaseFile(t), true},
{"invalid lease file format", configWithInvalidLeaseFileFormat(t), true},
{"invalid doh/doh3 endpoint", configWithInvalidDoHEndpoint(t), true},
}
for _, tc := range tests {
@@ -225,3 +226,10 @@ func configWithInvalidLeaseFileFormat(t *testing.T) *ctrld.Config {
cfg.Service.DHCPLeaseFileFormat = "invalid"
return cfg
}
func configWithInvalidDoHEndpoint(t *testing.T) *ctrld.Config {
cfg := defaultConfig(t)
cfg.Upstream["0"].Endpoint = "1.1.1.1"
cfg.Upstream["0"].Type = ctrld.ResolverTypeDOH
return cfg
}