Skip to content

Commit aca031c

Browse files
committed
Don't display sorted latencies if there is only one (or none)
1 parent 8e01421 commit aca031c

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

dnscrypt-proxy/plugins.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ func NewPluginsState(proxy *Proxy, clientProto string, clientAddr *net.Addr, sta
164164
}
165165
}
166166

167-
func (pluginsState *PluginsState) ApplyQueryPlugins(pluginsGlobals *PluginsGlobals, packet []byte, serverName *string) ([]byte, error) {
167+
func (pluginsState *PluginsState) ApplyQueryPlugins(pluginsGlobals *PluginsGlobals, packet []byte, serverName string) ([]byte, error) {
168168
if len(*pluginsGlobals.queryPlugins) == 0 && len(*pluginsGlobals.loggingPlugins) == 0 {
169169
return packet, nil
170170
}
171-
pluginsState.serverName = *serverName
171+
pluginsState.serverName = serverName
172172
pluginsState.action = PluginsActionForward
173173
msg := dns.Msg{}
174174
if err := msg.Unpack(packet); err != nil {

dnscrypt-proxy/proxy.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,11 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
332332
return
333333
}
334334
pluginsState := NewPluginsState(proxy, clientProto, clientAddr, start)
335-
query, _ = pluginsState.ApplyQueryPlugins(&proxy.pluginsGlobals, query, &serverInfo.Name)
335+
serverName := "-"
336+
if serverInfo != nil {
337+
serverName = serverInfo.Name
338+
}
339+
query, _ = pluginsState.ApplyQueryPlugins(&proxy.pluginsGlobals, query, serverName)
336340
if len(query) < MinDNSPacketSize || len(query) > MaxDNSPacketSize {
337341
return
338342
}

dnscrypt-proxy/serversInfo.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ func (serversInfo *ServersInfo) refresh(proxy *Proxy) (int, error) {
149149
}
150150
serversInfo.inner = inner
151151

152-
dlog.Notice("Sorted latencies:")
153-
for i := 0; i < innerLen; i++ {
154-
dlog.Noticef("- %5dms %s", inner[i].initialRtt, inner[i].Name)
152+
if innerLen > 1 {
153+
dlog.Notice("Sorted latencies:")
154+
for i := 0; i < innerLen; i++ {
155+
dlog.Noticef("- %5dms %s", inner[i].initialRtt, inner[i].Name)
156+
}
155157
}
156-
157158
if innerLen > 0 {
158159
dlog.Noticef("Server with the lowest initial latency: %s (rtt: %dms)", inner[0].Name, inner[0].initialRtt)
159160
proxy.certIgnoreTimestamp = false

0 commit comments

Comments
 (0)