From 1a70d9f9ef81ac1b5e843ac71f3538f7845e03ae Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 13 Apr 2024 00:47:29 +0200 Subject: First shot on chunked transfers --- trackerlogic.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'trackerlogic.c') diff --git a/trackerlogic.c b/trackerlogic.c index 6fd2724..13d2741 100644 --- a/trackerlogic.c +++ b/trackerlogic.c @@ -517,6 +517,29 @@ size_t peer_size_from_peer6(ot_peer6 *peer) { return OT_PEER_SIZE4; } +void trackerlogic_add_random_torrents(size_t amount) { + struct ot_workstruct ws; + memset( &ws, 0, sizeof(ws) ); + + ws.inbuf=malloc(G_INBUF_SIZE); + ws.outbuf=malloc(G_OUTBUF_SIZE); + ws.reply=ws.outbuf; + ws.hash=ws.inbuf; + + while( amount-- ) { + arc4random_buf(ws.hash, sizeof(ot_hash)); + arc4random_buf(&ws.peer, sizeof(ws.peer)); + + OT_PEERFLAG(ws.peer) &= PEER_FLAG_SEEDING | PEER_FLAG_COMPLETED | PEER_FLAG_STOPPED; + + add_peer_to_torrent_and_return_peers( FLAG_TCP, &ws, 1 ); + } + + free(ws.inbuf); + free(ws.outbuf); +} + + void exerr( char * message ) { fprintf( stderr, "%s\n", message ); exit( 111 ); -- cgit v1.2.3