summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2024-03-09 23:58:41 +0100
committerDirk Engling <erdgeist@erdgeist.org>2024-03-09 23:58:41 +0100
commit6604d65779796f2df6bd52840bc2b2e3f9f765b3 (patch)
tree1f575456842933c1fd8ff9d11cee5cfefddbbd25
parent9f080415851246df48d9e906b4c7d7ee3b0dbefc (diff)
Some clients have added the /stats URL as /announce URL and cause a lot of expensive operations. Prevent that
-rw-r--r--ot_http.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ot_http.c b/ot_http.c
index 2e16b58..90b7a4b 100644
--- a/ot_http.c
+++ b/ot_http.c
@@ -194,7 +194,7 @@ ssize_t http_sendiovecdata( const int64 sock, struct ot_workstruct *ws, int iove
194 194
195static ssize_t http_handle_stats( const int64 sock, struct ot_workstruct *ws, char *read_ptr ) { 195static ssize_t http_handle_stats( const int64 sock, struct ot_workstruct *ws, char *read_ptr ) {
196static const ot_keywords keywords_main[] = 196static const ot_keywords keywords_main[] =
197 { { "mode", 1 }, {"format", 2 }, { NULL, -3 } }; 197 { { "mode", 1 }, {"format", 2 }, {"info_hash", 3}, { NULL, -3 } };
198static const ot_keywords keywords_mode[] = 198static const ot_keywords keywords_mode[] =
199 { { "peer", TASK_STATS_PEERS }, { "conn", TASK_STATS_CONNS }, { "scrp", TASK_STATS_SCRAPE }, { "udp4", TASK_STATS_UDP }, { "tcp4", TASK_STATS_TCP }, 199 { { "peer", TASK_STATS_PEERS }, { "conn", TASK_STATS_CONNS }, { "scrp", TASK_STATS_SCRAPE }, { "udp4", TASK_STATS_UDP }, { "tcp4", TASK_STATS_TCP },
200 { "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE }, 200 { "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE },
@@ -230,6 +230,7 @@ static const ot_keywords keywords_format[] =
230 case 2: /* matched "format" */ 230 case 2: /* matched "format" */
231 if( ( format = scan_find_keywords( keywords_format, &read_ptr, SCAN_SEARCHPATH_VALUE ) ) <= 0 ) HTTPERROR_400_PARAM; 231 if( ( format = scan_find_keywords( keywords_format, &read_ptr, SCAN_SEARCHPATH_VALUE ) ) <= 0 ) HTTPERROR_400_PARAM;
232 break; 232 break;
233 case 3: HTTPERROR_400_PARAM; /* If the stats URL was mistakenly added as announce URL, return a 400 */
233 } 234 }
234 } 235 }
235 236