|
|
@ -4,31 +4,31 @@ |
|
|
|
$id$ */ |
|
|
|
$id$ */ |
|
|
|
|
|
|
|
|
|
|
|
/* System */ |
|
|
|
/* System */ |
|
|
|
#include <sys/types.h> |
|
|
|
|
|
|
|
#include <arpa/inet.h> |
|
|
|
#include <arpa/inet.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <pthread.h> |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdio.h> |
|
|
|
|
|
|
|
#include <stdlib.h> |
|
|
|
#include <string.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
#include <sys/types.h> |
|
|
|
#include <unistd.h> |
|
|
|
#include <unistd.h> |
|
|
|
#include <pthread.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Libowfat */ |
|
|
|
/* Libowfat */ |
|
|
|
#include "byte.h" |
|
|
|
|
|
|
|
#include "array.h" |
|
|
|
#include "array.h" |
|
|
|
|
|
|
|
#include "byte.h" |
|
|
|
|
|
|
|
#include "case.h" |
|
|
|
#include "iob.h" |
|
|
|
#include "iob.h" |
|
|
|
#include "ip6.h" |
|
|
|
#include "ip6.h" |
|
|
|
#include "scan.h" |
|
|
|
#include "scan.h" |
|
|
|
#include "case.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Opentracker */ |
|
|
|
/* Opentracker */ |
|
|
|
#include "trackerlogic.h" |
|
|
|
#include "ot_accesslist.h" |
|
|
|
#include "ot_mutex.h" |
|
|
|
#include "ot_fullscrape.h" |
|
|
|
#include "ot_http.h" |
|
|
|
#include "ot_http.h" |
|
|
|
#include "ot_iovec.h" |
|
|
|
#include "ot_iovec.h" |
|
|
|
#include "scan_urlencoded_query.h" |
|
|
|
#include "ot_mutex.h" |
|
|
|
#include "ot_fullscrape.h" |
|
|
|
|
|
|
|
#include "ot_stats.h" |
|
|
|
#include "ot_stats.h" |
|
|
|
#include "ot_accesslist.h" |
|
|
|
#include "scan_urlencoded_query.h" |
|
|
|
|
|
|
|
#include "trackerlogic.h" |
|
|
|
|
|
|
|
|
|
|
|
#define OT_MAXMULTISCRAPE_COUNT 64 |
|
|
|
#define OT_MAXMULTISCRAPE_COUNT 64 |
|
|
|
#define OT_BATCH_LIMIT (1024 * 1024 * 16) |
|
|
|
#define OT_BATCH_LIMIT (1024 * 1024 * 16) |
|
|
@ -37,15 +37,16 @@ extern char *g_redirecturl; |
|
|
|
char *g_stats_path; |
|
|
|
char *g_stats_path; |
|
|
|
ssize_t g_stats_path_len; |
|
|
|
ssize_t g_stats_path_len; |
|
|
|
|
|
|
|
|
|
|
|
enum { |
|
|
|
enum { SUCCESS_HTTP_HEADER_LENGTH = 80, SUCCESS_HTTP_SIZE_OFF = 17 }; |
|
|
|
SUCCESS_HTTP_HEADER_LENGTH = 80, |
|
|
|
|
|
|
|
SUCCESS_HTTP_SIZE_OFF = 17 }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void http_senddata(const int64 sock, struct ot_workstruct *ws) { |
|
|
|
static void http_senddata(const int64 sock, struct ot_workstruct *ws) { |
|
|
|
struct http_data *cookie = io_getcookie(sock); |
|
|
|
struct http_data *cookie = io_getcookie(sock); |
|
|
|
ssize_t written_size; |
|
|
|
ssize_t written_size; |
|
|
|
|
|
|
|
|
|
|
|
if( !cookie ) { io_close(sock); return; } |
|
|
|
if (!cookie) { |
|
|
|
|
|
|
|
io_close(sock); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* whoever sends data is not interested in its input-array */ |
|
|
|
/* whoever sends data is not interested in its input-array */ |
|
|
|
if (ws->keep_alive && ws->header_size != ws->request_size) { |
|
|
|
if (ws->keep_alive && ws->header_size != ws->request_size) { |
|
|
@ -61,7 +62,9 @@ static void http_senddata( const int64 sock, struct ot_workstruct *ws ) { |
|
|
|
written_size = write(sock, ws->reply, ws->reply_size); |
|
|
|
written_size = write(sock, ws->reply, ws->reply_size); |
|
|
|
if ((written_size < 0) || ((written_size == ws->reply_size) && !ws->keep_alive)) { |
|
|
|
if ((written_size < 0) || ((written_size == ws->reply_size) && !ws->keep_alive)) { |
|
|
|
array_reset(&cookie->request); |
|
|
|
array_reset(&cookie->request); |
|
|
|
free( cookie ); io_close( sock ); return; |
|
|
|
free(cookie); |
|
|
|
|
|
|
|
io_close(sock); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (written_size < ws->reply_size) { |
|
|
|
if (written_size < ws->reply_size) { |
|
|
@ -70,7 +73,8 @@ static void http_senddata( const int64 sock, struct ot_workstruct *ws ) { |
|
|
|
|
|
|
|
|
|
|
|
if (!(outbuf = malloc(ws->reply_size - written_size))) { |
|
|
|
if (!(outbuf = malloc(ws->reply_size - written_size))) { |
|
|
|
array_reset(&cookie->request); |
|
|
|
array_reset(&cookie->request); |
|
|
|
free(cookie); io_close( sock ); |
|
|
|
free(cookie); |
|
|
|
|
|
|
|
io_close(sock); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -85,7 +89,8 @@ static void http_senddata( const int64 sock, struct ot_workstruct *ws ) { |
|
|
|
|
|
|
|
|
|
|
|
/* writeable short data sockets just have a tcp timeout */ |
|
|
|
/* writeable short data sockets just have a tcp timeout */ |
|
|
|
if (!ws->keep_alive) { |
|
|
|
if (!ws->keep_alive) { |
|
|
|
taia_uint( &t, 0 ); io_timeout( sock, t ); |
|
|
|
taia_uint(&t, 0); |
|
|
|
|
|
|
|
io_timeout(sock, t); |
|
|
|
io_dontwantread(sock); |
|
|
|
io_dontwantread(sock); |
|
|
|
} |
|
|
|
} |
|
|
|
io_wantwrite(sock); |
|
|
|
io_wantwrite(sock); |
|
|
@ -110,7 +115,8 @@ ssize_t http_issue_error( const int64 sock, struct ot_workstruct *ws, int code ) |
|
|
|
if (code == CODE_HTTPERROR_302) |
|
|
|
if (code == CODE_HTTPERROR_302) |
|
|
|
ws->reply_size = snprintf(ws->reply, G_OUTBUF_SIZE, "HTTP/1.0 302 Found\r\nContent-Length: 0\r\nLocation: %s\r\n\r\n", g_redirecturl); |
|
|
|
ws->reply_size = snprintf(ws->reply, G_OUTBUF_SIZE, "HTTP/1.0 302 Found\r\nContent-Length: 0\r\nLocation: %s\r\n\r\n", g_redirecturl); |
|
|
|
else |
|
|
|
else |
|
|
|
ws->reply_size = snprintf( ws->reply, G_OUTBUF_SIZE, "HTTP/1.0 %s\r\nContent-Type: text/html\r\nContent-Length: %zd\r\n\r\n<title>%s</title>\n", title, strlen(title)+16-4,title+4); |
|
|
|
ws->reply_size = snprintf(ws->reply, G_OUTBUF_SIZE, "HTTP/1.0 %s\r\nContent-Type: text/html\r\nContent-Length: %zd\r\n\r\n<title>%s</title>\n", title, |
|
|
|
|
|
|
|
strlen(title) + 16 - 4, title + 4); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG_HTTPERROR |
|
|
|
#ifdef _DEBUG_HTTPERROR |
|
|
|
fprintf(stderr, "DEBUG: invalid request was: %s\n", ws->debugbuf); |
|
|
|
fprintf(stderr, "DEBUG: invalid request was: %s\n", ws->debugbuf); |
|
|
@ -155,7 +161,8 @@ ssize_t http_sendiovecdata( const int64 sock, struct ot_workstruct *ws, int iove |
|
|
|
header_size = asprintf(&header, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n%sContent-Length: %zd\r\n\r\n", encoding, size); |
|
|
|
header_size = asprintf(&header, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n%sContent-Length: %zd\r\n\r\n", encoding, size); |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (!(cookie->flag & STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER)) { |
|
|
|
if (!(cookie->flag & STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER)) { |
|
|
|
header_size = asprintf( &header, "HTTP/1.0 200 OK\r\nContent-Type: application/octet-stream\r\n%sTransfer-Encoding: chunked\r\n\r\n%zx\r\n", encoding, size ); |
|
|
|
header_size = |
|
|
|
|
|
|
|
asprintf(&header, "HTTP/1.0 200 OK\r\nContent-Type: application/octet-stream\r\n%sTransfer-Encoding: chunked\r\n\r\n%zx\r\n", encoding, size); |
|
|
|
cookie->flag |= STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER; |
|
|
|
cookie->flag |= STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER; |
|
|
|
} else |
|
|
|
} else |
|
|
|
header_size = asprintf(&header, "%zx\r\n", size); |
|
|
|
header_size = asprintf(&header, "%zx\r\n", size); |
|
|
@ -203,29 +210,43 @@ ssize_t http_sendiovecdata( const int64 sock, struct ot_workstruct *ws, int iove |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* writeable sockets timeout after 10 minutes */ |
|
|
|
/* writeable sockets timeout after 10 minutes */ |
|
|
|
taia_now( &t ); taia_addsec( &t, &t, OT_CLIENT_TIMEOUT_SEND ); |
|
|
|
taia_now(&t); |
|
|
|
|
|
|
|
taia_addsec(&t, &t, OT_CLIENT_TIMEOUT_SEND); |
|
|
|
io_timeout(sock, t); |
|
|
|
io_timeout(sock, t); |
|
|
|
io_wantwrite(sock); |
|
|
|
io_wantwrite(sock); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static ssize_t http_handle_stats(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { |
|
|
|
static ssize_t http_handle_stats(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { |
|
|
|
static const ot_keywords keywords_main[] = |
|
|
|
static const ot_keywords keywords_main[] = {{"mode", 1}, {"format", 2}, {"info_hash", 3}, {NULL, -3}}; |
|
|
|
{ { "mode", 1 }, {"format", 2 }, {"info_hash", 3}, { NULL, -3 } }; |
|
|
|
static const ot_keywords keywords_mode[] = {{"peer", TASK_STATS_PEERS}, |
|
|
|
static const ot_keywords keywords_mode[] = |
|
|
|
{"conn", TASK_STATS_CONNS}, |
|
|
|
{ { "peer", TASK_STATS_PEERS }, { "conn", TASK_STATS_CONNS }, { "scrp", TASK_STATS_SCRAPE }, { "udp4", TASK_STATS_UDP }, { "tcp4", TASK_STATS_TCP }, |
|
|
|
{"scrp", TASK_STATS_SCRAPE}, |
|
|
|
{ "busy", TASK_STATS_BUSY_NETWORKS }, { "torr", TASK_STATS_TORRENTS }, { "fscr", TASK_STATS_FULLSCRAPE }, |
|
|
|
{"udp4", TASK_STATS_UDP}, |
|
|
|
{ "s24s", TASK_STATS_SLASH24S }, { "tpbs", TASK_STATS_TPB }, { "herr", TASK_STATS_HTTPERRORS }, { "completed", TASK_STATS_COMPLETED }, |
|
|
|
{"tcp4", TASK_STATS_TCP}, |
|
|
|
{ "top100", TASK_STATS_TOP100 }, { "top10", TASK_STATS_TOP10 }, { "renew", TASK_STATS_RENEW }, { "syncs", TASK_STATS_SYNCS }, { "version", TASK_STATS_VERSION }, |
|
|
|
{"busy", TASK_STATS_BUSY_NETWORKS}, |
|
|
|
{ "everything", TASK_STATS_EVERYTHING }, { "statedump", TASK_FULLSCRAPE_TRACKERSTATE }, { "fulllog", TASK_STATS_FULLLOG }, |
|
|
|
{"torr", TASK_STATS_TORRENTS}, |
|
|
|
|
|
|
|
{"fscr", TASK_STATS_FULLSCRAPE}, |
|
|
|
|
|
|
|
{"s24s", TASK_STATS_SLASH24S}, |
|
|
|
|
|
|
|
{"tpbs", TASK_STATS_TPB}, |
|
|
|
|
|
|
|
{"herr", TASK_STATS_HTTPERRORS}, |
|
|
|
|
|
|
|
{"completed", TASK_STATS_COMPLETED}, |
|
|
|
|
|
|
|
{"top100", TASK_STATS_TOP100}, |
|
|
|
|
|
|
|
{"top10", TASK_STATS_TOP10}, |
|
|
|
|
|
|
|
{"renew", TASK_STATS_RENEW}, |
|
|
|
|
|
|
|
{"syncs", TASK_STATS_SYNCS}, |
|
|
|
|
|
|
|
{"version", TASK_STATS_VERSION}, |
|
|
|
|
|
|
|
{"everything", TASK_STATS_EVERYTHING}, |
|
|
|
|
|
|
|
{"statedump", TASK_FULLSCRAPE_TRACKERSTATE}, |
|
|
|
|
|
|
|
{"fulllog", TASK_STATS_FULLLOG}, |
|
|
|
{"woodpeckers", TASK_STATS_WOODPECKERS}, |
|
|
|
{"woodpeckers", TASK_STATS_WOODPECKERS}, |
|
|
|
#ifdef WANT_LOG_NUMWANT |
|
|
|
#ifdef WANT_LOG_NUMWANT |
|
|
|
{"numwants", TASK_STATS_NUMWANTS}, |
|
|
|
{"numwants", TASK_STATS_NUMWANTS}, |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
{NULL, -3}}; |
|
|
|
{NULL, -3}}; |
|
|
|
static const ot_keywords keywords_format[] = |
|
|
|
static const ot_keywords keywords_format[] = {{"bin", TASK_FULLSCRAPE_TPB_BINARY}, {"ben", TASK_FULLSCRAPE}, |
|
|
|
{ { "bin", TASK_FULLSCRAPE_TPB_BINARY }, { "ben", TASK_FULLSCRAPE }, { "url", TASK_FULLSCRAPE_TPB_URLENCODED }, |
|
|
|
{"url", TASK_FULLSCRAPE_TPB_URLENCODED}, {"txt", TASK_FULLSCRAPE_TPB_ASCII}, |
|
|
|
{ "txt", TASK_FULLSCRAPE_TPB_ASCII }, { "txtp", TASK_FULLSCRAPE_TPB_ASCII_PLUS }, { NULL, -3 } }; |
|
|
|
{"txtp", TASK_FULLSCRAPE_TPB_ASCII_PLUS}, {NULL, -3}}; |
|
|
|
|
|
|
|
|
|
|
|
int mode = TASK_STATS_PEERS, scanon = 1, format = 0; |
|
|
|
int mode = TASK_STATS_PEERS, scanon = 1, format = 0; |
|
|
|
|
|
|
|
|
|
|
@ -238,22 +259,31 @@ static const ot_keywords keywords_format[] = |
|
|
|
|
|
|
|
|
|
|
|
while (scanon) { |
|
|
|
while (scanon) { |
|
|
|
switch (scan_find_keywords(keywords_main, &read_ptr, SCAN_SEARCHPATH_PARAM)) { |
|
|
|
switch (scan_find_keywords(keywords_main, &read_ptr, SCAN_SEARCHPATH_PARAM)) { |
|
|
|
case -2: scanon = 0; break; /* TERMINATOR */ |
|
|
|
case -2: |
|
|
|
case -1: HTTPERROR_400_PARAM; /* PARSE ERROR */ |
|
|
|
scanon = 0; |
|
|
|
case -3: scan_urlencoded_skipvalue( &read_ptr ); break; |
|
|
|
break; /* TERMINATOR */ |
|
|
|
|
|
|
|
case -1: |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; /* PARSE ERROR */ |
|
|
|
|
|
|
|
case -3: |
|
|
|
|
|
|
|
scan_urlencoded_skipvalue(&read_ptr); |
|
|
|
|
|
|
|
break; |
|
|
|
case 1: /* matched "mode" */ |
|
|
|
case 1: /* matched "mode" */ |
|
|
|
if( ( mode = scan_find_keywords( keywords_mode, &read_ptr, SCAN_SEARCHPATH_VALUE ) ) <= 0 ) HTTPERROR_400_PARAM; |
|
|
|
if ((mode = scan_find_keywords(keywords_mode, &read_ptr, SCAN_SEARCHPATH_VALUE)) <= 0) |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 2: /* matched "format" */ |
|
|
|
case 2: /* matched "format" */ |
|
|
|
if( ( format = scan_find_keywords( keywords_format, &read_ptr, SCAN_SEARCHPATH_VALUE ) ) <= 0 ) HTTPERROR_400_PARAM; |
|
|
|
if ((format = scan_find_keywords(keywords_format, &read_ptr, SCAN_SEARCHPATH_VALUE)) <= 0) |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 3: HTTPERROR_400_PARAM; /* If the stats URL was mistakenly added as announce URL, return a 400 */ |
|
|
|
case 3: |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; /* If the stats URL was mistakenly added as announce URL, return a 400 */ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef WANT_FULLSCRAPE |
|
|
|
#ifdef WANT_FULLSCRAPE |
|
|
|
if (mode == TASK_FULLSCRAPE_TRACKERSTATE) { |
|
|
|
if (mode == TASK_FULLSCRAPE_TRACKERSTATE) { |
|
|
|
format = mode; mode = TASK_STATS_TPB; |
|
|
|
format = mode; |
|
|
|
|
|
|
|
mode = TASK_STATS_TPB; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mode == TASK_STATS_TPB) { |
|
|
|
if (mode == TASK_STATS_TPB) { |
|
|
@ -274,7 +304,8 @@ static const ot_keywords keywords_format[] = |
|
|
|
cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED; |
|
|
|
cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED; |
|
|
|
|
|
|
|
|
|
|
|
/* Clients waiting for us should not easily timeout */ |
|
|
|
/* Clients waiting for us should not easily timeout */ |
|
|
|
taia_uint( &t, 0 ); io_timeout( sock, t ); |
|
|
|
taia_uint(&t, 0); |
|
|
|
|
|
|
|
io_timeout(sock, t); |
|
|
|
fullscrape_deliver(sock, format); |
|
|
|
fullscrape_deliver(sock, format); |
|
|
|
io_dontwantread(sock); |
|
|
|
io_dontwantread(sock); |
|
|
|
return ws->reply_size = -2; |
|
|
|
return ws->reply_size = -2; |
|
|
@ -285,7 +316,8 @@ static const ot_keywords keywords_format[] = |
|
|
|
if ((mode & TASK_CLASS_MASK) == TASK_STATS) { |
|
|
|
if ((mode & TASK_CLASS_MASK) == TASK_STATS) { |
|
|
|
tai6464 t; |
|
|
|
tai6464 t; |
|
|
|
/* Complex stats also include expensive memory debugging tools */ |
|
|
|
/* Complex stats also include expensive memory debugging tools */ |
|
|
|
taia_uint( &t, 0 ); io_timeout( sock, t ); |
|
|
|
taia_uint(&t, 0); |
|
|
|
|
|
|
|
io_timeout(sock, t); |
|
|
|
stats_deliver(sock, mode); |
|
|
|
stats_deliver(sock, mode); |
|
|
|
return ws->reply_size = -2; |
|
|
|
return ws->reply_size = -2; |
|
|
|
} |
|
|
|
} |
|
|
@ -297,7 +329,10 @@ static const ot_keywords keywords_format[] = |
|
|
|
#ifdef WANT_MODEST_FULLSCRAPES |
|
|
|
#ifdef WANT_MODEST_FULLSCRAPES |
|
|
|
static pthread_mutex_t g_modest_fullscrape_mutex = PTHREAD_MUTEX_INITIALIZER; |
|
|
|
static pthread_mutex_t g_modest_fullscrape_mutex = PTHREAD_MUTEX_INITIALIZER; |
|
|
|
static ot_vector g_modest_fullscrape_timeouts; |
|
|
|
static ot_vector g_modest_fullscrape_timeouts; |
|
|
|
typedef struct { ot_ip6 ip; ot_time last_fullscrape; } ot_scrape_log; |
|
|
|
typedef struct { |
|
|
|
|
|
|
|
ot_ip6 ip; |
|
|
|
|
|
|
|
ot_time last_fullscrape; |
|
|
|
|
|
|
|
} ot_scrape_log; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef WANT_FULLSCRAPE |
|
|
|
#ifdef WANT_FULLSCRAPE |
|
|
@ -348,7 +383,8 @@ static ssize_t http_handle_fullscrape( const int64 sock, struct ot_workstruct *w |
|
|
|
/* Pass this task to the worker thread */ |
|
|
|
/* Pass this task to the worker thread */ |
|
|
|
cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED; |
|
|
|
cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED; |
|
|
|
/* Clients waiting for us should not easily timeout */ |
|
|
|
/* Clients waiting for us should not easily timeout */ |
|
|
|
taia_uint( &t, 0 ); io_timeout( sock, t ); |
|
|
|
taia_uint(&t, 0); |
|
|
|
|
|
|
|
io_timeout(sock, t); |
|
|
|
fullscrape_deliver(sock, TASK_FULLSCRAPE | format); |
|
|
|
fullscrape_deliver(sock, TASK_FULLSCRAPE | format); |
|
|
|
io_dontwantread(sock); |
|
|
|
io_dontwantread(sock); |
|
|
|
return ws->reply_size = -2; |
|
|
|
return ws->reply_size = -2; |
|
|
@ -363,16 +399,23 @@ static ssize_t http_handle_scrape( const int64 sock, struct ot_workstruct *ws, c |
|
|
|
|
|
|
|
|
|
|
|
/* This is to hack around stupid clients that send "scrape ?info_hash" */ |
|
|
|
/* This is to hack around stupid clients that send "scrape ?info_hash" */ |
|
|
|
if (read_ptr[-1] != '?') { |
|
|
|
if (read_ptr[-1] != '?') { |
|
|
|
while( ( *read_ptr != '?' ) && ( *read_ptr != '\n' ) ) ++read_ptr; |
|
|
|
while ((*read_ptr != '?') && (*read_ptr != '\n')) |
|
|
|
if( *read_ptr == '\n' ) HTTPERROR_400_PARAM; |
|
|
|
++read_ptr; |
|
|
|
|
|
|
|
if (*read_ptr == '\n') |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
++read_ptr; |
|
|
|
++read_ptr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
while (scanon) { |
|
|
|
while (scanon) { |
|
|
|
switch (scan_find_keywords(keywords_scrape, &read_ptr, SCAN_SEARCHPATH_PARAM)) { |
|
|
|
switch (scan_find_keywords(keywords_scrape, &read_ptr, SCAN_SEARCHPATH_PARAM)) { |
|
|
|
case -2: scanon = 0; break; /* TERMINATOR */ |
|
|
|
case -2: |
|
|
|
default: HTTPERROR_400_PARAM; /* PARSE ERROR */ |
|
|
|
scanon = 0; |
|
|
|
case -3: scan_urlencoded_skipvalue( &read_ptr ); break; |
|
|
|
break; /* TERMINATOR */ |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; /* PARSE ERROR */ |
|
|
|
|
|
|
|
case -3: |
|
|
|
|
|
|
|
scan_urlencoded_skipvalue(&read_ptr); |
|
|
|
|
|
|
|
break; |
|
|
|
case 1: /* matched "info_hash" */ |
|
|
|
case 1: /* matched "info_hash" */ |
|
|
|
/* ignore this, when we have less than 20 bytes */ |
|
|
|
/* ignore this, when we have less than 20 bytes */ |
|
|
|
if (scan_urlencoded_query(&read_ptr, (char *)(multiscrape_buf + numwant++), SCAN_SEARCHPATH_VALUE) != (ssize_t)sizeof(ot_hash)) |
|
|
|
if (scan_urlencoded_query(&read_ptr, (char *)(multiscrape_buf + numwant++), SCAN_SEARCHPATH_VALUE) != (ssize_t)sizeof(ot_hash)) |
|
|
@ -382,7 +425,8 @@ static ssize_t http_handle_scrape( const int64 sock, struct ot_workstruct *ws, c |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* No info_hash found? Inform user */ |
|
|
|
/* No info_hash found? Inform user */ |
|
|
|
if( !numwant ) HTTPERROR_400_PARAM; |
|
|
|
if (!numwant) |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
|
|
|
|
|
|
|
|
/* Limit number of hashes to process */ |
|
|
|
/* Limit number of hashes to process */ |
|
|
|
if (numwant > OT_MAXMULTISCRAPE_COUNT) |
|
|
|
if (numwant > OT_MAXMULTISCRAPE_COUNT) |
|
|
@ -403,10 +447,13 @@ static char* http_header( char *data, size_t byte_count, char *header ) { |
|
|
|
size_t i; |
|
|
|
size_t i; |
|
|
|
long sl = strlen(header); |
|
|
|
long sl = strlen(header); |
|
|
|
for (i = 0; i + sl + 2 < byte_count; ++i) { |
|
|
|
for (i = 0; i + sl + 2 < byte_count; ++i) { |
|
|
|
if( data[i] != '\n' || data[ i + sl + 1] != ':' ) continue; |
|
|
|
if (data[i] != '\n' || data[i + sl + 1] != ':') |
|
|
|
if( !case_equalb( data + i + 1, sl, header ) ) continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
if (!case_equalb(data + i + 1, sl, header)) |
|
|
|
|
|
|
|
continue; |
|
|
|
data += i + sl + 2; |
|
|
|
data += i + sl + 2; |
|
|
|
while( *data == ' ' || *data == '\t' ) ++data; |
|
|
|
while (*data == ' ' || *data == '\t') |
|
|
|
|
|
|
|
++data; |
|
|
|
return data; |
|
|
|
return data; |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
@ -420,8 +467,7 @@ static ot_keywords keywords_announce[] = { { "port", 1 }, { "left", 2 }, { "even |
|
|
|
#ifdef WANT_FULLLOG_NETWORKS |
|
|
|
#ifdef WANT_FULLLOG_NETWORKS |
|
|
|
{"lognet", 8}, |
|
|
|
{"lognet", 8}, |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
{ "peer_id", 9 }, |
|
|
|
{"peer_id", 9}, {NULL, -3}}; |
|
|
|
{ NULL, -3 } }; |
|
|
|
|
|
|
|
static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; |
|
|
|
static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; |
|
|
|
static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { |
|
|
|
static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { |
|
|
|
int numwant, tmp, scanon; |
|
|
|
int numwant, tmp, scanon; |
|
|
@ -432,8 +478,10 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, |
|
|
|
|
|
|
|
|
|
|
|
/* This is to hack around stupid clients that send "announce ?info_hash" */ |
|
|
|
/* This is to hack around stupid clients that send "announce ?info_hash" */ |
|
|
|
if (read_ptr[-1] != '?') { |
|
|
|
if (read_ptr[-1] != '?') { |
|
|
|
while( ( *read_ptr != '?' ) && ( *read_ptr != '\n' ) ) ++read_ptr; |
|
|
|
while ((*read_ptr != '?') && (*read_ptr != '\n')) |
|
|
|
if( *read_ptr == '\n' ) HTTPERROR_400_PARAM; |
|
|
|
++read_ptr; |
|
|
|
|
|
|
|
if (*read_ptr == '\n') |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
++read_ptr; |
|
|
|
++read_ptr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -459,22 +507,33 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, |
|
|
|
|
|
|
|
|
|
|
|
while (scanon) { |
|
|
|
while (scanon) { |
|
|
|
switch (scan_find_keywords(keywords_announce, &read_ptr, SCAN_SEARCHPATH_PARAM)) { |
|
|
|
switch (scan_find_keywords(keywords_announce, &read_ptr, SCAN_SEARCHPATH_PARAM)) { |
|
|
|
case -2: scanon = 0; break; /* TERMINATOR */ |
|
|
|
case -2: |
|
|
|
case -1: HTTPERROR_400_PARAM; /* PARSE ERROR */ |
|
|
|
scanon = 0; |
|
|
|
case -3: scan_urlencoded_skipvalue( &read_ptr ); break; |
|
|
|
break; /* TERMINATOR */ |
|
|
|
|
|
|
|
case -1: |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; /* PARSE ERROR */ |
|
|
|
|
|
|
|
case -3: |
|
|
|
|
|
|
|
scan_urlencoded_skipvalue(&read_ptr); |
|
|
|
|
|
|
|
break; |
|
|
|
case 1: /* matched "port" */ |
|
|
|
case 1: /* matched "port" */ |
|
|
|
len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE); |
|
|
|
len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE); |
|
|
|
if( ( len <= 0 ) || scan_fixed_int( write_ptr, len, &tmp ) || ( tmp > 0xffff ) ) HTTPERROR_400_PARAM; |
|
|
|
if ((len <= 0) || scan_fixed_int(write_ptr, len, &tmp) || (tmp > 0xffff)) |
|
|
|
port = htons( tmp ); OT_SETPORT( &ws->peer, &port ); |
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
|
|
|
|
port = htons(tmp); |
|
|
|
|
|
|
|
OT_SETPORT(&ws->peer, &port); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 2: /* matched "left" */ |
|
|
|
case 2: /* matched "left" */ |
|
|
|
if( ( len = scan_urlencoded_query( &read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE ) ) <= 0 ) HTTPERROR_400_PARAM; |
|
|
|
if ((len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE)) <= 0) |
|
|
|
if( scan_fixed_int( write_ptr, len, &tmp ) ) tmp = 0; |
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
if( !tmp ) OT_PEERFLAG( &ws->peer ) |= PEER_FLAG_SEEDING; |
|
|
|
if (scan_fixed_int(write_ptr, len, &tmp)) |
|
|
|
|
|
|
|
tmp = 0; |
|
|
|
|
|
|
|
if (!tmp) |
|
|
|
|
|
|
|
OT_PEERFLAG(&ws->peer) |= PEER_FLAG_SEEDING; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 3: /* matched "event" */ |
|
|
|
case 3: /* matched "event" */ |
|
|
|
switch (scan_find_keywords(keywords_announce_event, &read_ptr, SCAN_SEARCHPATH_VALUE)) { |
|
|
|
switch (scan_find_keywords(keywords_announce_event, &read_ptr, SCAN_SEARCHPATH_VALUE)) { |
|
|
|
case -1: HTTPERROR_400_PARAM; |
|
|
|
case -1: |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
case 1: /* matched "completed" */ |
|
|
|
case 1: /* matched "completed" */ |
|
|
|
OT_PEERFLAG(&ws->peer) |= PEER_FLAG_COMPLETED; |
|
|
|
OT_PEERFLAG(&ws->peer) |= PEER_FLAG_COMPLETED; |
|
|
|
break; |
|
|
|
break; |
|
|
@ -487,19 +546,26 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 4: /* matched "numwant" */ |
|
|
|
case 4: /* matched "numwant" */ |
|
|
|
len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE); |
|
|
|
len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE); |
|
|
|
if( ( len <= 0 ) || scan_fixed_int( write_ptr, len, &numwant ) ) HTTPERROR_400_PARAM; |
|
|
|
if ((len <= 0) || scan_fixed_int(write_ptr, len, &numwant)) |
|
|
|
if( numwant < 0 ) numwant = 50; |
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
if( numwant > 200 ) numwant = 200; |
|
|
|
if (numwant < 0) |
|
|
|
|
|
|
|
numwant = 50; |
|
|
|
|
|
|
|
if (numwant > 200) |
|
|
|
|
|
|
|
numwant = 200; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 5: /* matched "compact" */ |
|
|
|
case 5: /* matched "compact" */ |
|
|
|
len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE); |
|
|
|
len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE); |
|
|
|
if( ( len <= 0 ) || scan_fixed_int( write_ptr, len, &tmp ) ) HTTPERROR_400_PARAM; |
|
|
|
if ((len <= 0) || scan_fixed_int(write_ptr, len, &tmp)) |
|
|
|
if( !tmp ) HTTPERROR_400_COMPACT; |
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
|
|
|
|
if (!tmp) |
|
|
|
|
|
|
|
HTTPERROR_400_COMPACT; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 6: /* matched "info_hash" */ |
|
|
|
case 6: /* matched "info_hash" */ |
|
|
|
if( ws->hash ) HTTPERROR_400_DOUBLEHASH; |
|
|
|
if (ws->hash) |
|
|
|
|
|
|
|
HTTPERROR_400_DOUBLEHASH; |
|
|
|
/* ignore this, when we have less than 20 bytes */ |
|
|
|
/* ignore this, when we have less than 20 bytes */ |
|
|
|
if( scan_urlencoded_query( &read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE ) != 20 ) HTTPERROR_400_PARAM; |
|
|
|
if (scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE) != 20) |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
ws->hash = (ot_hash *)write_ptr; |
|
|
|
ws->hash = (ot_hash *)write_ptr; |
|
|
|
break; |
|
|
|
break; |
|
|
|
#ifdef WANT_IP_FROM_QUERY_STRING |
|
|
|
#ifdef WANT_IP_FROM_QUERY_STRING |
|
|
@ -508,10 +574,10 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, |
|
|
|
char *tmp_buf1 = ws->reply, *tmp_buf2 = ws->reply + 16; |
|
|
|
char *tmp_buf1 = ws->reply, *tmp_buf2 = ws->reply + 16; |
|
|
|
len = scan_urlencoded_query(&read_ptr, tmp_buf2, SCAN_SEARCHPATH_VALUE); |
|
|
|
len = scan_urlencoded_query(&read_ptr, tmp_buf2, SCAN_SEARCHPATH_VALUE); |
|
|
|
tmp_buf2[len] = 0; |
|
|
|
tmp_buf2[len] = 0; |
|
|
|
if( ( len <= 0 ) || !scan_ip6( tmp_buf2, tmp_buf1 ) ) HTTPERROR_400_PARAM; |
|
|
|
if ((len <= 0) || !scan_ip6(tmp_buf2, tmp_buf1)) |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
OT_SETIP(&ws->peer, tmp_buf1); |
|
|
|
OT_SETIP(&ws->peer, tmp_buf1); |
|
|
|
} |
|
|
|
} break; |
|
|
|
break; |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#ifdef WANT_FULLLOG_NETWORKS |
|
|
|
#ifdef WANT_FULLLOG_NETWORKS |
|
|
|
case 8: /* matched "lognet" */ |
|
|
|
case 8: /* matched "lognet" */ |
|
|
@ -523,18 +589,21 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, |
|
|
|
|
|
|
|
|
|
|
|
len = scan_urlencoded_query(&read_ptr, tmp_buf, SCAN_SEARCHPATH_VALUE); |
|
|
|
len = scan_urlencoded_query(&read_ptr, tmp_buf, SCAN_SEARCHPATH_VALUE); |
|
|
|
tmp_buf[len] = 0; |
|
|
|
tmp_buf[len] = 0; |
|
|
|
if( len <= 0 ) HTTPERROR_400_PARAM; |
|
|
|
if (len <= 0) |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
if (*tmp_buf == '-') { |
|
|
|
if (*tmp_buf == '-') { |
|
|
|
loglist_reset(); |
|
|
|
loglist_reset(); |
|
|
|
return ws->reply_size = sprintf(ws->reply, "Successfully removed.\n"); |
|
|
|
return ws->reply_size = sprintf(ws->reply, "Successfully removed.\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
parsed = scan_ip6(tmp_buf, net.address); |
|
|
|
parsed = scan_ip6(tmp_buf, net.address); |
|
|
|
if( !parsed ) HTTPERROR_400_PARAM; |
|
|
|
if (!parsed) |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
if (tmp_buf[parsed++] != '/') |
|
|
|
if (tmp_buf[parsed++] != '/') |
|
|
|
bits = 128; |
|
|
|
bits = 128; |
|
|
|
else { |
|
|
|
else { |
|
|
|
parsed = scan_short(tmp_buf + parsed, &bits); |
|
|
|
parsed = scan_short(tmp_buf + parsed, &bits); |
|
|
|
if( !parsed ) HTTPERROR_400_PARAM; |
|
|
|
if (!parsed) |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
if (ip6_isv4mapped(net.address)) |
|
|
|
if (ip6_isv4mapped(net.address)) |
|
|
|
bits += 96; |
|
|
|
bits += 96; |
|
|
|
} |
|
|
|
} |
|
|
@ -542,12 +611,12 @@ static ssize_t http_handle_announce( const int64 sock, struct ot_workstruct *ws, |
|
|
|
loglist_add_network(&net); |
|
|
|
loglist_add_network(&net); |
|
|
|
return ws->reply_size = sprintf(ws->reply, "Successfully added.\n"); |
|
|
|
return ws->reply_size = sprintf(ws->reply, "Successfully added.\n"); |
|
|
|
//}
|
|
|
|
//}
|
|
|
|
} |
|
|
|
} break; |
|
|
|
break; |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
case 9: /* matched "peer_id" */ |
|
|
|
case 9: /* matched "peer_id" */ |
|
|
|
/* ignore this, when we have less than 20 bytes */ |
|
|
|
/* ignore this, when we have less than 20 bytes */ |
|
|
|
if( scan_urlencoded_query( &read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE ) != 20 ) HTTPERROR_400_PARAM; |
|
|
|
if (scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE) != 20) |
|
|
|
|
|
|
|
HTTPERROR_400_PARAM; |
|
|
|
ws->peer_id = write_ptr; |
|
|
|
ws->peer_id = write_ptr; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -614,10 +683,12 @@ ssize_t http_handle_request( const int64 sock, struct ot_workstruct *ws ) { |
|
|
|
ws->reply = ws->outbuf + SUCCESS_HTTP_HEADER_LENGTH; |
|
|
|
ws->reply = ws->outbuf + SUCCESS_HTTP_HEADER_LENGTH; |
|
|
|
|
|
|
|
|
|
|
|
/* This one implicitely tests strlen < 5, too -- remember, it is \n terminated */ |
|
|
|
/* This one implicitely tests strlen < 5, too -- remember, it is \n terminated */ |
|
|
|
if( memcmp( read_ptr, "GET /", 5) ) HTTPERROR_400; |
|
|
|
if (memcmp(read_ptr, "GET /", 5)) |
|
|
|
|
|
|
|
HTTPERROR_400; |
|
|
|
|
|
|
|
|
|
|
|
/* Skip leading '/' */ |
|
|
|
/* Skip leading '/' */ |
|
|
|
for( read_ptr+=4; *read_ptr == '/'; ++read_ptr); |
|
|
|
for (read_ptr += 4; *read_ptr == '/'; ++read_ptr) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
/* Try to parse the request.
|
|
|
|
/* Try to parse the request.
|
|
|
|
In reality we abandoned requiring the url to be correct. This now |
|
|
|
In reality we abandoned requiring the url to be correct. This now |
|
|
@ -626,8 +697,10 @@ ssize_t http_handle_request( const int64 sock, struct ot_workstruct *ws ) { |
|
|
|
len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_PATH); |
|
|
|
len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_PATH); |
|
|
|
|
|
|
|
|
|
|
|
/* If parsing returned an error, leave with not found */ |
|
|
|
/* If parsing returned an error, leave with not found */ |
|
|
|
if( g_redirecturl && ( len == -2 ) ) HTTPERROR_302; |
|
|
|
if (g_redirecturl && (len == -2)) |
|
|
|
if( len <= 0 ) HTTPERROR_404; |
|
|
|
HTTPERROR_302; |
|
|
|
|
|
|
|
if (len <= 0) |
|
|
|
|
|
|
|
HTTPERROR_404; |
|
|
|
|
|
|
|
|
|
|
|
/* This is the hardcore match for announce*/ |
|
|
|
/* This is the hardcore match for announce*/ |
|
|
|
if ((*write_ptr == 'a') || (*write_ptr == '?')) |
|
|
|
if ((*write_ptr == 'a') || (*write_ptr == '?')) |
|
|
@ -649,13 +722,16 @@ ssize_t http_handle_request( const int64 sock, struct ot_workstruct *ws ) { |
|
|
|
ws->keep_alive = 0; |
|
|
|
ws->keep_alive = 0; |
|
|
|
#ifdef WANT_KEEPALIVE |
|
|
|
#ifdef WANT_KEEPALIVE |
|
|
|
read_ptr = http_header(ws->request, ws->header_size, "connection"); |
|
|
|
read_ptr = http_header(ws->request, ws->header_size, "connection"); |
|
|
|
if( read_ptr && ( *read_ptr == 'K' || *read_ptr == 'k' ) ) ws->keep_alive = 1; |
|
|
|
if (read_ptr && (*read_ptr == 'K' || *read_ptr == 'k')) |
|
|
|
|
|
|
|
ws->keep_alive = 1; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/* If routines handled sending themselves, just return */ |
|
|
|
/* If routines handled sending themselves, just return */ |
|
|
|
if( ws->reply_size == -2 ) return 0; |
|
|
|
if (ws->reply_size == -2) |
|
|
|
|
|
|
|
return 0; |
|
|
|
/* If routine failed, let http error take over */ |
|
|
|
/* If routine failed, let http error take over */ |
|
|
|
if( ws->reply_size <= 0 ) HTTPERROR_500; |
|
|
|
if (ws->reply_size <= 0) |
|
|
|
|
|
|
|
HTTPERROR_500; |
|
|
|
|
|
|
|
|
|
|
|
/* This one is rather ugly, so I take you step by step through it.
|
|
|
|
/* This one is rather ugly, so I take you step by step through it.
|
|
|
|
|
|
|
|
|
|
|
|