Marcus Griep wrote: > Patch attached, comments welcome. I noticed one comment left unchanged in my patch that could leave the next editor of this code a bit confused (comment no longer matches the comment). This patch includes that minor comment fix (block @@ -170,10 +171,10 @@) incorporated with my prior patch. -- Marcus Griep GPG Key ID: 0x070E3F2D —— https://torproj.xpdm.us Ακακια את.ψο´, 3°
Index: TorBulkExitList.py =================================================================== --- TorBulkExitList.py (revision 19666) +++ TorBulkExitList.py (working copy) @@ -8,9 +8,10 @@ from mod_python import util DNS.ParseResolvConf() -def bulkCheck(RemoteServerIP): +def bulkCheck(RemoteServerIP, RemotePort): parsedExitList = "/tmp/TorBulkCheck/parsed-exit-list" - cacheFile = parsedExitList + "-" + RemoteServerIP + ".cache" + cacheFile = parsedExitList + "-" + RemoteServerIP +\ + "_" + RemotePort + ".cache" confirmedExits = [] # Do we have a fresh exit cache? @@ -34,7 +35,7 @@ # the list for possibleExit in possibleExits: try: - if (isUsingTor(possibleExit, RemoteServerIP) == 0 ): + if (isUsingTor(possibleExit, RemoteServerIP, RemotePort) == 0 ): confirmedExits.append(possibleExit) except: return None @@ -52,7 +53,7 @@ else: # Lets return the cache - cachedExits = open(parsedExitList, 'r') + cachedExits = open(cacheFile, 'r') cachedExitList = cachedExits.readlines() return cachedExitList @@ -170,10 +171,10 @@ # We're getting unexpected data - fail closed return 2 for a in answer.answers: - if a['data'] != "127.0.0.2": - return 2 + if a['data'] == "127.0.0.2": + return 0 - # If we're here, we've had a positive exit answer + # If we're here, we have not received a positive exit answer - return 0 + return 2 def parseAddress(req): # Get the ip from apache @@ -199,16 +200,21 @@ req.content_type = 'text/plain; charset=utf-8' RemoteServerIP = parseAddress(req) - RemotePort = "80" + RemotePort = util.FieldStorage(req).getfirst("port", "80") if RemoteServerIP is not None: updateCache() - TestedExits = bulkCheck(RemoteServerIP) + TestedExits = bulkCheck(RemoteServerIP, RemotePort) req.write("# This is a list of all Tor exit nodes that can contact " + RemoteServerIP + " on Port " + RemotePort + " #\n") + + querystring = "ip=%s" % RemoteServerIP + if RemotePort != "80": + querystring += "&port=%s" % RemotePort + req.write("# You can update this list by visiting " + \ - "https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=%s #\n" % RemoteServerIP) + "https://check.torproject.org/cgi-bin/TorBulkExitList.py?%s #\n" % querystring) dateOfAccess = time.asctime(time.gmtime()) req.write("# This file was generated on %s UTC #\n" % dateOfAccess)
Attachment:
signature.asc
Description: OpenPGP digital signature