summaryrefslogtreecommitdiff
path: root/ot_http.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_http.c')
-rw-r--r--ot_http.c69
1 files changed, 2 insertions, 67 deletions
diff --git a/ot_http.c b/ot_http.c
index b0e1de3..b243ff6 100644
--- a/ot_http.c
+++ b/ot_http.c
@@ -289,10 +289,8 @@ static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, c
289 {"top10", TASK_STATS_TOP10}, 289 {"top10", TASK_STATS_TOP10},
290 {"renew", TASK_STATS_RENEW}, 290 {"renew", TASK_STATS_RENEW},
291 {"syncs", TASK_STATS_SYNCS}, 291 {"syncs", TASK_STATS_SYNCS},
292 {"version", TASK_STATS_VERSION},
293 {"everything", TASK_STATS_EVERYTHING}, 292 {"everything", TASK_STATS_EVERYTHING},
294 {"statedump", TASK_FULLSCRAPE_TRACKERSTATE}, 293 {"statedump", TASK_FULLSCRAPE_TRACKERSTATE},
295 {"fulllog", TASK_STATS_FULLLOG},
296 {"woodpeckers", TASK_STATS_WOODPECKERS}, 294 {"woodpeckers", TASK_STATS_WOODPECKERS},
297#ifdef WANT_LOG_NUMWANT 295#ifdef WANT_LOG_NUMWANT
298 {"numwants", TASK_STATS_NUMWANTS}, 296 {"numwants", TASK_STATS_NUMWANTS},
@@ -559,10 +557,7 @@ static ot_keywords keywords_announce[] = {{"port", 1}, {"left", 2}, {"event",
559#ifdef WANT_IP_FROM_QUERY_STRING 557#ifdef WANT_IP_FROM_QUERY_STRING
560 {"ip", 7}, 558 {"ip", 7},
561#endif 559#endif
562#ifdef WANT_FULLLOG_NETWORKS 560 {"peer_id", 8}, {NULL, -3}};
563 {"lognet", 8},
564#endif
565 {"peer_id", 9}, {NULL, -3}};
566static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; 561static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}};
567 562
568/* For the replies that are one fixed string and nothing else, where the only 563/* For the replies that are one fixed string and nothing else, where the only
@@ -687,43 +682,7 @@ static ssize_t http_handle_announce(const int64_t sock, struct ot_workstruct
687 OT_SETIP(&ws->peer, tmp_buf1); 682 OT_SETIP(&ws->peer, tmp_buf1);
688 } break; 683 } break;
689#endif 684#endif
690#ifdef WANT_FULLLOG_NETWORKS 685 case 8: /* matched "peer_id" */
691 case 8: /* matched "lognet" */
692 {
693 // if( accesslist_is_blessed( cookie->ip, OT_PERMISSION_MAY_STAT ) ) {
694 char *tmp_buf = ws->reply;
695 ot_net net;
696 uint64_t value;
697 signed short parsed, bits;
698
699 len = urlencoded_parse(&read_ptr, tmp_buf, SCAN_SEARCHPATH_VALUE);
700 tmp_buf[len] = 0;
701 if (len <= 0)
702 HTTPERROR_400_PARAM;
703 if (*tmp_buf == '-') {
704 loglist_reset();
705 return ws->reply_size = reply_literal(ws, "Successfully removed.\n");
706 }
707 parsed = ip_parse(tmp_buf, net.address);
708 if (!parsed)
709 HTTPERROR_400_PARAM;
710 if (tmp_buf[parsed++] != '/')
711 bits = 128;
712 else {
713 parsed = scan_uint(tmp_buf + parsed, &value, 128);
714 if (!parsed)
715 HTTPERROR_400_PARAM;
716 bits = (signed short)value;
717 if (ip_is_v4mapped(net.address))
718 bits += 96;
719 }
720 net.bits = bits;
721 loglist_add_network(&net);
722 return ws->reply_size = reply_literal(ws, "Successfully added.\n");
723 //}
724 } break;
725#endif
726 case 9: /* matched "peer_id" */
727 /* ignore this, when we have less than 20 bytes */ 686 /* ignore this, when we have less than 20 bytes */
728 if (urlencoded_parse(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE) != 20) 687 if (urlencoded_parse(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE) != 20)
729 HTTPERROR_400_PARAM; 688 HTTPERROR_400_PARAM;
@@ -757,30 +716,6 @@ ssize_t http_handle_request(const int64_t sock, struct ot_workstruct *ws) {
757 ssize_t reply_off, len; 716 ssize_t reply_off, len;
758 char *read_ptr = ws->request, *write_ptr; 717 char *read_ptr = ws->request, *write_ptr;
759 718
760#ifdef WANT_FULLLOG_NETWORKS
761 struct http_data *cookie = fdstate_cookie(sock);
762 if (loglist_check_address(cookie->ip)) {
763 ot_log *log = malloc(sizeof(ot_log));
764 if (log) {
765 log->size = ws->request_size;
766 log->data = malloc(ws->request_size);
767 log->next = 0;
768 log->time = time_now_seconds();
769 memcpy(log->ip, cookie->ip, sizeof(ot_ip6));
770 if (log->data) {
771 memcpy(log->data, ws->request, ws->request_size);
772 if (!g_logchain_first)
773 g_logchain_first = g_logchain_last = log;
774 else {
775 g_logchain_last->next = log;
776 g_logchain_last = log;
777 }
778 } else
779 free(log);
780 }
781 }
782#endif
783
784#ifdef _DEBUG_HTTPERROR 719#ifdef _DEBUG_HTTPERROR
785 reply_off = ws->request_size; 720 reply_off = ws->request_size;
786 if (ws->request_size >= G_DEBUGBUF_SIZE) 721 if (ws->request_size >= G_DEBUGBUF_SIZE)