-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtracker.h
48 lines (43 loc) · 1.35 KB
/
tracker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#define ID_LEN 20
#define PEER_HASH_SIZE 0x100000
#define PEER_HASH_SEARCH_DELTA 0x4
#define PEER_HASH_FN(info_hash) (hash_buf(info_hash) & (PEER_HASH_SIZE - 1))
enum { EVENT_NONE, EVENT_STARTED, EVENT_COMPLETED, EVENT_STOPPED };
struct ipmask_entry_s
{
unsigned char *ipaddr;
unsigned char *netmask;
};
typedef struct ipmask_entry_s ipmask_entry;
struct peer_entry_s
{
unsigned int hash_idx;
unsigned int peer_hash_idx;
unsigned int num_hits;
unsigned int num_seeders, num_leechers, times_completed;
unsigned int is_seeder;
unsigned char info_hash[ID_LEN];
unsigned char peer_id[ID_LEN];
time_t prev_active;
time_t last_active;
unsigned char ipstr[64];
unsigned int ipnum;
unsigned char ipraw[4];
unsigned int port;
unsigned long long uploaded;
unsigned long long downloaded;
unsigned long long prev_uploaded;
unsigned long long prev_downloaded;
unsigned int lastevent;
unsigned int is_local;
unsigned int is_complete;
struct peer_entry_s *next;
struct peer_entry_s *prev;
};
typedef struct peer_entry_s peer_entry;
void tracker_init(void);
void tracker_periodic(void);
void tracker_serve_announce(int, http_fd_entry *, net_fd_entry *);
void tracker_serve_scrape(int, http_fd_entry *, net_fd_entry *);
void tracker_serve_status(int, http_fd_entry *, net_fd_entry *);
void tracker_serve_peers(int, http_fd_entry *, net_fd_entry *);