Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6534d3d

Browse files
authoredMar 18, 2025··
DNS: Make UDP DNS random Transaction ID
1 parent 2cba2c4 commit 6534d3d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎app/dns/nameserver_udp.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package dns
22

33
import (
44
"context"
5+
"math/rand"
56
"strings"
67
"sync"
7-
"sync/atomic"
88
"time"
99

1010
"github.com/xtls/xray-core/common"
@@ -31,7 +31,6 @@ type ClassicNameServer struct {
3131
pub *pubsub.Service
3232
udpServer *udp.Dispatcher
3333
cleanup *task.Periodic
34-
reqID uint32
3534
queryStrategy QueryStrategy
3635
}
3736

@@ -176,7 +175,7 @@ func (s *ClassicNameServer) updateIP(domain string, newRec *record) {
176175
}
177176

178177
func (s *ClassicNameServer) newReqID() uint16 {
179-
return uint16(atomic.AddUint32(&s.reqID, 1))
178+
return uint16(rand.Intn(65535) + 1) // no zero
180179
}
181180

182181
func (s *ClassicNameServer) addPendingRequest(req *dnsRequest) {

0 commit comments

Comments
 (0)
Please sign in to comment.