summaryrefslogtreecommitdiff
path: root/ot_udp.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_udp.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_udp.c')
-rw-r--r--ot_udp.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ot_udp.c b/ot_udp.c
index 0a6458e..64f9c50 100644
--- a/ot_udp.c
+++ b/ot_udp.c
@@ -52,8 +52,8 @@ void handle_udp4( int64 serversocket ) {
52 52
53 r = socket_recv4( serversocket, static_inbuf, sizeof( static_inbuf ), remoteip, &remoteport); 53 r = socket_recv4( serversocket, static_inbuf, sizeof( static_inbuf ), remoteip, &remoteport);
54 54
55 stats_issue_event( EVENT_ACCEPT, 0, ntohl(*(uint32_t*)remoteip) ); 55 stats_issue_event( EVENT_ACCEPT, FLAG_UDP, ntohl(*(uint32_t*)remoteip) );
56 stats_issue_event( EVENT_READ, 0, r ); 56 stats_issue_event( EVENT_READ, FLAG_UDP, r );
57 57
58 /* Minimum udp tracker packet size, also catches error */ 58 /* Minimum udp tracker packet size, also catches error */
59 if( r < 16 ) 59 if( r < 16 )
@@ -72,7 +72,7 @@ void handle_udp4( int64 serversocket ) {
72 udp_make_connectionid( outpacket + 2, remoteip ); 72 udp_make_connectionid( outpacket + 2, remoteip );
73 73
74 socket_send4( serversocket, static_outbuf, 16, remoteip, remoteport ); 74 socket_send4( serversocket, static_outbuf, 16, remoteip, remoteport );
75 stats_issue_event( EVENT_CONNECT, 0, 16 ); 75 stats_issue_event( EVENT_CONNECT, FLAG_UDP, 16 );
76 break; 76 break;
77 case 1: /* This is an announce action */ 77 case 1: /* This is an announce action */
78 /* Minimum udp announce packet size */ 78 /* Minimum udp announce packet size */
@@ -109,9 +109,9 @@ void handle_udp4( int64 serversocket ) {
109 outpacket[1] = inpacket[12/4]; 109 outpacket[1] = inpacket[12/4];
110 110
111 if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) /* Peer is gone. */ 111 if( OT_FLAG( &peer ) & PEER_FLAG_STOPPED ) /* Peer is gone. */
112 r = remove_peer_from_torrent( hash, &peer, static_outbuf, 0 ); 112 r = remove_peer_from_torrent( hash, &peer, static_outbuf, FLAG_UDP );
113 else { 113 else {
114 torrent = add_peer_to_torrent( hash, &peer WANT_TRACKER_SYNC_PARAM( 0 ) ); 114 torrent = add_peer_to_torrent( hash, &peer WANT_SYNC_PARAM( 0 ) );
115 if( !torrent ) 115 if( !torrent )
116 return; /* XXX maybe send error */ 116 return; /* XXX maybe send error */
117 117
@@ -119,7 +119,7 @@ void handle_udp4( int64 serversocket ) {
119 } 119 }
120 120
121 socket_send4( serversocket, static_outbuf, r, remoteip, remoteport ); 121 socket_send4( serversocket, static_outbuf, r, remoteip, remoteport );
122 stats_issue_event( EVENT_ANNOUNCE, 0, r ); 122 stats_issue_event( EVENT_ANNOUNCE, FLAG_UDP, r );
123 break; 123 break;
124 124
125 case 2: /* This is a scrape action */ 125 case 2: /* This is a scrape action */
@@ -133,7 +133,7 @@ void handle_udp4( int64 serversocket ) {
133 return_udp_scrape_for_torrent( (ot_hash*)( static_inbuf + 16 + 20 * r_out ), static_outbuf + 8 + 12 * r_out ); 133 return_udp_scrape_for_torrent( (ot_hash*)( static_inbuf + 16 + 20 * r_out ), static_outbuf + 8 + 12 * r_out );
134 134
135 socket_send4( serversocket, static_outbuf, 8 + 12 * r_out, remoteip, remoteport ); 135 socket_send4( serversocket, static_outbuf, 8 + 12 * r_out, remoteip, remoteport );
136 stats_issue_event( EVENT_SCRAPE, 0, r ); 136 stats_issue_event( EVENT_SCRAPE, FLAG_UDP, r );
137 break; 137 break;
138 } 138 }
139} 139}