From 568f54fabbd1766e7eb1026002f57cd437b598ec Mon Sep 17 00:00:00 2001 From: lifenjoiner Date: Fri, 8 Jul 2022 20:11:51 +0800 Subject: [PATCH] Reduce comparisons (#2148) --- dnscrypt-proxy/crypto.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dnscrypt-proxy/crypto.go b/dnscrypt-proxy/crypto.go index e52d3e5a..f36b2e2a 100644 --- a/dnscrypt-proxy/crypto.go +++ b/dnscrypt-proxy/crypto.go @@ -106,10 +106,9 @@ func (proxy *Proxy) Encrypt( minQuestionSize += int(xpad[0]) } paddedLength := Min(MaxDNSUDPPacketSize, (Max(minQuestionSize, QueryOverhead)+1+63) & ^63) - if proto == "udp" && serverInfo.knownBugs.fragmentsBlocked { + if serverInfo.knownBugs.fragmentsBlocked && proto == "udp" { paddedLength = MaxDNSUDPSafePacketSize - } - if serverInfo.Relay != nil && proto == "tcp" { + } else if serverInfo.Relay != nil && proto == "tcp" { paddedLength = MaxDNSPacketSize } if QueryOverhead+len(packet)+1 > paddedLength {