Skip to content

Commit 3cc989d

Browse files
Fix checking bad dns seeds without casting
Since seed lines comes with 'str' type, comparing it directly with 0 ('int' type) in the if statement was not working at all. This is fixed by casting 'int' type to the values in the 'good' column of seeds text file. Lines that starts with comment in the seeds text file are now ignored. If statement for checking bad seeds are moved to the top of the 'parseline' function as if seed is bad, there is no point of going forward from there.
1 parent 1ea0279 commit 3cc989d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

contrib/seeds/makeseeds.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,16 @@ def parseline(line: str) -> Union[dict, None]:
4646
""" Parses a line from `seeds_main.txt` into a dictionary of details for that line.
4747
or `None`, if the line could not be parsed.
4848
"""
49+
if line.startswith('#'):
50+
# Ignore line that starts with comment
51+
return None
4952
sline = line.split()
5053
if len(sline) < 11:
5154
# line too short to be valid, skip it.
5255
return None
56+
# Skip bad results.
57+
if int(sline[1]) == 0:
58+
return None
5359
m = PATTERN_IPV4.match(sline[0])
5460
sortkey = None
5561
ip = None
@@ -83,9 +89,6 @@ def parseline(line: str) -> Union[dict, None]:
8389
sortkey = ip
8490
ipstr = m.group(1)
8591
port = int(m.group(6))
86-
# Skip bad results.
87-
if sline[1] == 0:
88-
return None
8992
# Extract uptime %.
9093
uptime30 = float(sline[7][:-1])
9194
# Extract Unix timestamp of last success.

0 commit comments

Comments
 (0)