[tor-bugs] #13059 [Tor]: Create bad-relays file
Tor Bug Tracker & Wiki
blackhole at torproject.org
Sun Sep 7 19:08:38 UTC 2014
#13059: Create bad-relays file
---------------------------+--------------------------------
Reporter: Sebastian | Owner:
Type: defect | Status: new
Priority: normal | Milestone: Tor: 0.2.6.x-final
Component: Tor | Version:
Resolution: | Keywords:
Actual Points: | Parent ID: #12898
Points: |
---------------------------+--------------------------------
Comment (by Sebastian):
Trivial script for conversion. It dumps all comments in the new file,
preserves newlines, and removes all unknown lines (=the ones which belong
to the naming system or the torrc).
{{{
#!/usr/bin/python
torrc = "./torrc"
approved_routers = "./approved-routers"
outfile = "./bad-relays"
outfile_reject = outfile + ".reject"
infiles = [torrc, approved_routers]
outf = open(outfile, 'w')
outf_rej = open(outfile_reject, 'w')
for f in infiles:
for line in file(f, 'r'):
l = line.strip().split(None, 1)
if (len(l) == 0 or l[0].startswith('#')):
outf.write(line)
elif l[0].lower() in ['authdirbadexit',
'authdirbadexitcc', 'authdirinvalid', 'authdirinvalidcc',
'authdirreject', 'authdirrejectcc', '!badexit', '!invalid',
'!reject', '' ]:
if (len(l) == 1):
outf.write(line)
else:
outf.write(l[0] + " " + l[1].replace(' ', '') + "\n")
else:
outf_rej.write(line)
}}}
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/13059#comment:4>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list