diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-25 02:43:09 +0200 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-10-25 02:43:09 +0200 |
| commit | 4afeaeb4b6ab6c56e582436b17f367e216f16de1 (patch) | |
| tree | b9b958494436556274132a87db3ab79cf62722e7 /ot_udp.c | |
| parent | 7af7598086e5a3f9a75507cd6f9907a98faf3d9d (diff) | |
Use the new ot_socket abstraction for socket creation, read and write
Diffstat (limited to 'ot_udp.c')
| -rw-r--r-- | ot_udp.c | 14 |
1 files changed, 7 insertions, 7 deletions
| @@ -12,12 +12,12 @@ | |||
| 12 | 12 | ||
| 13 | /* Libowfat */ | 13 | /* Libowfat */ |
| 14 | #include "io.h" | 14 | #include "io.h" |
| 15 | #include "socket.h" | ||
| 16 | 15 | ||
| 17 | /* Opentracker */ | 16 | /* Opentracker */ |
| 18 | #include "ot_ip.h" | 17 | #include "ot_ip.h" |
| 19 | #include "ot_random.h" | 18 | #include "ot_random.h" |
| 20 | #include "ot_rijndael.h" | 19 | #include "ot_rijndael.h" |
| 20 | #include "ot_socket.h" | ||
| 21 | #include "ot_stats.h" | 21 | #include "ot_stats.h" |
| 22 | #include "ot_udp.h" | 22 | #include "ot_udp.h" |
| 23 | #include "trackerlogic.h" | 23 | #include "trackerlogic.h" |
| @@ -75,13 +75,13 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { | |||
| 75 | ot_ip6 remoteip; | 75 | ot_ip6 remoteip; |
| 76 | uint32_t *inpacket = (uint32_t *)ws->inbuf; | 76 | uint32_t *inpacket = (uint32_t *)ws->inbuf; |
| 77 | uint32_t *outpacket = (uint32_t *)ws->outbuf; | 77 | uint32_t *outpacket = (uint32_t *)ws->outbuf; |
| 78 | uint32_t left, event, scopeid; | 78 | uint32_t left, event; |
| 79 | uint32_t connid[2]; | 79 | uint32_t connid[2]; |
| 80 | uint32_t action; | 80 | uint32_t action; |
| 81 | uint16_t port, remoteport; | 81 | uint16_t port, remoteport; |
| 82 | size_t byte_count, scrape_count; | 82 | size_t byte_count, scrape_count; |
| 83 | 83 | ||
| 84 | ssize_t result = socket_recv6(serversocket, ws->inbuf, G_INBUF_SIZE, remoteip, &remoteport, &scopeid); | 84 | ssize_t result = socket_recv(serversocket, ws->inbuf, G_INBUF_SIZE, remoteip, &remoteport); |
| 85 | if (result <= 0) | 85 | if (result <= 0) |
| 86 | return 0; | 86 | return 0; |
| 87 | byte_count = (size_t)result; | 87 | byte_count = (size_t)result; |
| @@ -118,7 +118,7 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { | |||
| 118 | outpacket[0] = htonl(3); | 118 | outpacket[0] = htonl(3); |
| 119 | outpacket[1] = inpacket[3]; | 119 | outpacket[1] = inpacket[3]; |
| 120 | memcpy(&outpacket[2], "Connection ID missmatch.", s); | 120 | memcpy(&outpacket[2], "Connection ID missmatch.", s); |
| 121 | socket_send6(serversocket, ws->outbuf, 8 + s, remoteip, remoteport, 0); | 121 | socket_send(serversocket, ws->outbuf, 8 + s, remoteip, remoteport); |
| 122 | stats_issue_event(EVENT_CONNID_MISSMATCH, FLAG_UDP, 8 + s); | 122 | stats_issue_event(EVENT_CONNID_MISSMATCH, FLAG_UDP, 8 + s); |
| 123 | return 1; | 123 | return 1; |
| 124 | } | 124 | } |
| @@ -135,7 +135,7 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { | |||
| 135 | outpacket[2] = connid[0]; | 135 | outpacket[2] = connid[0]; |
| 136 | outpacket[3] = connid[1]; | 136 | outpacket[3] = connid[1]; |
| 137 | 137 | ||
| 138 | socket_send6(serversocket, ws->outbuf, 16, remoteip, remoteport, 0); | 138 | socket_send(serversocket, ws->outbuf, 16, remoteip, remoteport); |
| 139 | stats_issue_event(EVENT_CONNECT, FLAG_UDP, 16); | 139 | stats_issue_event(EVENT_CONNECT, FLAG_UDP, 16); |
| 140 | break; | 140 | break; |
| 141 | case 1: /* This is an announce action */ | 141 | case 1: /* This is an announce action */ |
| @@ -185,7 +185,7 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { | |||
| 185 | ws->reply_size = 8 + add_peer_to_torrent_and_return_peers(FLAG_UDP, ws, numwant); | 185 | ws->reply_size = 8 + add_peer_to_torrent_and_return_peers(FLAG_UDP, ws, numwant); |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | socket_send6(serversocket, ws->outbuf, ws->reply_size, remoteip, remoteport, 0); | 188 | socket_send(serversocket, ws->outbuf, ws->reply_size, remoteip, remoteport); |
| 189 | stats_issue_event(EVENT_ANNOUNCE, FLAG_UDP, ws->reply_size); | 189 | stats_issue_event(EVENT_ANNOUNCE, FLAG_UDP, ws->reply_size); |
| 190 | break; | 190 | break; |
| 191 | 191 | ||
| @@ -196,7 +196,7 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { | |||
| 196 | for (scrape_count = 0; (scrape_count * 20 < byte_count - 16) && (scrape_count <= 74); scrape_count++) | 196 | for (scrape_count = 0; (scrape_count * 20 < byte_count - 16) && (scrape_count <= 74); scrape_count++) |
| 197 | return_udp_scrape_for_torrent(*(ot_hash *)(((char *)inpacket) + 16 + 20 * scrape_count), ((char *)outpacket) + 8 + 12 * scrape_count); | 197 | return_udp_scrape_for_torrent(*(ot_hash *)(((char *)inpacket) + 16 + 20 * scrape_count), ((char *)outpacket) + 8 + 12 * scrape_count); |
| 198 | 198 | ||
| 199 | socket_send6(serversocket, ws->outbuf, 8 + 12 * scrape_count, remoteip, remoteport, 0); | 199 | socket_send(serversocket, ws->outbuf, 8 + 12 * scrape_count, remoteip, remoteport); |
| 200 | stats_issue_event(EVENT_SCRAPE, FLAG_UDP, scrape_count); | 200 | stats_issue_event(EVENT_SCRAPE, FLAG_UDP, scrape_count); |
| 201 | break; | 201 | break; |
| 202 | } | 202 | } |
