[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r14840: Greatly simplify the way we split ip addresses up. Also, giv (check/trunk/cgi-bin)
Author: ioerror
Date: 2008-05-30 02:35:15 -0400 (Fri, 30 May 2008)
New Revision: 14840
Modified:
check/trunk/cgi-bin/TorBulkExitList.py
Log:
Greatly simplify the way we split ip addresses up. Also, give sane defaults with a reasonable way to call the function.
Modified: check/trunk/cgi-bin/TorBulkExitList.py
===================================================================
--- check/trunk/cgi-bin/TorBulkExitList.py 2008-05-30 05:28:18 UTC (rev 14839)
+++ check/trunk/cgi-bin/TorBulkExitList.py 2008-05-30 06:35:15 UTC (rev 14840)
@@ -34,7 +34,7 @@
# the list
for possibleExit in possibleExits:
try:
- if (isUsingTor(possibleExit, RemoteServerIP, "80") == 0 ):
+ if (isUsingTor(possibleExit, RemoteServerIP) == 0 ):
confirmedExits.append(possibleExit)
except:
return None
@@ -135,34 +135,17 @@
return possibleExits
-def isUsingTor(clientIp, ELTarget, ELPort):
+def isUsingTor(clientIp, ELTarget = "209.237.247.217", ELPort = "80"):
- if ELPort is None:
- # We'll attempt to reach this port on the Target host
- ElPort = "80"
+ ELExitNode = ".".join(reversed(clientIp.strip().split('.')))
+ ELTarget = ".".join(reversed(ELTarget.strip().split('.')))
- if ELTarget is None:
- # We'll try to reach this host as a reasonable default
- ELTarget = "209.237.247.217"
-
- stripIP = clientIp.rstrip('\n')
- splitIp = stripIP.split('.')
- splitIp.reverse()
- ELExitNode = ".".join(splitIp)
-
- stripIP = ELTarget.rstrip('\n')
- splitIp = stripIP.split('.')
- splitIp.reverse()
- ELTarget = ".".join(splitIp)
-
# This is the ExitList DNS server we want to query
ELHost = "ip-port.exitlist.torproject.org"
# Prepare the question as an A record request
ELQuestion = ELExitNode + "." + ELPort + "." + ELTarget + "." + ELHost
- print("Attempting to ask: %s" % ELQuestion)
request = DNS.DnsRequest(name=ELQuestion,qtype='A')
- print("Asked: %s" % ELQuestion)
# Increase time out length
#answer=request.timeout = 30