diff options
Diffstat (limited to 'opentracker.c')
-rw-r--r-- | opentracker.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/opentracker.c b/opentracker.c index 9c36361..00210d2 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -40,7 +40,8 @@ static unsigned long long ot_full_scrape_size = 0; | |||
40 | static time_t ot_start_time; | 40 | static time_t ot_start_time; |
41 | static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; | 41 | static const size_t SUCCESS_HTTP_HEADER_LENGTH = 80; |
42 | static const size_t SUCCESS_HTTP_SIZE_OFF = 17; | 42 | static const size_t SUCCESS_HTTP_SIZE_OFF = 17; |
43 | static char g_adminip[4] = {0,0,0,0}; | 43 | static uint32_t g_adminip_addresses[OT_ADMINIP_MAX]; |
44 | static unsigned int g_adminip_count = 0; | ||
44 | time_t g_now; | 45 | time_t g_now; |
45 | 46 | ||
46 | #if defined ( WANT_BLACKLISTING ) && defined (WANT_CLOSED_TRACKER ) | 47 | #if defined ( WANT_BLACKLISTING ) && defined (WANT_CLOSED_TRACKER ) |
@@ -90,7 +91,8 @@ struct http_data { | |||
90 | unsigned char ip[4]; | 91 | unsigned char ip[4]; |
91 | STRUCT_HTTP_FLAG flag; | 92 | STRUCT_HTTP_FLAG flag; |
92 | }; | 93 | }; |
93 | #define NOTBLESSED( h ) byte_diff( &h->ip, 4, g_adminip ) | 94 | #define NOTBLESSED( h ) (!bsearch( &h->ip, g_adminip_addresses, g_adminip_count, 4, ot_ip_compare )) |
95 | static int ot_ip_compare( const void *a, const void *b ) { return memcmp( a,b,4 ); } | ||
94 | 96 | ||
95 | /* Prototypes */ | 97 | /* Prototypes */ |
96 | 98 | ||
@@ -954,7 +956,6 @@ int main( int argc, char **argv ) { | |||
954 | "h" ) ) { | 956 | "h" ) ) { |
955 | case -1 : scanon = 0; break; | 957 | case -1 : scanon = 0; break; |
956 | case 'i': scan_ip4( optarg, serverip ); break; | 958 | case 'i': scan_ip4( optarg, serverip ); break; |
957 | case 'A': scan_ip4( optarg, g_adminip ); break; | ||
958 | #ifdef WANT_BLACKLISTING | 959 | #ifdef WANT_BLACKLISTING |
959 | case 'b': accesslist_filename = optarg; break; | 960 | case 'b': accesslist_filename = optarg; break; |
960 | #elif defined( WANT_CLOSED_TRACKER ) | 961 | #elif defined( WANT_CLOSED_TRACKER ) |
@@ -963,12 +964,19 @@ int main( int argc, char **argv ) { | |||
963 | case 'p': ot_try_bind( serverip, (uint16)atol( optarg ), 1 ); break; | 964 | case 'p': ot_try_bind( serverip, (uint16)atol( optarg ), 1 ); break; |
964 | case 'P': ot_try_bind( serverip, (uint16)atol( optarg ), 0 ); break; | 965 | case 'P': ot_try_bind( serverip, (uint16)atol( optarg ), 0 ); break; |
965 | case 'd': serverdir = optarg; break; | 966 | case 'd': serverdir = optarg; break; |
967 | case 'A': | ||
968 | if( g_adminip_count < OT_ADMINIP_MAX ) | ||
969 | scan_ip4( optarg, (char*)(g_adminip_addresses + g_adminip_count++) ); | ||
970 | break; | ||
966 | case 'h': help( argv[0] ); exit( 0 ); | 971 | case 'h': help( argv[0] ); exit( 0 ); |
967 | default: | 972 | default: |
968 | case '?': usage( argv[0] ); exit( 1 ); | 973 | case '?': usage( argv[0] ); exit( 1 ); |
969 | } | 974 | } |
970 | } | 975 | } |
971 | 976 | ||
977 | /* Sort our admin ips for quick lookup */ | ||
978 | qsort( g_adminip_addresses, g_adminip_count, 4, ot_ip_compare ); | ||
979 | |||
972 | /* Bind to our default tcp/udp ports */ | 980 | /* Bind to our default tcp/udp ports */ |
973 | if( !ot_sockets_count ) { | 981 | if( !ot_sockets_count ) { |
974 | ot_try_bind( serverip, 6969, 1 ); | 982 | ot_try_bind( serverip, 6969, 1 ); |