all: supports multiple protocols for no config mode

Updates #78
This commit is contained in:
Cuong Manh Le
2023-03-25 00:44:27 +07:00
committed by Cuong Manh Le
parent 42d29b626b
commit c94e1b02d2
3 changed files with 60 additions and 6 deletions
+12 -6
View File
@@ -593,18 +593,24 @@ func processNoConfigFlags(noConfigStart bool) {
}
processListenFlag()
endpointAndTyp := func(endpoint string) (string, string) {
typ := ctrld.ResolverTypeFromEndpoint(endpoint)
return strings.TrimPrefix(endpoint, "quic://"), typ
}
pEndpoint, pType := endpointAndTyp(primaryUpstream)
upstream := map[string]*ctrld.UpstreamConfig{
"0": {
Name: primaryUpstream,
Endpoint: primaryUpstream,
Type: ctrld.ResolverTypeDOH,
Name: pEndpoint,
Endpoint: pEndpoint,
Type: pType,
},
}
if secondaryUpstream != "" {
sEndpoint, sType := endpointAndTyp(secondaryUpstream)
upstream["1"] = &ctrld.UpstreamConfig{
Name: secondaryUpstream,
Endpoint: secondaryUpstream,
Type: ctrld.ResolverTypeLegacy,
Name: sEndpoint,
Endpoint: sEndpoint,
Type: sType,
}
rules := make([]ctrld.Rule, 0, len(domains))
for _, domain := range domains {