diff options
Diffstat (limited to 'ot_http.c')
| -rw-r--r-- | ot_http.c | 68 |
1 files changed, 2 insertions, 66 deletions
| @@ -292,7 +292,6 @@ static ssize_t http_handle_stats(const int64_t sock, struct ot_workstruct *ws, c | |||
| 292 | {"version", TASK_STATS_VERSION}, | 292 | {"version", TASK_STATS_VERSION}, |
| 293 | {"everything", TASK_STATS_EVERYTHING}, | 293 | {"everything", TASK_STATS_EVERYTHING}, |
| 294 | {"statedump", TASK_FULLSCRAPE_TRACKERSTATE}, | 294 | {"statedump", TASK_FULLSCRAPE_TRACKERSTATE}, |
| 295 | {"fulllog", TASK_STATS_FULLLOG}, | ||
| 296 | {"woodpeckers", TASK_STATS_WOODPECKERS}, | 295 | {"woodpeckers", TASK_STATS_WOODPECKERS}, |
| 297 | #ifdef WANT_LOG_NUMWANT | 296 | #ifdef WANT_LOG_NUMWANT |
| 298 | {"numwants", TASK_STATS_NUMWANTS}, | 297 | {"numwants", TASK_STATS_NUMWANTS}, |
| @@ -559,10 +558,7 @@ static ot_keywords keywords_announce[] = {{"port", 1}, {"left", 2}, {"event", | |||
| 559 | #ifdef WANT_IP_FROM_QUERY_STRING | 558 | #ifdef WANT_IP_FROM_QUERY_STRING |
| 560 | {"ip", 7}, | 559 | {"ip", 7}, |
| 561 | #endif | 560 | #endif |
| 562 | #ifdef WANT_FULLLOG_NETWORKS | 561 | {"peer_id", 8}, {NULL, -3}}; |
| 563 | {"lognet", 8}, | ||
| 564 | #endif | ||
| 565 | {"peer_id", 9}, {NULL, -3}}; | ||
| 566 | static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; | 562 | static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; |
| 567 | 563 | ||
| 568 | /* For the replies that are one fixed string and nothing else, where the only | 564 | /* For the replies that are one fixed string and nothing else, where the only |
| @@ -687,43 +683,7 @@ static ssize_t http_handle_announce(const int64_t sock, struct ot_workstruct | |||
| 687 | OT_SETIP(&ws->peer, tmp_buf1); | 683 | OT_SETIP(&ws->peer, tmp_buf1); |
| 688 | } break; | 684 | } break; |
| 689 | #endif | 685 | #endif |
| 690 | #ifdef WANT_FULLLOG_NETWORKS | 686 | 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 */ | 687 | /* ignore this, when we have less than 20 bytes */ |
| 728 | if (urlencoded_parse(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE) != 20) | 688 | if (urlencoded_parse(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE) != 20) |
| 729 | HTTPERROR_400_PARAM; | 689 | HTTPERROR_400_PARAM; |
| @@ -757,30 +717,6 @@ ssize_t http_handle_request(const int64_t sock, struct ot_workstruct *ws) { | |||
| 757 | ssize_t reply_off, len; | 717 | ssize_t reply_off, len; |
| 758 | char *read_ptr = ws->request, *write_ptr; | 718 | char *read_ptr = ws->request, *write_ptr; |
| 759 | 719 | ||
| 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 | 720 | #ifdef _DEBUG_HTTPERROR |
| 785 | reply_off = ws->request_size; | 721 | reply_off = ws->request_size; |
| 786 | if (ws->request_size >= G_DEBUGBUF_SIZE) | 722 | if (ws->request_size >= G_DEBUGBUF_SIZE) |
