diff options
Diffstat (limited to 'opentracker.c')
| -rw-r--r-- | opentracker.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/opentracker.c b/opentracker.c index 35482e4..1bd8514 100644 --- a/opentracker.c +++ b/opentracker.c | |||
| @@ -19,6 +19,8 @@ | |||
| 19 | #include "trackerlogic.h" | 19 | #include "trackerlogic.h" |
| 20 | #include "scan_urlencoded_query.h" | 20 | #include "scan_urlencoded_query.h" |
| 21 | 21 | ||
| 22 | static unsigned int overall_connections = 0; | ||
| 23 | |||
| 22 | static void carp(const char* routine) { | 24 | static void carp(const char* routine) { |
| 23 | buffer_puts(buffer_2,routine); | 25 | buffer_puts(buffer_2,routine); |
| 24 | buffer_puts(buffer_2,": "); | 26 | buffer_puts(buffer_2,": "); |
| @@ -279,7 +281,13 @@ e500: | |||
| 279 | } | 281 | } |
| 280 | } | 282 | } |
| 281 | break; | 283 | break; |
| 282 | default: /* neither scrape nor announce */ | 284 | case 11: |
| 285 | if( byte_diff(data,11,",mrtg_scrape")) | ||
| 286 | goto e404; | ||
| 287 | reply = malloc( 128 ); | ||
| 288 | reply_size = sprintf( reply, "%d\n%d\nUp: 23 years.\nPertuned by german engineers.", overall_connections, overall_connections ); | ||
| 289 | break; | ||
| 290 | default: /* neither *scrape nor announce */ | ||
| 283 | e404: | 291 | e404: |
| 284 | httperror(h,"404 Not Found","No such file or directory."); | 292 | httperror(h,"404 Not Found","No such file or directory."); |
| 285 | goto bailout; | 293 | goto bailout; |
| @@ -293,7 +301,7 @@ e404: | |||
| 293 | c+=fmt_httpdate(c,time(0)); | 301 | c+=fmt_httpdate(c,time(0)); |
| 294 | c+=fmt_str(c,"\r\nConnection: close\r\n\r\n"); | 302 | c+=fmt_str(c,"\r\nConnection: close\r\n\r\n"); |
| 295 | iob_addbuf(&h->iob,h->hdrbuf,c - h->hdrbuf); | 303 | iob_addbuf(&h->iob,h->hdrbuf,c - h->hdrbuf); |
| 296 | if( reply && reply_size ) iob_addbuf(&h->iob,reply, reply_size ); | 304 | if( reply && reply_size ) iob_addbuf_free(&h->iob,reply, reply_size ); |
| 297 | 305 | ||
| 298 | bailout: | 306 | bailout: |
| 299 | io_dontwantread(s); | 307 | io_dontwantread(s); |
| @@ -351,6 +359,7 @@ int main() | |||
| 351 | byte_zero(h,sizeof(struct http_data)); | 359 | byte_zero(h,sizeof(struct http_data)); |
| 352 | h->ip=ip; | 360 | h->ip=ip; |
| 353 | io_setcookie(n,h); | 361 | io_setcookie(n,h); |
| 362 | ++overall_connections; | ||
| 354 | } else | 363 | } else |
| 355 | io_close(n); | 364 | io_close(n); |
| 356 | } else | 365 | } else |
