diff options
Diffstat (limited to 'trackerlogic.h')
-rw-r--r-- | trackerlogic.h | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/trackerlogic.h b/trackerlogic.h index 3525421..986c17a 100644 --- a/trackerlogic.h +++ b/trackerlogic.h | |||
@@ -43,6 +43,11 @@ typedef time_t ot_time; | |||
43 | /* From opentracker.c */ | 43 | /* From opentracker.c */ |
44 | extern time_t g_now; | 44 | extern time_t g_now; |
45 | #define NOW (g_now/OT_POOLS_TIMEOUT) | 45 | #define NOW (g_now/OT_POOLS_TIMEOUT) |
46 | extern uint32_t g_tracker_id; | ||
47 | typedef enum { FLAG_TCP, FLAG_UDP, FLAG_MCA } PROTO_FLAG; | ||
48 | |||
49 | /* Try to bind to ip:port pair. May call exit() on failure */ | ||
50 | int64_t ot_try_bind( char ip[4], uint16_t port, PROTO_FLAG proto ); | ||
46 | 51 | ||
47 | typedef struct { | 52 | typedef struct { |
48 | uint8_t data[8]; | 53 | uint8_t data[8]; |
@@ -50,6 +55,7 @@ typedef struct { | |||
50 | static const uint8_t PEER_FLAG_SEEDING = 0x80; | 55 | static const uint8_t PEER_FLAG_SEEDING = 0x80; |
51 | static const uint8_t PEER_FLAG_COMPLETED = 0x40; | 56 | static const uint8_t PEER_FLAG_COMPLETED = 0x40; |
52 | static const uint8_t PEER_FLAG_STOPPED = 0x20; | 57 | static const uint8_t PEER_FLAG_STOPPED = 0x20; |
58 | static const uint8_t PEER_FLAG_LEECHING = 0x00; | ||
53 | 59 | ||
54 | #define OT_SETIP( peer, ip ) memmove((peer),(ip),4); | 60 | #define OT_SETIP( peer, ip ) memmove((peer),(ip),4); |
55 | #define OT_SETPORT( peer, port ) memmove(((uint8_t*)peer)+4,(port),2); | 61 | #define OT_SETPORT( peer, port ) memmove(((uint8_t*)peer)+4,(port),2); |
@@ -74,7 +80,7 @@ struct ot_peerlist { | |||
74 | size_t down_count; | 80 | size_t down_count; |
75 | size_t seed_counts[ OT_POOLS_COUNT ]; | 81 | size_t seed_counts[ OT_POOLS_COUNT ]; |
76 | ot_vector peers[ OT_POOLS_COUNT ]; | 82 | ot_vector peers[ OT_POOLS_COUNT ]; |
77 | #ifdef WANT_TRACKER_SYNC | 83 | #ifdef WANT_SYNC_BATCH |
78 | ot_vector changeset; | 84 | ot_vector changeset; |
79 | #endif | 85 | #endif |
80 | }; | 86 | }; |
@@ -83,18 +89,23 @@ struct ot_peerlist { | |||
83 | Exported functions | 89 | Exported functions |
84 | */ | 90 | */ |
85 | 91 | ||
86 | #ifdef WANT_TRACKER_SYNC | 92 | #if defined( WANT_SYNC_BATCH ) || defined( WANT_SYNC_LIVE ) |
87 | #define WANT_TRACKER_SYNC_PARAM( param ) , param | 93 | #define WANT_SYNC |
94 | #endif | ||
95 | |||
96 | #ifdef WANT_SYNC | ||
97 | #define WANT_SYNC_PARAM( param ) , param | ||
88 | #else | 98 | #else |
89 | #define WANT_TRACKER_SYNC_PARAM( param ) | 99 | #define WANT_SYNC_PARAM( param ) |
90 | #endif | 100 | #endif |
91 | 101 | ||
92 | int trackerlogic_init( const char * const serverdir ); | 102 | int trackerlogic_init( const char * const serverdir ); |
93 | void trackerlogic_deinit( void ); | 103 | void trackerlogic_deinit( void ); |
104 | void exerr( char * message ); | ||
94 | 105 | ||
95 | ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_TRACKER_SYNC_PARAM( int from_changeset ) ); | 106 | ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM( int from_changeset ) ); |
96 | size_t remove_peer_from_torrent( ot_hash *hash, ot_peer *peer, char *reply, int is_tcp ); | 107 | size_t remove_peer_from_torrent( ot_hash *hash, ot_peer *peer, char *reply, PROTO_FLAG proto ); |
97 | size_t return_peers_for_torrent( ot_hash *hash, size_t amount, char *reply, int is_tcp ); | 108 | size_t return_peers_for_torrent( ot_hash *hash, size_t amount, char *reply, PROTO_FLAG proto ); |
98 | size_t return_tcp_scrape_for_torrent( ot_hash *hash, int amount, char *reply ); | 109 | size_t return_tcp_scrape_for_torrent( ot_hash *hash, int amount, char *reply ); |
99 | size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ); | 110 | size_t return_udp_scrape_for_torrent( ot_hash *hash, char *reply ); |
100 | 111 | ||