summaryrefslogtreecommitdiff
path: root/ot_accesslist.c
diff options
context:
space:
mode:
authorerdgeist <>2008-10-04 05:40:51 +0000
committererdgeist <>2008-10-04 05:40:51 +0000
commite534db03c6877f8ac0559f63840e9a00e9bd43bf (patch)
tree811181b9b39d0484e28eb25cbb9f2eea094978e2 /ot_accesslist.c
parent8cbfc8602c73e55770f3c06d8ea42758b22a0401 (diff)
added live sync code
added a config file parser added tracker id changed WANT_CLOSED_TRACKER and WANT_BLACKLIST into WANT_ACCESS_WHITE and WANT_ACCESS_BLACK changed WANT_TRACKER_SYNC to WANT_SYNC_BATCH and added WANT_SYNC_LIVE added an option to switch off fullscrapes cleaned up many internal hardcoded values, like PROTO_FLAG,
Diffstat (limited to 'ot_accesslist.c')
-rw-r--r--ot_accesslist.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/ot_accesslist.c b/ot_accesslist.c
index df3d64c..cebb064 100644
--- a/ot_accesslist.c
+++ b/ot_accesslist.c
@@ -18,8 +18,8 @@
18#include "ot_accesslist.h" 18#include "ot_accesslist.h"
19 19
20/* GLOBAL VARIABLES */ 20/* GLOBAL VARIABLES */
21#ifdef WANT_ACCESS_CONTROL 21#ifdef WANT_ACCESSLIST
22static char *accesslist_filename = NULL; 22char *g_accesslist_filename = NULL;
23static ot_vector accesslist; 23static ot_vector accesslist;
24 24
25static void accesslist_reset( void ) { 25static void accesslist_reset( void ) {
@@ -46,13 +46,13 @@ static void accesslist_readfile( int foo ) {
46 char inbuf[512]; 46 char inbuf[512];
47 foo = foo; 47 foo = foo;
48 48
49 accesslist_filehandle = fopen( accesslist_filename, "r" ); 49 accesslist_filehandle = fopen( g_accesslist_filename, "r" );
50 50
51 /* Free accesslist vector in trackerlogic.c*/ 51 /* Free accesslist vector in trackerlogic.c*/
52 accesslist_reset(); 52 accesslist_reset();
53 53
54 if( accesslist_filehandle == NULL ) { 54 if( accesslist_filehandle == NULL ) {
55 fprintf( stderr, "Warning: Can't open accesslist file: %s (but will try to create it later, if necessary and possible).", accesslist_filename ); 55 fprintf( stderr, "Warning: Can't open accesslist file: %s (but will try to create it later, if necessary and possible).", g_accesslist_filename );
56 return; 56 return;
57 } 57 }
58 58
@@ -79,21 +79,20 @@ int accesslist_hashisvalid( ot_hash *hash ) {
79 int exactmatch; 79 int exactmatch;
80 binary_search( hash, accesslist.data, accesslist.size, OT_HASH_COMPARE_SIZE, OT_HASH_COMPARE_SIZE, &exactmatch ); 80 binary_search( hash, accesslist.data, accesslist.size, OT_HASH_COMPARE_SIZE, OT_HASH_COMPARE_SIZE, &exactmatch );
81 81
82#ifdef WANT_BLACKLISTING 82#ifdef WANT_ACCESSLIST_BLACK
83 exactmatch = !exactmatch; 83 exactmatch = !exactmatch;
84#endif 84#endif
85 85
86 return exactmatch; 86 return exactmatch;
87} 87}
88 88
89void accesslist_init( char *accesslist_filename_in ) { 89void accesslist_init( ) {
90 byte_zero( &accesslist, sizeof( accesslist ) ); 90 byte_zero( &accesslist, sizeof( accesslist ) );
91 91
92 /* Passing "0" since read_blacklist_file also is SIGHUP handler */ 92 /* Passing "0" since read_blacklist_file also is SIGHUP handler */
93 if( accesslist_filename_in ) { 93 if( g_accesslist_filename ) {
94 accesslist_filename = accesslist_filename_in;
95 accesslist_readfile( 0 ); 94 accesslist_readfile( 0 );
96 signal( SIGHUP, accesslist_readfile ); 95 signal( SIGHUP, accesslist_readfile );
97 } 96 }
98} 97}
99 98
@@ -108,6 +107,7 @@ int accesslist_blessip( char *ip, ot_permissions permissions ) {
108 return -1; 107 return -1;
109 memmove( g_adminip_addresses + g_adminip_count, ip, 4 ); 108 memmove( g_adminip_addresses + g_adminip_count, ip, 4 );
110 g_adminip_permissions[ g_adminip_count++ ] = permissions; 109 g_adminip_permissions[ g_adminip_count++ ] = permissions;
110// fprintf( stderr, "Blessing ip address %d.%d.%d.%d with %02x\n", (uint8_t)ip[0], (uint8_t)ip[1], (uint8_t)ip[2], (uint8_t)ip[3], permissions );
111 return 0; 111 return 0;
112} 112}
113 113