diff options
| -rw-r--r-- | proxy.c | 17 |
1 files changed, 8 insertions, 9 deletions
| @@ -245,9 +245,9 @@ typedef struct { | |||
| 245 | int64 fd; /* A file handle, if connected, <= 0 is disconnected (0 initially, -1 else) */ | 245 | int64 fd; /* A file handle, if connected, <= 0 is disconnected (0 initially, -1 else) */ |
| 246 | io_batch outdata; /* The iobatch containing our sync data */ | 246 | io_batch outdata; /* The iobatch containing our sync data */ |
| 247 | 247 | ||
| 248 | int packet_tcount; /* Number of unprocessed torrents in packet we currently receive */ | 248 | size_t packet_tcount; /* Number of unprocessed torrents in packet we currently receive */ |
| 249 | char packet_tprefix; /* Prefix byte for all torrents in current packet */ | 249 | uint8_t packet_tprefix; /* Prefix byte for all torrents in current packet */ |
| 250 | char packet_type; /* Type of current packet */ | 250 | uint8_t packet_type; /* Type of current packet */ |
| 251 | uint32_t packet_tid; /* Tracker id for current packet */ | 251 | uint32_t packet_tid; /* Tracker id for current packet */ |
| 252 | 252 | ||
| 253 | } proxy_peer; | 253 | } proxy_peer; |
| @@ -754,7 +754,7 @@ static void livesync_proxytell( uint8_t prefix, uint8_t *info_hash, uint8_t *pee | |||
| 754 | 754 | ||
| 755 | g_peerbuffer_pos += sizeof(ot_hash); | 755 | g_peerbuffer_pos += sizeof(ot_hash); |
| 756 | 756 | ||
| 757 | printf( "%d.%d.%d.%d:%hd (%02X %02X)\n", g_peerbuffer_pos[0], g_peerbuffer_pos[1], g_peerbuffer_pos[2], g_peerbuffer_pos[3], | 757 | printf( "%hhu.%hhu.%hhu.%hhu:%hu (%02X %02X)\n", g_peerbuffer_pos[0], g_peerbuffer_pos[1], g_peerbuffer_pos[2], g_peerbuffer_pos[3], |
| 758 | g_peerbuffer_pos[4] | ( g_peerbuffer_pos[5] << 8 ), g_peerbuffer_pos[6], g_peerbuffer_pos[7] ); | 758 | g_peerbuffer_pos[4] | ( g_peerbuffer_pos[5] << 8 ), g_peerbuffer_pos[6], g_peerbuffer_pos[7] ); |
| 759 | 759 | ||
| 760 | g_peerbuffer_pos += sizeof(ot_peer); | 760 | g_peerbuffer_pos += sizeof(ot_peer); |
| @@ -778,7 +778,7 @@ static void process_indata( proxy_peer * peer ) { | |||
| 778 | peer->packet_tprefix = data[5]; | 778 | peer->packet_tprefix = data[5]; |
| 779 | peer->packet_tcount = data[6] * 256 + data[7]; | 779 | peer->packet_tcount = data[6] * 256 + data[7]; |
| 780 | data += 8; | 780 | data += 8; |
| 781 | printf( "type: %d, prefix: %02X, torrentcount: %d\n", peer->packet_type, peer->packet_tprefix, peer->packet_tcount ); | 781 | printf( "type: %hhu, prefix: %02X, torrentcount: %zd\n", peer->packet_type, peer->packet_tprefix, peer->packet_tcount ); |
| 782 | } | 782 | } |
| 783 | 783 | ||
| 784 | next_torrent: | 784 | next_torrent: |
| @@ -790,13 +790,12 @@ next_torrent: | |||
| 790 | data += sizeof(ot_hash) - 1; | 790 | data += sizeof(ot_hash) - 1; |
| 791 | 791 | ||
| 792 | /* Type 0 has peer count encoded before each peers */ | 792 | /* Type 0 has peer count encoded before each peers */ |
| 793 | if( peer->packet_type == 0 ) { | 793 | peers = peer->packet_type; |
| 794 | if( !peers ) { | ||
| 794 | int shift = 0; | 795 | int shift = 0; |
| 795 | peers = 0; | ||
| 796 | do peers |= ( 0x7f & *data ) << ( 7 * shift ); | 796 | do peers |= ( 0x7f & *data ) << ( 7 * shift ); |
| 797 | while ( *(data++) & 0x80 && shift++ < 6 ); | 797 | while ( *(data++) & 0x80 && shift++ < 6 ); |
| 798 | } else | 798 | } |
| 799 | peers = peer->packet_type; | ||
| 800 | 799 | ||
| 801 | /* Ensure enough data being read to hold all peers */ | 800 | /* Ensure enough data being read to hold all peers */ |
| 802 | if( data + 7 * peers > dataend ) break; | 801 | if( data + 7 * peers > dataend ) break; |
