diff options
author | erdgeist <> | 2007-11-12 04:39:53 +0000 |
---|---|---|
committer | erdgeist <> | 2007-11-12 04:39:53 +0000 |
commit | 697e239027b1490eaa51e1d2dfc1f93b9941e07b (patch) | |
tree | 3f5bcf8a629a2cc035b307a80fda355bb7481735 /trackerlogic.c | |
parent | 0547e2ade2cfb974526fdcd8b350db0aead7d802 (diff) |
Moving accesslist stuff to its own object
Diffstat (limited to 'trackerlogic.c')
-rw-r--r-- | trackerlogic.c | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index 7f28903..d0d5235 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -21,12 +21,7 @@ | |||
21 | #include "ot_mutex.h" | 21 | #include "ot_mutex.h" |
22 | #include "ot_stats.h" | 22 | #include "ot_stats.h" |
23 | #include "ot_clean.h" | 23 | #include "ot_clean.h" |
24 | 24 | #include "ot_accesslist.h" | |
25 | /* GLOBAL VARIABLES */ | ||
26 | #if defined ( WANT_BLACKLISTING ) || defined( WANT_CLOSED_TRACKER ) | ||
27 | static ot_vector accesslist; | ||
28 | #define WANT_ACCESS_CONTROL | ||
29 | #endif | ||
30 | 25 | ||
31 | void free_peerlist( ot_peerlist *peer_list ) { | 26 | void free_peerlist( ot_peerlist *peer_list ) { |
32 | size_t i; | 27 | size_t i; |
@@ -46,18 +41,10 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_TRACKER_SYNC | |||
46 | ot_vector *torrents_list = mutex_bucket_lock_by_hash( hash ), *peer_pool; | 41 | ot_vector *torrents_list = mutex_bucket_lock_by_hash( hash ), *peer_pool; |
47 | int base_pool = 0; | 42 | int base_pool = 0; |
48 | 43 | ||
49 | #ifdef WANT_ACCESS_CONTROL | 44 | if( !accesslist_hashisvalid( hash ) ) { |
50 | binary_search( hash, accesslist.data, accesslist.size, OT_HASH_COMPARE_SIZE, OT_HASH_COMPARE_SIZE, &exactmatch ); | ||
51 | |||
52 | #ifdef WANT_CLOSED_TRACKER | ||
53 | exactmatch = !exactmatch; | ||
54 | #endif | ||
55 | |||
56 | if( exactmatch ) { | ||
57 | mutex_bucket_unlock_by_hash( hash ); | 45 | mutex_bucket_unlock_by_hash( hash ); |
58 | return NULL; | 46 | return NULL; |
59 | } | 47 | } |
60 | #endif | ||
61 | 48 | ||
62 | torrent = vector_find_or_insert( torrents_list, (void*)hash, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch ); | 49 | torrent = vector_find_or_insert( torrents_list, (void*)hash, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch ); |
63 | if( !torrent ) { | 50 | if( !torrent ) { |
@@ -326,25 +313,6 @@ exit_loop: | |||
326 | return (size_t)20; | 313 | return (size_t)20; |
327 | } | 314 | } |
328 | 315 | ||
329 | #ifdef WANT_ACCESS_CONTROL | ||
330 | void accesslist_reset( void ) { | ||
331 | free( accesslist.data ); | ||
332 | byte_zero( &accesslist, sizeof( accesslist ) ); | ||
333 | } | ||
334 | |||
335 | int accesslist_addentry( ot_hash *infohash ) { | ||
336 | int em; | ||
337 | void *insert = vector_find_or_insert( &accesslist, infohash, OT_HASH_COMPARE_SIZE, OT_HASH_COMPARE_SIZE, &em ); | ||
338 | |||
339 | if( !insert ) | ||
340 | return -1; | ||
341 | |||
342 | memmove( insert, infohash, OT_HASH_COMPARE_SIZE ); | ||
343 | |||
344 | return 0; | ||
345 | } | ||
346 | #endif | ||
347 | |||
348 | int trackerlogic_init( const char * const serverdir ) { | 316 | int trackerlogic_init( const char * const serverdir ) { |
349 | if( serverdir && chdir( serverdir ) ) { | 317 | if( serverdir && chdir( serverdir ) ) { |
350 | fprintf( stderr, "Could not chdir() to %s\n", serverdir ); | 318 | fprintf( stderr, "Could not chdir() to %s\n", serverdir ); |
@@ -352,7 +320,7 @@ int trackerlogic_init( const char * const serverdir ) { | |||
352 | } | 320 | } |
353 | 321 | ||
354 | srandom( time(NULL) ); | 322 | srandom( time(NULL) ); |
355 | 323 | ||
356 | clean_init( ); | 324 | clean_init( ); |
357 | mutex_init( ); | 325 | mutex_init( ); |
358 | 326 | ||