From adc518a2063ee78e4217a8aba51b116af1af42f4 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 28 Nov 2026 19:46:59 +0100 Subject: Add helper to pack uint32 in network byte order --- src/ot_udp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/ot_udp.c') diff --git a/src/ot_udp.c b/src/ot_udp.c index 2918c25..7a05b61 100644 --- a/src/ot_udp.c +++ b/src/ot_udp.c @@ -204,11 +204,9 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { if (!left) OT_PEERFLAG(ws->peer) |= PEER_FLAG_SEEDING; - reply = udp_reply_header(ws->outbuf, UDP_ACTION_ANNOUNCE, request); + ws->reply = udp_reply_header(ws->outbuf, UDP_ACTION_ANNOUNCE, request); if (OT_PEERFLAG(ws->peer) & PEER_FLAG_STOPPED) { /* Peer is gone. */ - /* This one writes the whole reply, and leaves the header alone */ - ws->reply = ws->outbuf; ws->reply_size = remove_peer_from_torrent(FLAG_UDP, ws); } else { /* List of peers should fit in a single UDP packet */ @@ -216,7 +214,6 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { if (numwant > max_peers) numwant = max_peers; - ws->reply = reply; ws->reply_size = add_peer_to_torrent_and_return_peers(FLAG_UDP, ws, numwant); /* The announce path answers a refusal itself, so nothing is left here @@ -225,8 +222,8 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { udp_send_error(serversocket, ws, "Tracker is out of resources, try again later.", remoteip, remoteport); return 1; } - ws->reply_size += UDP_REPLY_HEADER_SIZE; } + ws->reply_size += UDP_REPLY_HEADER_SIZE; socket_send(serversocket, ws->outbuf, ws->reply_size, remoteip, remoteport); stats_issue_event(ws, EVENT_ANNOUNCE, FLAG_UDP, ws->reply_size); -- cgit v1.3