@@ -176,50 +176,50 @@ def ip_stats(ips):
176
176
if ip is not None :
177
177
hist [ip ['net' ]] += 1
178
178
179
- return 'IPv4 %d, IPv6 %d, Onion %d ' % (hist ['ipv4' ], hist ['ipv6' ], hist ['onion' ])
179
+ return '%6d %6d %6d ' % (hist ['ipv4' ], hist ['ipv6' ], hist ['onion' ])
180
180
181
181
def main ():
182
182
lines = sys .stdin .readlines ()
183
183
ips = [parseline (line ) for line in lines ]
184
184
185
- print ('Initial: %s' % (ip_stats (ips )), file = sys .stderr )
185
+ print ('\x1b [7m IPv4 IPv6 Onion Pass \x1b [0m' , file = sys .stderr )
186
+ print ('%s Initial' % (ip_stats (ips )), file = sys .stderr )
186
187
# Skip entries with invalid address.
187
188
ips = [ip for ip in ips if ip is not None ]
188
- print ('Skip entries with invalid address: %s ' % (ip_stats (ips )), file = sys .stderr )
189
+ print ('%s Skip entries with invalid address' % (ip_stats (ips )), file = sys .stderr )
189
190
# Skip duplicattes (in case multiple seeds files were concatenated)
190
191
ips = dedup (ips )
191
- print ('After removing duplicates: %s ' % (ip_stats (ips )), file = sys .stderr )
192
+ print ('%s After removing duplicates' % (ip_stats (ips )), file = sys .stderr )
192
193
# Skip entries from suspicious hosts.
193
194
ips = [ip for ip in ips if ip ['ip' ] not in SUSPICIOUS_HOSTS ]
194
- print ('Skip entries from suspicious hosts: %s ' % (ip_stats (ips )), file = sys .stderr )
195
+ print ('%s Skip entries from suspicious hosts' % (ip_stats (ips )), file = sys .stderr )
195
196
# Enforce minimal number of blocks.
196
197
ips = [ip for ip in ips if ip ['blocks' ] >= MIN_BLOCKS ]
197
- print ('Enforce minimal number of blocks: %s ' % (ip_stats (ips )), file = sys .stderr )
198
+ print ('%s Enforce minimal number of blocks' % (ip_stats (ips )), file = sys .stderr )
198
199
# Require service bit 1.
199
200
ips = [ip for ip in ips if (ip ['service' ] & 1 ) == 1 ]
200
- print ('Require service bit 1: %s ' % (ip_stats (ips )), file = sys .stderr )
201
+ print ('%s Require service bit 1' % (ip_stats (ips )), file = sys .stderr )
201
202
# Require at least 50% 30-day uptime for clearnet, 10% for onion.
202
203
req_uptime = {
203
204
'ipv4' : 50 ,
204
205
'ipv6' : 50 ,
205
206
'onion' : 10 ,
206
207
}
207
208
ips = [ip for ip in ips if ip ['uptime' ] > req_uptime [ip ['net' ]]]
208
- print ('Require minimum uptime: %s ' % (ip_stats (ips )), file = sys .stderr )
209
+ print ('%s Require minimum uptime' % (ip_stats (ips )), file = sys .stderr )
209
210
# Require a known and recent user agent.
210
211
ips = [ip for ip in ips if PATTERN_AGENT .match (ip ['agent' ])]
211
- print ('Require a known and recent user agent: %s ' % (ip_stats (ips )), file = sys .stderr )
212
+ print ('%s Require a known and recent user agent' % (ip_stats (ips )), file = sys .stderr )
212
213
# Sort by availability (and use last success as tie breaker)
213
214
ips .sort (key = lambda x : (x ['uptime' ], x ['lastsuccess' ], x ['ip' ]), reverse = True )
214
215
# Filter out hosts with multiple bitcoin ports, these are likely abusive
215
216
ips = filtermultiport (ips )
216
- print ('Filter out hosts with multiple bitcoin ports: %s ' % (ip_stats (ips )), file = sys .stderr )
217
+ print ('%s Filter out hosts with multiple bitcoin ports' % (ip_stats (ips )), file = sys .stderr )
217
218
# Look up ASNs and limit results, both per ASN and globally.
218
219
ips = filterbyasn (ips , MAX_SEEDS_PER_ASN , NSEEDS )
220
+ print ('%s Look up ASNs and limit results per ASN and per net' % (ip_stats (ips )), file = sys .stderr )
219
221
# Sort the results by IP address (for deterministic output).
220
- print ('Look up ASNs and limit results, both per ASN and globally: %s' % (ip_stats (ips )), file = sys .stderr )
221
222
ips .sort (key = lambda x : (x ['net' ], x ['sortkey' ]))
222
-
223
223
for ip in ips :
224
224
if ip ['net' ] == 'ipv6' :
225
225
print ('[%s]:%i' % (ip ['ip' ], ip ['port' ]))
0 commit comments