[or-cvs] r12328: Try to provide some slightly more informative error messages (weather/trunk)
pde at seul.org
pde at seul.org
Fri Nov 2 07:03:05 UTC 2007
Author: pde
Date: 2007-11-02 03:03:05 -0400 (Fri, 02 Nov 2007)
New Revision: 12328
Modified:
weather/trunk/poll.py
Log:
Try to provide some slightly more informative error messages for Roger.
Hasn't been tested properly!
Modified: weather/trunk/poll.py
===================================================================
--- weather/trunk/poll.py 2007-11-02 06:12:48 UTC (rev 12327)
+++ weather/trunk/poll.py 2007-11-02 07:03:05 UTC (rev 12328)
@@ -17,6 +17,8 @@
debug = 0
+class NodePollFailure(Exception):
+ pass
debugfile = open(weather_storage + "/torctl-debug","w")
class TorPing:
@@ -51,11 +53,17 @@
info = self.control.get_info(string)
# 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]
+ try:
+ ip,port = info[string].split()[6:8]
+ except:
+ raise NodePollFailure, "Could not extract port and IP from tor client"
# throw exceptions like confetti if this isn't legit
- socket.inet_aton(ip)
- # ensure port is a kosher string
- assert 0 < int(port) < 65536
+ try:
+ socket.inet_aton(ip)
+ # ensure port is a kosher string
+ assert 0 < int(port) < 65536
+ except:
+ raise NodePollFailure, "Tor client getinfo gave a non-kosher ip:port!"
if debug: print "contacting node at %s:%s" % (ip,port)
@@ -71,7 +79,8 @@
if n > 0:
return True
else:
- return False
+ raise NodePollFailure, "Cannot SSL handshake to node."
+ #return False
def test(self):
"Check that the connection to the Tor Control port is still okay."
@@ -153,10 +162,12 @@
node = self.subscriptions.nextkey(node)
self.gdbm_lock.release()
#del self.tp # this minimises the chance of confusion a local tor control
- # port crash with a remote node being down
+ # port crash with a remote node being down
if debug: print "Ping_all finished"
+
def ping(self, node):
+ "Is this node there and, to the best of our knowledge, being a tor node?"
if debug: print "pinging", node
try:
assert self.tp.ping(node)
@@ -186,6 +197,7 @@
good_ping = re.compile("0% packet loss")
def internet_looks_okay(self):
+ "If none of the ping targets are dropping packets, the Internet looks okay."
cmd = ["ping", "-c", "3", "x"]
pings = []
for host in ping_targets:
More information about the tor-commits
mailing list