diff options
Diffstat (limited to 'trackerlogic.c')
-rw-r--r-- | trackerlogic.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index ebfb1f8..98fcef9 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -22,6 +22,10 @@ | |||
22 | /* GLOBAL VARIABLES */ | 22 | /* GLOBAL VARIABLES */ |
23 | static ot_vector all_torrents[256]; | 23 | static ot_vector all_torrents[256]; |
24 | static ot_vector changeset; | 24 | static ot_vector changeset; |
25 | #ifdef WANT_BLACKLISTING | ||
26 | static ot_vector blacklist; | ||
27 | #endif | ||
28 | |||
25 | size_t changeset_size = 0; | 29 | size_t changeset_size = 0; |
26 | time_t last_clean_time = 0; | 30 | time_t last_clean_time = 0; |
27 | 31 | ||
@@ -155,6 +159,12 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer, int from_changese | |||
155 | ot_vector *torrents_list = &all_torrents[*hash[0]], *peer_pool; | 159 | ot_vector *torrents_list = &all_torrents[*hash[0]], *peer_pool; |
156 | int base_pool = 0; | 160 | int base_pool = 0; |
157 | 161 | ||
162 | #ifdef WANT_BLACKLISTING | ||
163 | binary_search( hash, blacklist.data, blacklist.size, OT_HASH_COMPARE_SIZE, OT_HASH_COMPARE_SIZE, &exactmatch ); | ||
164 | if( exactmatch ) | ||
165 | return NULL; | ||
166 | #endif | ||
167 | |||
158 | torrent = vector_find_or_insert( torrents_list, (void*)hash, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch ); | 168 | torrent = vector_find_or_insert( torrents_list, (void*)hash, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch ); |
159 | if( !torrent ) return NULL; | 169 | if( !torrent ) return NULL; |
160 | 170 | ||
@@ -672,3 +682,22 @@ void deinit_logic( void ) { | |||
672 | byte_zero( &changeset, sizeof( changeset ) ); | 682 | byte_zero( &changeset, sizeof( changeset ) ); |
673 | changeset_size = 0; | 683 | changeset_size = 0; |
674 | } | 684 | } |
685 | |||
686 | #ifdef WANT_BLACKLISTING | ||
687 | void blacklist_reset( void ) { | ||
688 | free( blacklist.data ); | ||
689 | byte_zero( &blacklist, sizeof( blacklist ) ); | ||
690 | } | ||
691 | |||
692 | int blacklist_addentry( ot_hash *infohash ) { | ||
693 | int em; | ||
694 | void *insert = vector_find_or_insert( &blacklist, infohash, OT_HASH_COMPARE_SIZE, OT_HASH_COMPARE_SIZE, &em ); | ||
695 | |||
696 | if( !insert ) | ||
697 | return -1; | ||
698 | |||
699 | memmove( insert, infohash, OT_HASH_COMPARE_SIZE ); | ||
700 | |||
701 | return 0; | ||
702 | } | ||
703 | #endif | ||