[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r18180: {weather} Update poll.py to no longer make a call to OpenSSL. Rather, (weather/trunk)
Author: ioerror
Date: 2009-01-19 15:54:53 -0500 (Mon, 19 Jan 2009)
New Revision: 18180
Modified:
weather/trunk/poll.py
Log:
Update poll.py to no longer make a call to OpenSSL. Rather, lets just trust that Tor knows what's going on; if we can fetch information about a given node id, we can assume it's in the consensus. Later we can parse the information and ensure it has the Running flag.
Modified: weather/trunk/poll.py
===================================================================
--- weather/trunk/poll.py 2009-01-19 16:19:39 UTC (rev 18179)
+++ weather/trunk/poll.py 2009-01-19 20:54:53 UTC (rev 18180)
@@ -49,10 +49,16 @@
self.control = None
def ping(self, node_id):
- "Let's see if this tor node is up."
+ "Let's see if this tor node is up by only asking Tor."
string = "ns/id/" + node_id
try:
info = self.control.get_info(string)
+ except ErrorReply:
+ # If we're getting here, we're likely seeing:
+ # ErrorReply: 552 Unrecognized key "ns/id/46D9..."
+ # This means that the node isn't recognized by
+ return False
+
except:
# Remove this, it's a hack to debug this specific bug
x = traceback.format_exc()
@@ -61,29 +67,33 @@
fh.close()
info = None
return False
+
+ # If we're here, we were able to fetch information about the router
+ return True
+
# info looks like this:
# {'ns/id/FFCB46DB1339DA84674C70D7CB586434C4370441': 'r moria1 /8tG2xM52oRnTHDXy1hkNMQ3BEE pavoLDqxMvw+T1VHR5hmmgpr9self 2007-10-10 21:12:08 128.31.0.34 9001 9031\ns Authority Fast Named Running Valid V2Dir\n'}
- ip,port = info[string].split()[6:8]
+ ##ip,port = info[string].split()[6:8]
# throw exceptions like confetti if this isn't legit
- socket.inet_aton(ip)
+ ##socket.inet_aton(ip)
# ensure port is a kosher string
- assert 0 < int(port) < 65536
+ ##assert 0 < int(port) < 65536
- if debug: print "contacting node at %s:%s" % (ip,port)
+ ##if debug: print "contacting node at %s:%s" % (ip,port)
# XXX check: could non-blocking io be used to make us safe from
# answer-very-slowly DOSes? or do we need to spawn threads here?
- cmd = ["openssl", "s_client", "-connect", ip + ':' + port]
- ssl_handshake = Popen( args = cmd, stdout = PIPE, stderr = PIPE, stdin=PIPE)
- ssl_handshake.stdin.close()
- safe_from_DOS = 10000 # moria1's response is ~1500 chars long
- output = ssl_handshake.stdout.read(safe_from_DOS)
- n = output.find("Server public key is 1024 bit")
- if n > 0:
- return True
- else:
- return False
+ ##cmd = ["openssl", "s_client", "-connect", ip + ':' + port]
+ ##ssl_handshake = Popen( args = cmd, stdout = PIPE, stderr = PIPE, stdin=PIPE)
+ ##ssl_handshake.stdin.close()
+ ##safe_from_DOS = 10000 # moria1's response is ~1500 chars long
+ ##output = ssl_handshake.stdout.read(safe_from_DOS)
+ ##n = output.find("Server public key is 1024 bit")
+ ##if n > 0:
+ ## return True
+ ##else:
+ ## return False
def test(self):
"Check that the connection to the Tor Control port is still okay."