summaryrefslogtreecommitdiff
path: root/ot_fullscrape.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-24 02:04:33 +0200
committerDirk Engling <erdgeist@erdgeist.org>2026-10-24 02:04:33 +0200
commit168285b4569f862443419a2bffe221e1a8ab8150 (patch)
tree27ef578cd4af2e6860bcbc9c0dcb7af16d80b4ec /ot_fullscrape.c
parent0eb6054309f23b3cec7cb799485b859fcf61f794 (diff)
Replace all manual hex conversion with the new helper
Diffstat (limited to 'ot_fullscrape.c')
-rw-r--r--ot_fullscrape.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/ot_fullscrape.c b/ot_fullscrape.c
index 3e36e8e..08970a6 100644
--- a/ot_fullscrape.c
+++ b/ot_fullscrape.c
@@ -23,6 +23,7 @@
23#include "textcode.h" 23#include "textcode.h"
24 24
25/* Opentracker */ 25/* Opentracker */
26#include "ot_hex.h"
26#include "ot_fullscrape.h" 27#include "ot_fullscrape.h"
27#include "ot_iovec.h" 28#include "ot_iovec.h"
28#include "ot_mutex.h" 29#include "ot_mutex.h"
@@ -48,18 +49,6 @@ static void fullscrape_make_zstd(int taskid, ot_tasktype mode);
48 49
49/* Converter function from memory to human readable hex strings 50/* Converter function from memory to human readable hex strings
50 XXX - Duplicated from ot_stats. Needs fix. */ 51 XXX - Duplicated from ot_stats. Needs fix. */
51static char *to_hex(char *d, uint8_t *s) {
52 char *m = "0123456789ABCDEF";
53 char *t = d;
54 char *e = d + 40;
55 while (d < e) {
56 *d++ = m[*s >> 4];
57 *d++ = m[*s++ & 15];
58 }
59 *d = 0;
60 return t;
61}
62
63/* This is the entry point into this worker thread 52/* This is the entry point into this worker thread
64 It grabs tasks from mutex_tasklist and delivers results back 53 It grabs tasks from mutex_tasklist and delivers results back
65*/ 54*/
@@ -117,12 +106,12 @@ static char * fullscrape_write_one( ot_tasktype mode, char *r, ot_torrent *torre
117 106
118 break; 107 break;
119 case TASK_FULLSCRAPE_TPB_ASCII: 108 case TASK_FULLSCRAPE_TPB_ASCII:
120 to_hex(r, *hash); 109 hex_fromhash(r, *hash);
121 r += 2 * sizeof(ot_hash); 110 r += 2 * sizeof(ot_hash);
122 r += sprintf(r, ":%zd:%zd\n", seed_count, peer_count - seed_count); 111 r += sprintf(r, ":%zd:%zd\n", seed_count, peer_count - seed_count);
123 break; 112 break;
124 case TASK_FULLSCRAPE_TPB_ASCII_PLUS: 113 case TASK_FULLSCRAPE_TPB_ASCII_PLUS:
125 to_hex(r, *hash); 114 hex_fromhash(r, *hash);
126 r += 2 * sizeof(ot_hash); 115 r += 2 * sizeof(ot_hash);
127 r += sprintf(r, ":%zd:%zd:%zd\n", seed_count, peer_count - seed_count, down_count); 116 r += sprintf(r, ":%zd:%zd:%zd\n", seed_count, peer_count - seed_count, down_count);
128 break; 117 break;
@@ -138,7 +127,7 @@ static char * fullscrape_write_one( ot_tasktype mode, char *r, ot_torrent *torre
138 r += sprintf(r, ":%zd:%zd\n", seed_count, peer_count - seed_count); 127 r += sprintf(r, ":%zd:%zd\n", seed_count, peer_count - seed_count);
139 break; 128 break;
140 case TASK_FULLSCRAPE_TRACKERSTATE: 129 case TASK_FULLSCRAPE_TRACKERSTATE:
141 to_hex(r, *hash); 130 hex_fromhash(r, *hash);
142 r += 2 * sizeof(ot_hash); 131 r += 2 * sizeof(ot_hash);
143 r += sprintf(r, ":%zd:%zd\n", torrent->peer_list6->base, down_count); 132 r += sprintf(r, ":%zd:%zd\n", torrent->peer_list6->base, down_count);
144 break; 133 break;