Skip to content

Commit 801d341

Browse files
committed
contrib: makeseeds: More fancy output
1 parent ed76299 commit 801d341

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

contrib/seeds/makeseeds.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,50 +176,50 @@ def ip_stats(ips):
176176
if ip is not None:
177177
hist[ip['net']] += 1
178178

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'])
180180

181181
def main():
182182
lines = sys.stdin.readlines()
183183
ips = [parseline(line) for line in lines]
184184

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)
186187
# Skip entries with invalid address.
187188
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)
189190
# Skip duplicattes (in case multiple seeds files were concatenated)
190191
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)
192193
# Skip entries from suspicious hosts.
193194
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)
195196
# Enforce minimal number of blocks.
196197
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)
198199
# Require service bit 1.
199200
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)
201202
# Require at least 50% 30-day uptime for clearnet, 10% for onion.
202203
req_uptime = {
203204
'ipv4': 50,
204205
'ipv6': 50,
205206
'onion': 10,
206207
}
207208
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)
209210
# Require a known and recent user agent.
210211
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)
212213
# Sort by availability (and use last success as tie breaker)
213214
ips.sort(key=lambda x: (x['uptime'], x['lastsuccess'], x['ip']), reverse=True)
214215
# Filter out hosts with multiple bitcoin ports, these are likely abusive
215216
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)
217218
# Look up ASNs and limit results, both per ASN and globally.
218219
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)
219221
# 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)
221222
ips.sort(key=lambda x: (x['net'], x['sortkey']))
222-
223223
for ip in ips:
224224
if ip['net'] == 'ipv6':
225225
print('[%s]:%i' % (ip['ip'], ip['port']))

0 commit comments

Comments
 (0)