summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opentracker.c44
-rw-r--r--trackerlogic.c1
-rw-r--r--trackerlogic.h3
3 files changed, 42 insertions, 6 deletions
diff --git a/opentracker.c b/opentracker.c
index b992117..b7c1f6a 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -342,10 +342,37 @@ void graceful( int s ) {
342void usage( char *name ) { 342void usage( char *name ) {
343 fprintf( stderr, "Usage: %s [-i serverip] [-p serverport] [-d serverdirectory]" 343 fprintf( stderr, "Usage: %s [-i serverip] [-p serverport] [-d serverdirectory]"
344#ifdef WANT_CLOSED_TRACKER 344#ifdef WANT_CLOSED_TRACKER
345 " [-o|c]" 345 " [-oc]"
346#endif
347#ifdef WANT_BLACKLIST
348 " [-bB]"
346#endif 349#endif
347 "\n", name ); 350 "\n", name );
348 exit(1); 351}
352
353void help( char *name ) {
354 usage( name );
355 fprintf( stderr, "\t-i serverip\tspecify ip to bind to (default: *)\n"
356 "\t-p serverport\tspecify port to bind to (default: 6969)\n"
357 "\t-d serverdir\tspecify directory containing white- or black listed torrent info_hashes (default: \".\")\n"
358#ifdef WANT_CLOSED_TRACKER
359 "\t-o\t\tmake tracker an open tracker, e.g. do not check for white list (default: off)\n"
360 "\t-c\t\tmake tracker a closed tracker, e.g. check each announced torrent against white list (default: on)\n"
361#endif
362#ifdef WANT_BLACKLIST
363 "\t-b\t\tmake tracker check its black list, e.g. check each announced torrent against black list (default: on)\n"
364 "\t-B\t\tmake tracker check its black list, e.g. check each announced torrent against black list (default: off)\n"
365#endif
366#ifdef WANT_CLOSED_TRACKER
367 "\n* To white list a torrent, touch a file inside serverdir with info_hash hex string.\n"
368#endif
369#ifdef WANT_BLACKLIST
370#ifndef WANT_CLOSED_TRACKER
371 "\n"
372#endif
373 "* To white list a torrent, touch a file inside serverdir with info_hash hex string, preprended by '-'.\n"
374#endif
375);
349} 376}
350 377
351int main( int argc, char **argv ) { 378int main( int argc, char **argv ) {
@@ -356,17 +383,22 @@ int main( int argc, char **argv ) {
356 uint16 port = 6969; 383 uint16 port = 6969;
357 384
358 while( 1 ) { 385 while( 1 ) {
359 switch( getopt(argc,argv,":i:p:d:") ) { 386 switch( getopt(argc,argv,":i:p:d:ocbBh") ) {
360 case -1: goto allparsed; 387 case -1: goto allparsed;
361 case 'i': serverip = optarg; break; 388 case 'i': serverip = optarg; break;
362 case 'p': port = (uint16)atol( optarg ); break; 389 case 'p': port = (uint16)atol( optarg ); break;
363 case 'd': serverdir = optarg; break; 390 case 'd': serverdir = optarg; break;
391 case 'h': help( argv[0]); exit(0);
364#ifdef WANT_CLOSED_TRACKER 392#ifdef WANT_CLOSED_TRACKER
365 case 'o': g_closedtracker = 0; 393 case 'o': g_closedtracker = 0; break;
366 case 'c': g_closedtracker = 1; 394 case 'c': g_closedtracker = 1; break;
395#endif
396#ifdef WANT_BLACKLIST
397 case 'b': g_check_blacklist = 1; break;
398 case 'B': g_check_blacklist = 0; break;
367#endif 399#endif
368 default: 400 default:
369 case '?': usage( argv[0] ); 401 case '?': usage( argv[0] ); exit(1);
370 } 402 }
371 } 403 }
372 404
diff --git a/trackerlogic.c b/trackerlogic.c
index 5a74e2c..620e056 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -32,6 +32,7 @@ static ot_torrent* const OT_TORRENT_NOT_ON_WHITELIST = (ot_torrent*)1;
32#endif 32#endif
33 33
34#ifdef WANT_BLACKLIST 34#ifdef WANT_BLACKLIST
35int g_check_blacklist = 1;
35static ot_torrent* const OT_TORRENT_ON_BLACKLIST = (ot_torrent*)2; 36static ot_torrent* const OT_TORRENT_ON_BLACKLIST = (ot_torrent*)2;
36#endif 37#endif
37 38
diff --git a/trackerlogic.h b/trackerlogic.h
index baa0bd1..812cfce 100644
--- a/trackerlogic.h
+++ b/trackerlogic.h
@@ -81,6 +81,9 @@ void deinit_logic( );
81#ifdef WANT_CLOSED_TRACKER 81#ifdef WANT_CLOSED_TRACKER
82extern int g_closedtracker; 82extern int g_closedtracker;
83#endif 83#endif
84#ifdef WANT_BLACKLIST
85extern int g_check_blacklist;
86#endif
84 87
85ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ); 88ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer );
86size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char *reply ); 89size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char *reply );