From 5cedf602f23974955808826606916356e2c2da97 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 8 Dec 2022 15:06:59 +1100 Subject: [PATCH] Make UDP tracker connection ID unsigned This is more appropriate for logging and its use as a byte blob elsewhere. --- tracker/udp-server_test.go | 2 +- tracker/udp/protocol.go | 2 +- tracker/udp/server/server.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tracker/udp-server_test.go b/tracker/udp-server_test.go index b32fe853..7308ed0d 100644 --- a/tracker/udp-server_test.go +++ b/tracker/udp-server_test.go @@ -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{}) } diff --git a/tracker/udp/protocol.go b/tracker/udp/protocol.go index f6beb4c6..653d013e 100644 --- a/tracker/udp/protocol.go +++ b/tracker/udp/protocol.go @@ -26,7 +26,7 @@ const ( type TransactionId = int32 -type ConnectionId = int64 +type ConnectionId = uint64 type ConnectionRequest struct { ConnectionId ConnectionId diff --git a/tracker/udp/server/server.go b/tracker/udp/server/server.go index dfcc6500..20e827b9 100644 --- a/tracker/udp/server/server.go +++ b/tracker/udp/server/server.go @@ -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 {