diff options
author | erdgeist <> | 2007-12-05 01:40:24 +0000 |
---|---|---|
committer | erdgeist <> | 2007-12-05 01:40:24 +0000 |
commit | bee364a6f33694b4d58f29f0de5ad630d392a031 (patch) | |
tree | fb5c9355bb0e7bbccc3b8288dfadfdbd275e7bc0 /opentracker.c | |
parent | 31d876d53dfdafc4370b7c23febbb6978b271a77 (diff) |
/ can now be redirected to any URL
Diffstat (limited to 'opentracker.c')
-rw-r--r-- | opentracker.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/opentracker.c b/opentracker.c index 3adcfd0..6867946 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -35,6 +35,7 @@ | |||
35 | 35 | ||
36 | /* Globals */ | 36 | /* Globals */ |
37 | time_t g_now; | 37 | time_t g_now; |
38 | char * g_redirecturl = NULL; | ||
38 | 39 | ||
39 | /* To always have space for error messages ;) */ | 40 | /* To always have space for error messages ;) */ |
40 | static char static_inbuf[8192]; | 41 | static char static_inbuf[8192]; |
@@ -60,7 +61,7 @@ static void signal_handler( int s ) { | |||
60 | } | 61 | } |
61 | 62 | ||
62 | static void usage( char *name ) { | 63 | static void usage( char *name ) { |
63 | fprintf( stderr, "Usage: %s [-i ip] [-p port] [-P port] [-d dir] [-A ip]" | 64 | fprintf( stderr, "Usage: %s [-i ip] [-p port] [-P port] [-r redirect] [-d dir] [-A ip]" |
64 | #ifdef WANT_BLACKLISTING | 65 | #ifdef WANT_BLACKLISTING |
65 | " [-b blacklistfile]" | 66 | " [-b blacklistfile]" |
66 | #elif defined ( WANT_CLOSED_TRACKER ) | 67 | #elif defined ( WANT_CLOSED_TRACKER ) |
@@ -76,6 +77,7 @@ static void help( char *name ) { | |||
76 | HELPLINE("-i ip","specify ip to bind to (default: *, you may specify more than one)"); | 77 | HELPLINE("-i ip","specify ip to bind to (default: *, you may specify more than one)"); |
77 | HELPLINE("-p port","specify tcp port to bind to (default: 6969, you may specify more than one)"); | 78 | HELPLINE("-p port","specify tcp port to bind to (default: 6969, you may specify more than one)"); |
78 | HELPLINE("-P port","specify udp port to bind to (default: 6969, you may specify more than one)"); | 79 | HELPLINE("-P port","specify udp port to bind to (default: 6969, you may specify more than one)"); |
80 | HELPLINE("-r redirecturl","specify url where / should be redirected to (default none)"); | ||
79 | HELPLINE("-d dir","specify directory to try to chroot to (default: \".\")"); | 81 | HELPLINE("-d dir","specify directory to try to chroot to (default: \".\")"); |
80 | HELPLINE("-A ip","bless an ip address as admin address (e.g. to allow syncs from this address)"); | 82 | HELPLINE("-A ip","bless an ip address as admin address (e.g. to allow syncs from this address)"); |
81 | #ifdef WANT_BLACKLISTING | 83 | #ifdef WANT_BLACKLISTING |
@@ -124,10 +126,10 @@ static ssize_t handle_read( const int64 clientsocket ) { | |||
124 | array_catb( &h->request, static_inbuf, l ); | 126 | array_catb( &h->request, static_inbuf, l ); |
125 | 127 | ||
126 | if( array_failed( &h->request ) ) | 128 | if( array_failed( &h->request ) ) |
127 | return http_issue_error( clientsocket, "500 Server Error", "Request too long."); | 129 | return http_issue_error( clientsocket, CODE_HTTPERROR_500 ); |
128 | 130 | ||
129 | if( ( array_bytes( &h->request ) > 8192 ) && !accesslist_isblessed( (char*)&h->ip, OT_PERMISSION_MAY_SYNC ) ) | 131 | if( ( array_bytes( &h->request ) > 8192 ) && !accesslist_isblessed( (char*)&h->ip, OT_PERMISSION_MAY_SYNC ) ) |
130 | return http_issue_error( clientsocket, "500 request too long", "You sent too much headers"); | 132 | return http_issue_error( clientsocket, CODE_HTTPERROR_500 ); |
131 | 133 | ||
132 | if( memchr( array_start( &h->request ), '\n', array_bytes( &h->request ) ) ) | 134 | if( memchr( array_start( &h->request ), '\n', array_bytes( &h->request ) ) ) |
133 | return http_handle_request( clientsocket, array_start( &h->request ), array_bytes( &h->request ) ); | 135 | return http_handle_request( clientsocket, array_start( &h->request ), array_bytes( &h->request ) ); |
@@ -248,7 +250,7 @@ int main( int argc, char **argv ) { | |||
248 | #endif | 250 | #endif |
249 | 251 | ||
250 | while( scanon ) { | 252 | while( scanon ) { |
251 | switch( getopt( argc, argv, ":i:p:A:P:d:" | 253 | switch( getopt( argc, argv, ":i:p:A:P:d:r:" |
252 | #ifdef WANT_BLACKLISTING | 254 | #ifdef WANT_BLACKLISTING |
253 | "b:" | 255 | "b:" |
254 | #elif defined( WANT_CLOSED_TRACKER ) | 256 | #elif defined( WANT_CLOSED_TRACKER ) |
@@ -265,6 +267,7 @@ int main( int argc, char **argv ) { | |||
265 | case 'p': ot_try_bind( serverip, (uint16)atol( optarg ), 1 ); bound++; break; | 267 | case 'p': ot_try_bind( serverip, (uint16)atol( optarg ), 1 ); bound++; break; |
266 | case 'P': ot_try_bind( serverip, (uint16)atol( optarg ), 0 ); bound++; break; | 268 | case 'P': ot_try_bind( serverip, (uint16)atol( optarg ), 0 ); bound++; break; |
267 | case 'd': serverdir = optarg; break; | 269 | case 'd': serverdir = optarg; break; |
270 | case 'r': g_redirecturl = optarg; break; | ||
268 | case 'A': | 271 | case 'A': |
269 | scan_ip4( optarg, tmpip ); | 272 | scan_ip4( optarg, tmpip ); |
270 | accesslist_blessip( tmpip, 0xffff ); /* Allow everything for now */ | 273 | accesslist_blessip( tmpip, 0xffff ); /* Allow everything for now */ |