1
0
mirror of https://github.com/DNSCrypt/dnscrypt-proxy.git synced 2024-12-28 00:20:13 +01:00

Don't display sorted latencies if there is only one (or none)

This commit is contained in:
Frank Denis 2019-06-03 18:51:21 +02:00
parent 8e01421304
commit aca031c2ec
3 changed files with 12 additions and 7 deletions

View File

@ -164,11 +164,11 @@ func NewPluginsState(proxy *Proxy, clientProto string, clientAddr *net.Addr, sta
}
}
func (pluginsState *PluginsState) ApplyQueryPlugins(pluginsGlobals *PluginsGlobals, packet []byte, serverName *string) ([]byte, error) {
func (pluginsState *PluginsState) ApplyQueryPlugins(pluginsGlobals *PluginsGlobals, packet []byte, serverName string) ([]byte, error) {
if len(*pluginsGlobals.queryPlugins) == 0 && len(*pluginsGlobals.loggingPlugins) == 0 {
return packet, nil
}
pluginsState.serverName = *serverName
pluginsState.serverName = serverName
pluginsState.action = PluginsActionForward
msg := dns.Msg{}
if err := msg.Unpack(packet); err != nil {

View File

@ -332,7 +332,11 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
return
}
pluginsState := NewPluginsState(proxy, clientProto, clientAddr, start)
query, _ = pluginsState.ApplyQueryPlugins(&proxy.pluginsGlobals, query, &serverInfo.Name)
serverName := "-"
if serverInfo != nil {
serverName = serverInfo.Name
}
query, _ = pluginsState.ApplyQueryPlugins(&proxy.pluginsGlobals, query, serverName)
if len(query) < MinDNSPacketSize || len(query) > MaxDNSPacketSize {
return
}

View File

@ -149,11 +149,12 @@ func (serversInfo *ServersInfo) refresh(proxy *Proxy) (int, error) {
}
serversInfo.inner = inner
dlog.Notice("Sorted latencies:")
for i := 0; i < innerLen; i++ {
dlog.Noticef("- %5dms %s", inner[i].initialRtt, inner[i].Name)
if innerLen > 1 {
dlog.Notice("Sorted latencies:")
for i := 0; i < innerLen; i++ {
dlog.Noticef("- %5dms %s", inner[i].initialRtt, inner[i].Name)
}
}
if innerLen > 0 {
dlog.Noticef("Server with the lowest initial latency: %s (rtt: %dms)", inner[0].Name, inner[0].initialRtt)
proxy.certIgnoreTimestamp = false