1
0
mirror of https://github.com/DNSCrypt/dnscrypt-proxy.git synced 2025-01-14 02:25:52 +01:00

Reduce comparisons (#2148)

This commit is contained in:
lifenjoiner 2022-07-08 20:11:51 +08:00 committed by GitHub
parent dc2fff05be
commit 568f54fabb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,10 +106,9 @@ func (proxy *Proxy) Encrypt(
minQuestionSize += int(xpad[0]) minQuestionSize += int(xpad[0])
} }
paddedLength := Min(MaxDNSUDPPacketSize, (Max(minQuestionSize, QueryOverhead)+1+63) & ^63) paddedLength := Min(MaxDNSUDPPacketSize, (Max(minQuestionSize, QueryOverhead)+1+63) & ^63)
if proto == "udp" && serverInfo.knownBugs.fragmentsBlocked { if serverInfo.knownBugs.fragmentsBlocked && proto == "udp" {
paddedLength = MaxDNSUDPSafePacketSize paddedLength = MaxDNSUDPSafePacketSize
} } else if serverInfo.Relay != nil && proto == "tcp" {
if serverInfo.Relay != nil && proto == "tcp" {
paddedLength = MaxDNSPacketSize paddedLength = MaxDNSPacketSize
} }
if QueryOverhead+len(packet)+1 > paddedLength { if QueryOverhead+len(packet)+1 > paddedLength {