diff options
Diffstat (limited to 'ot_udp.c')
| -rw-r--r-- | ot_udp.c | 20 |
1 files changed, 14 insertions, 6 deletions
| @@ -10,9 +10,6 @@ | |||
| 10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
| 11 | #include <string.h> | 11 | #include <string.h> |
| 12 | 12 | ||
| 13 | /* Libowfat */ | ||
| 14 | #include "io.h" | ||
| 15 | |||
| 16 | /* Opentracker */ | 13 | /* Opentracker */ |
| 17 | #include "ot_ip.h" | 14 | #include "ot_ip.h" |
| 18 | #include "ot_random.h" | 15 | #include "ot_random.h" |
| @@ -108,10 +105,11 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { | |||
| 108 | match, return an error packet */ | 105 | match, return an error packet */ |
| 109 | udp_make_connectionid(connid, remoteip, 1); | 106 | udp_make_connectionid(connid, remoteip, 1); |
| 110 | if (inpacket[0] != connid[0] || inpacket[1] != connid[1]) { | 107 | if (inpacket[0] != connid[0] || inpacket[1] != connid[1]) { |
| 111 | const size_t s = sizeof("Connection ID missmatch."); | 108 | const char err_idmiss[] = "Connection ID missmatch."; |
| 109 | size_t s = sizeof(err_idmiss); | ||
| 112 | outpacket[0] = htonl(3); | 110 | outpacket[0] = htonl(3); |
| 113 | outpacket[1] = inpacket[3]; | 111 | outpacket[1] = inpacket[3]; |
| 114 | memcpy(&outpacket[2], "Connection ID missmatch.", s); | 112 | memcpy(&outpacket[2], &err_idmiss[0], s); |
| 115 | socket_send(serversocket, ws->outbuf, 8 + s, remoteip, remoteport); | 113 | socket_send(serversocket, ws->outbuf, 8 + s, remoteip, remoteport); |
| 116 | stats_issue_event(EVENT_CONNID_MISSMATCH, FLAG_UDP, 8 + s); | 114 | stats_issue_event(EVENT_CONNID_MISSMATCH, FLAG_UDP, 8 + s); |
| 117 | return 1; | 115 | return 1; |
| @@ -176,7 +174,17 @@ int handle_udp6(int64_t serversocket, struct ot_workstruct *ws) { | |||
| 176 | numwant = max_peers; | 174 | numwant = max_peers; |
| 177 | 175 | ||
| 178 | ws->reply = ws->outbuf + 8; | 176 | ws->reply = ws->outbuf + 8; |
| 179 | ws->reply_size = 8 + add_peer_to_torrent_and_return_peers(FLAG_UDP, ws, numwant); | 177 | ws->reply_size = add_peer_to_torrent_and_return_peers(FLAG_UDP, ws, numwant); |
| 178 | |||
| 179 | if (!ws->reply_size) { | ||
| 180 | const char err_unauth[] = "Requested download is not authorized for use with this tracker."; | ||
| 181 | size_t s = sizeof(err_unauth); | ||
| 182 | outpacket[0] = htonl(3); | ||
| 183 | memcpy(&outpacket[2], &err_unauth[0], s); | ||
| 184 | socket_send(serversocket, ws->outbuf, 8 + s, remoteip, remoteport); | ||
| 185 | return 1; | ||
| 186 | } | ||
| 187 | ws->reply_size += 8; | ||
| 180 | } | 188 | } |
| 181 | 189 | ||
| 182 | socket_send(serversocket, ws->outbuf, ws->reply_size, remoteip, remoteport); | 190 | socket_send(serversocket, ws->outbuf, ws->reply_size, remoteip, remoteport); |
