@@ -88,6 +88,8 @@ def parseline(line: str) -> Union[dict, None]:
88
88
if m .group (1 ) in ['::' ]: # Not interested in localhost
89
89
return None
90
90
ipstr = m .group (1 )
91
+ if ipstr .startswith ("fc" ): # cjdns looks like ipv6 but always begins with fc
92
+ net = "cjdns"
91
93
sortkey = ipstr # XXX parse IPv6 into number, could use name_to_ipv6 from generate-seeds
92
94
port = int (m .group (2 ))
93
95
else :
@@ -154,6 +156,7 @@ def filterbyasn(asmap: ASMap, ips: list[dict], max_per_asn: dict, max_per_net: i
154
156
ips_ipv46 = [ip for ip in ips if ip ['net' ] in ['ipv4' , 'ipv6' ]]
155
157
ips_onion = [ip for ip in ips if ip ['net' ] == 'onion' ]
156
158
ips_i2p = [ip for ip in ips if ip ['net' ] == 'i2p' ]
159
+ ips_cjdns = [ip for ip in ips if ip ["net" ] == "cjdns" ]
157
160
158
161
# Filter IPv46 by ASN, and limit to max_per_net per network
159
162
result = []
@@ -178,6 +181,7 @@ def filterbyasn(asmap: ASMap, ips: list[dict], max_per_asn: dict, max_per_net: i
178
181
# Add back Onions (up to max_per_net)
179
182
result .extend (ips_onion [0 :max_per_net ])
180
183
result .extend (ips_i2p [0 :max_per_net ])
184
+ result .extend (ips_cjdns [0 :max_per_net ])
181
185
return result
182
186
183
187
def ip_stats (ips : list [dict ]) -> str :
@@ -187,7 +191,7 @@ def ip_stats(ips: list[dict]) -> str:
187
191
if ip is not None :
188
192
hist [ip ['net' ]] += 1
189
193
190
- return f"{ hist ['ipv4' ]:6d} { hist ['ipv6' ]:6d} { hist ['onion' ]:6d} { hist ['i2p' ]:6d} "
194
+ return f"{ hist ['ipv4' ]:6d} { hist ['ipv6' ]:6d} { hist ['onion' ]:6d} { hist ['i2p' ]:6d} { hist [ 'cjdns' ]:6d } "
191
195
192
196
def parse_args ():
193
197
argparser = argparse .ArgumentParser (description = 'Generate a list of bitcoin node seed ip addresses.' )
@@ -209,7 +213,7 @@ def main():
209
213
ips = [parseline (line ) for line in lines ]
210
214
print ('Done.' , file = sys .stderr )
211
215
212
- print ('\x1b [7m IPv4 IPv6 Onion I2P Pass \x1b [0m' , file = sys .stderr )
216
+ print ('\x1b [7m IPv4 IPv6 Onion I2P CJDNS Pass \x1b [0m' , file = sys .stderr )
213
217
print (f'{ ip_stats (ips ):s} Initial' , file = sys .stderr )
214
218
# Skip entries with invalid address.
215
219
ips = [ip for ip in ips if ip is not None ]
@@ -229,6 +233,7 @@ def main():
229
233
'ipv6' : 50 ,
230
234
'onion' : 10 ,
231
235
'i2p' : 10 ,
236
+ 'cjdns' : 10 ,
232
237
}
233
238
ips = [ip for ip in ips if ip ['uptime' ] > req_uptime [ip ['net' ]]]
234
239
print (f'{ ip_stats (ips ):s} Require minimum uptime' , file = sys .stderr )
@@ -246,7 +251,7 @@ def main():
246
251
# Sort the results by IP address (for deterministic output).
247
252
ips .sort (key = lambda x : (x ['net' ], x ['sortkey' ]))
248
253
for ip in ips :
249
- if ip ['net' ] == 'ipv6' :
254
+ if ip ['net' ] == 'ipv6' or ip [ "net" ] == "cjdns" :
250
255
print (f"[{ ip ['ip' ]} ]:{ ip ['port' ]} " , end = "" )
251
256
else :
252
257
print (f"{ ip ['ip' ]} :{ ip ['port' ]} " , end = "" )
0 commit comments