1
0
mirror of https://github.com/DNSCrypt/dnscrypt-proxy.git synced 2024-12-11 22:35:40 +01:00

Correctly check for empty/wrong relays

This commit is contained in:
Frank Denis 2021-06-08 10:27:03 +02:00
parent ec581597a2
commit 5a9a6467df

View File

@ -371,7 +371,7 @@ func route(proxy *Proxy, name string) (*Relay, error) {
wildcard = true wildcard = true
relayNames, ok = (*routes)["*"] relayNames, ok = (*routes)["*"]
} }
if !ok { if !ok || len(relayNames) == 0 {
return nil, nil return nil, nil
} }
relayStamps := make([]stamps.ServerStamp, 0) relayStamps := make([]stamps.ServerStamp, 0)
@ -704,12 +704,13 @@ func _fetchODoHTargetInfo(proxy *Proxy, name string, stamp stamps.ServerStamp, i
} }
if relay == nil { if relay == nil {
if relay.ODoH == nil {
dlog.Criticalf("No relay defined for [%v] - Configuring a relay is required for ODoH servers (see the `[anonymized_dns]` section)", name) dlog.Criticalf("No relay defined for [%v] - Configuring a relay is required for ODoH servers (see the `[anonymized_dns]` section)", name)
} else {
dlog.Criticalf("Wrong relay type defined for [%v] - ODoH servers require an ODoH relay", name)
}
return ServerInfo{}, errors.New("No ODoH relay") return ServerInfo{}, errors.New("No ODoH relay")
} else {
if relay.ODoH == nil {
dlog.Criticalf("Wrong relay type defined for [%v] - ODoH servers require an ODoH relay", name)
return ServerInfo{}, errors.New("Wrong ODoH relay type")
}
} }
dlog.Debugf("Pausing after ODoH configuration retrieval") dlog.Debugf("Pausing after ODoH configuration retrieval")