]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Make UDP tracker connection ID unsigned
authorMatt Joiner <anacrolix@gmail.com>
Thu, 8 Dec 2022 04:06:59 +0000 (15:06 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 8 Dec 2022 04:06:59 +0000 (15:06 +1100)
This is more appropriate for logging and its use as a byte blob elsewhere.

tracker/udp-server_test.go
tracker/udp/protocol.go
tracker/udp/server/server.go

index b32fe853b8259bd725a538f653c5a6e3cd6eec0c..7308ed0d8ef322514cfff25b1331976ffc564fa1 100644 (file)
@@ -47,7 +47,7 @@ func (s *server) respond(addr net.Addr, rh udp.ResponseHeader, parts ...interfac
 }
 
 func (s *server) newConn() (ret udp.ConnectionId) {
-       ret = rand.Int63()
+       ret = rand.Uint64()
        if s.conns == nil {
                s.conns = make(map[udp.ConnectionId]struct{})
        }
index f6beb4c6d55c3e495730fcac1caebfc23c717d4e..653d013efcd5367888ea6bde3af13d7d6ae7d749 100644 (file)
@@ -26,7 +26,7 @@ const (
 
 type TransactionId = int32
 
-type ConnectionId = int64
+type ConnectionId = uint64
 
 type ConnectionRequest struct {
        ConnectionId  ConnectionId
index dfcc6500a0e12776c865b49a0eb1c195c7cb8001..20e827b9737bbecb614622edfb22eaeb2a09f21e 100644 (file)
@@ -181,7 +181,7 @@ func randomConnectionId() udp.ConnectionId {
        if err != nil {
                panic(err)
        }
-       return int64(binary.BigEndian.Uint64(b[:]))
+       return binary.BigEndian.Uint64(b[:])
 }
 
 func RunSimple(ctx context.Context, s *Server, pc net.PacketConn, family udp.AddrFamily) error {