mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-01-16 02:40:37 +01:00
Improve logging
This commit is contained in:
parent
2785cc579e
commit
551ddcf199
@ -33,7 +33,7 @@ func FetchCurrentDNSCryptCert(proxy *Proxy, serverName *string, proto string, pk
|
||||
}
|
||||
query := new(dns.Msg)
|
||||
query.SetQuestion(providerName, dns.TypeTXT)
|
||||
in, rtt, err := dnsExchange(proxy, proto, query, serverAddress, relayUDPAddr, relayTCPAddr)
|
||||
in, rtt, err := dnsExchange(proxy, proto, query, serverAddress, relayUDPAddr, relayTCPAddr, serverName)
|
||||
if err != nil {
|
||||
dlog.Noticef("[%s] TIMEOUT", *serverName)
|
||||
return CertInfo{}, 0, err
|
||||
@ -179,11 +179,14 @@ func packTxtString(s string) ([]byte, error) {
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
func dnsExchange(proxy *Proxy, proto string, query *dns.Msg, serverAddress string, relayUDPAddr *net.UDPAddr, relayTCPAddr *net.TCPAddr) (*dns.Msg, time.Duration, error) {
|
||||
func dnsExchange(proxy *Proxy, proto string, query *dns.Msg, serverAddress string, relayUDPAddr *net.UDPAddr, relayTCPAddr *net.TCPAddr, serverName *string) (*dns.Msg, time.Duration, error) {
|
||||
response, ttl, err := _dnsExchange(proxy, proto, query, serverAddress, relayUDPAddr, relayTCPAddr)
|
||||
if err != nil && relayUDPAddr != nil {
|
||||
dlog.Warnf("Unable to get a certificate via relay [%v], retrying over a direct connection", relayUDPAddr.IP)
|
||||
dlog.Debugf("Unable to get a certificate for [%v] via relay [%v], retrying over a direct connection", *serverName, relayUDPAddr.IP)
|
||||
response, ttl, err = _dnsExchange(proxy, proto, query, serverAddress, nil, nil)
|
||||
if err == nil {
|
||||
dlog.Infof("Direct certificate retrieval for [%v] succeeded", *serverName)
|
||||
}
|
||||
}
|
||||
return response, ttl, err
|
||||
}
|
||||
|
@ -225,7 +225,10 @@ func fetchServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp, isNew
|
||||
return ServerInfo{}, errors.New("Unsupported protocol")
|
||||
}
|
||||
|
||||
func route(proxy *Proxy, name string) (*net.UDPAddr, *net.TCPAddr, error) {
|
||||
func route(proxy *Proxy, name string, stamp *stamps.ServerStamp) (*net.UDPAddr, *net.TCPAddr, error) {
|
||||
if !strings.HasPrefix(stamp.ProviderName, "2.dnscrypt-cert.") {
|
||||
return nil, nil, fmt.Errorf("[%v] uses a non-standard provider name - anonymized DNS will not work with this server", name)
|
||||
}
|
||||
routes := proxy.routes
|
||||
if routes == nil {
|
||||
return nil, nil, nil
|
||||
@ -293,7 +296,7 @@ func fetchDNSCryptServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp
|
||||
dlog.Warnf("Public key [%s] shouldn't be hex-encoded any more", string(stamp.ServerPk))
|
||||
stamp.ServerPk = serverPk
|
||||
}
|
||||
relayUDPAddr, relayTCPAddr, err := route(proxy, name)
|
||||
relayUDPAddr, relayTCPAddr, err := route(proxy, name, &stamp)
|
||||
if err != nil {
|
||||
return ServerInfo{}, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user