diff options
author | erdgeist <> | 2007-01-17 11:51:55 +0000 |
---|---|---|
committer | erdgeist <> | 2007-01-17 11:51:55 +0000 |
commit | 005ff4e2313da86eb01c939c1859b92608e181c7 (patch) | |
tree | e1f4c341fdc5d255b42a50d66d3096ba08aad71b /opentracker.c | |
parent | 4eefe49307440649133b93ba9a1afeb2b7e2c862 (diff) |
Simple top5 by peers/seeders table
Diffstat (limited to 'opentracker.c')
-rw-r--r-- | opentracker.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/opentracker.c b/opentracker.c index a2f0db2..5fa6548 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -106,7 +106,7 @@ void httpresponse(int64 s,struct http_data* h) | |||
106 | ot_peer peer; | 106 | ot_peer peer; |
107 | ot_torrent *torrent; | 107 | ot_torrent *torrent; |
108 | ot_hash *hash = NULL; | 108 | ot_hash *hash = NULL; |
109 | int numwant, tmp, scanon; | 109 | int numwant, tmp, scanon, mode; |
110 | unsigned short port = htons(6881); | 110 | unsigned short port = htons(6881); |
111 | size_t reply_size = 0; | 111 | size_t reply_size = 0; |
112 | 112 | ||
@@ -130,8 +130,37 @@ e400: | |||
130 | case 5: /* scrape ? */ | 130 | case 5: /* scrape ? */ |
131 | if (byte_diff(data,5,"stats")) | 131 | if (byte_diff(data,5,"stats")) |
132 | goto e404; | 132 | goto e404; |
133 | scanon = 1; | ||
134 | mode = STATS_MRTG; | ||
135 | |||
136 | while( scanon ) { | ||
137 | switch( scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_PARAM ) ) { | ||
138 | case -2: /* terminator */ | ||
139 | scanon = 0; | ||
140 | break; | ||
141 | case -1: /* error */ | ||
142 | goto e404; | ||
143 | case 4: | ||
144 | if(byte_diff(data,4,"mode")) { | ||
145 | scan_urlencoded_query( &c, NULL, SCAN_SEARCHPATH_VALUE ); | ||
146 | continue; | ||
147 | } | ||
148 | size_t len = scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_VALUE ); | ||
149 | if( len <= 0 ) goto e400_param; | ||
150 | if( !byte_diff(data,4,"mrtg")) | ||
151 | mode = STATS_MRTG; | ||
152 | else if( !byte_diff(data,4,"top5")) | ||
153 | mode = STATS_TOP5; | ||
154 | else | ||
155 | goto e400_param; | ||
156 | default: | ||
157 | scan_urlencoded_query( &c, NULL, SCAN_SEARCHPATH_VALUE ); | ||
158 | break; | ||
159 | } | ||
160 | } | ||
161 | |||
133 | /* Enough for http header + whole scrape string */ | 162 | /* Enough for http header + whole scrape string */ |
134 | if( ( reply_size = return_stats_for_tracker( SUCCESS_HTTP_HEADER_LENGTH + static_reply ) ) <= 0 ) | 163 | if( ( reply_size = return_stats_for_tracker( SUCCESS_HTTP_HEADER_LENGTH + static_reply, mode ) ) <= 0 ) |
135 | goto e500; | 164 | goto e500; |
136 | break; | 165 | break; |
137 | case 6: /* scrape ? */ | 166 | case 6: /* scrape ? */ |