@@ -15,17 +15,6 @@ using namespace std;
15
15
16
16
bool fTestNet = false ;
17
17
18
- uint64_t filter_whitelist[] = {
19
- 0x0000000000000001 ,
20
- 0x0000000000000003 ,
21
- 0x0000000000000005 ,
22
- 0x0000000000000007 ,
23
- 0x0000000000000009 ,
24
- 0x000000000000000B ,
25
- 0x000000000000000D ,
26
- 0x000000000000000F ,
27
- };
28
-
29
18
class CDnsSeedOpts {
30
19
public:
31
20
int nThreads;
@@ -40,6 +29,7 @@ class CDnsSeedOpts {
40
29
const char *tor;
41
30
const char *ipv4_proxy;
42
31
const char *ipv6_proxy;
32
+ std::set<uint64_t > filter_whitelist;
43
33
44
34
CDnsSeedOpts () : nThreads(96 ), nDnsThreads(4 ), nPort(53 ), mbox(NULL ), ns(NULL ), host(NULL ), tor(NULL ), fUseTestNet (false ), fWipeBan (false ), fWipeIgnore (false ), ipv4_proxy(NULL ), ipv6_proxy(NULL ) {}
45
35
@@ -57,6 +47,7 @@ class CDnsSeedOpts {
57
47
" -o <ip:port> Tor proxy IP/Port\n "
58
48
" -i <ip:port> IPV4 SOCKS5 proxy IP/Port\n "
59
49
" -k <ip:port> IPV6 SOCKS5 proxy IP/Port\n "
50
+ " -w f1,f2,... Allow these flag combinations as filters\n "
60
51
" --testnet Use testnet\n "
61
52
" --wipeban Wipe list of banned nodes\n "
62
53
" --wipeignore Wipe list of ignored nodes\n "
@@ -75,6 +66,7 @@ class CDnsSeedOpts {
75
66
{" onion" , required_argument, 0 , ' o' },
76
67
{" proxyipv4" , required_argument, 0 , ' i' },
77
68
{" proxyipv6" , required_argument, 0 , ' k' },
69
+ {" filter" , required_argument, 0 , ' w' },
78
70
{" testnet" , no_argument, &fUseTestNet , 1 },
79
71
{" wipeban" , no_argument, &fWipeBan , 1 },
80
72
{" wipeignore" , no_argument, &fWipeBan , 1 },
@@ -133,12 +125,32 @@ class CDnsSeedOpts {
133
125
break ;
134
126
}
135
127
128
+ case ' w' : {
129
+ char * ptr = optarg ;
130
+ while (*ptr != 0 ) {
131
+ unsigned long l = strtoul (ptr, &ptr, 0 );
132
+ if (*ptr == ' ,' ) {
133
+ ptr++;
134
+ } else if (*ptr != 0 ) {
135
+ break ;
136
+ }
137
+ filter_whitelist.insert (l);
138
+ }
139
+ break ;
140
+ }
141
+
136
142
case ' ?' : {
137
143
showHelp = true ;
138
144
break ;
139
145
}
140
146
}
141
147
}
148
+ if (filter_whitelist.empty ()) {
149
+ filter_whitelist.insert (1 );
150
+ filter_whitelist.insert (5 );
151
+ filter_whitelist.insert (9 );
152
+ filter_whitelist.insert (13 );
153
+ }
142
154
if (host != NULL && ns == NULL ) showHelp = true ;
143
155
if (showHelp) fprintf (stderr, help, argv[0 ]);
144
156
}
@@ -189,7 +201,7 @@ class CDnsThread {
189
201
std::map<uint64_t , time_t > cacheTime;
190
202
unsigned int cacheHits;
191
203
uint64_t dbQueries;
192
- std::vector <uint64_t > filterWhitelist;
204
+ std::set <uint64_t > filterWhitelist;
193
205
194
206
void cacheHit (uint64_t requestedFlags, bool force = false ) {
195
207
static bool nets[NET_MAX] = {};
@@ -244,7 +256,7 @@ class CDnsThread {
244
256
dbQueries = 0 ;
245
257
nIPv4 = 0 ;
246
258
nIPv6 = 0 ;
247
- filterWhitelist = std::vector< uint64_t >( filter_whitelist, filter_whitelist + ( sizeof filter_whitelist / sizeof filter_whitelist[ 0 ])) ;
259
+ filterWhitelist = opts-> filter_whitelist ;
248
260
}
249
261
250
262
void run () {
@@ -330,11 +342,11 @@ extern "C" void* ThreadDumper(void*) {
330
342
rename (" dnsseed.dat.new" , " dnsseed.dat" );
331
343
}
332
344
FILE *d = fopen (" dnsseed.dump" , " w" );
333
- fprintf (d, " # address servicebits good lastSuccess %%(2h) %%(8h) %%(1d) %%(7d) %%(30d) blocks svcs version\n " );
345
+ fprintf (d, " # address good lastSuccess %%(2h) %%(8h) %%(1d) %%(7d) %%(30d) blocks svcs version\n " );
334
346
double stat[5 ]={0 ,0 ,0 ,0 ,0 };
335
347
for (vector<CAddrReport>::const_iterator it = v.begin (); it < v.end (); it++) {
336
348
CAddrReport rep = *it;
337
- fprintf (d, " %-47s %8lld % 4d %11" PRId64" %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6i %08" PRIx64" %5i \" %s\"\n " , rep.ip .ToString ().c_str (), ( uint64_t )rep. services , (int )rep.fGood , rep.lastSuccess , 100.0 *rep.uptime [0 ], 100.0 *rep.uptime [1 ], 100.0 *rep.uptime [2 ], 100.0 *rep.uptime [3 ], 100.0 *rep.uptime [4 ], rep.blocks , rep.services , rep.clientVersion , rep.clientSubVersion .c_str ());
349
+ fprintf (d, " %-47s %4d %11" PRId64" %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6i %08" PRIx64" %5i \" %s\"\n " , rep.ip .ToString ().c_str (), (int )rep.fGood , rep.lastSuccess , 100.0 *rep.uptime [0 ], 100.0 *rep.uptime [1 ], 100.0 *rep.uptime [2 ], 100.0 *rep.uptime [3 ], 100.0 *rep.uptime [4 ], rep.blocks , rep.services , rep.clientVersion , rep.clientSubVersion .c_str ());
338
350
stat[0 ] += rep.uptime [0 ];
339
351
stat[1 ] += rep.uptime [1 ];
340
352
stat[2 ] += rep.uptime [2 ];
@@ -406,6 +418,14 @@ int main(int argc, char **argv) {
406
418
setbuf (stdout, NULL );
407
419
CDnsSeedOpts opts;
408
420
opts.ParseCommandLine (argc, argv);
421
+ printf (" Supporting whitelisted filters: " );
422
+ for (std::set<uint64_t >::const_iterator it = opts.filter_whitelist .begin (); it != opts.filter_whitelist .end (); it++) {
423
+ if (it != opts.filter_whitelist .begin ()) {
424
+ printf (" ," );
425
+ }
426
+ printf (" 0x%lx" , (unsigned long )*it);
427
+ }
428
+ printf (" \n " );
409
429
if (opts.tor ) {
410
430
CService service (opts.tor , 9050 );
411
431
if (service.IsValid ()) {
0 commit comments