[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r19573: {torctl} TorCtl auth_cookie support + misc logging tweak patches from (torctl/trunk/python/TorCtl)
Author: mikeperry
Date: 2009-05-27 23:08:58 -0400 (Wed, 27 May 2009)
New Revision: 19573
Modified:
torctl/trunk/python/TorCtl/SQLSupport.py
torctl/trunk/python/TorCtl/TorCtl.py
torctl/trunk/python/TorCtl/TorUtil.py
Log:
TorCtl auth_cookie support + misc logging tweak patches from
Damian Johnson.
Modified: torctl/trunk/python/TorCtl/SQLSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/SQLSupport.py 2009-05-27 11:32:48 UTC (rev 19572)
+++ torctl/trunk/python/TorCtl/SQLSupport.py 2009-05-28 03:08:58 UTC (rev 19573)
@@ -587,6 +587,8 @@
f.write(str(int(time.time()))+"\n")
+ # XXX: print out avg consensus bw too.. Hrmm, but only
+ # during active scan period..
for s in RouterStats.query.filter(pct_clause).filter(stat_clause).\
order_by(order_by).all():
f.write("node_id=$"+s.router.idhex+" nick="+s.router.nickname)
Modified: torctl/trunk/python/TorCtl/TorCtl.py
===================================================================
--- torctl/trunk/python/TorCtl/TorCtl.py 2009-05-27 11:32:48 UTC (rev 19572)
+++ torctl/trunk/python/TorCtl/TorCtl.py 2009-05-28 03:08:58 UTC (rev 19573)
@@ -426,6 +426,7 @@
self._eventQueue.put((time.time(), "CLOSE"))
self._closed = 1
self._s.close()
+ self._eventThread.join()
finally:
self._sendLock.release()
@@ -657,11 +658,22 @@
return lines
def authenticate(self, secret=""):
- """Send an authenticating secret to Tor. You'll need to call this
- method before Tor can start.
+ """Sends an authenticating secret (password) to Tor. You'll need to call
+ this method (or authenticate_cookie) before Tor can start.
"""
#hexstr = binascii.b2a_hex(secret)
self.sendAndRecv("AUTHENTICATE \"%s\"\r\n"%secret)
+
+ def authenticate_cookie(self, cookie):
+ """Sends an authentication cookie to Tor. This may either be a file or
+ its contents.
+ """
+
+ # read contents if provided a file
+ if type(cookie) == file: cookie = cookie.read()
+
+ # unlike passwords the cookie contents isn't enclosed by quotes
+ self.sendAndRecv("AUTHENTICATE %s\r\n" % binascii.b2a_hex(cookie))
def get_option(self, name):
"""Get the value of the configuration option named 'name'. To
Modified: torctl/trunk/python/TorCtl/TorUtil.py
===================================================================
--- torctl/trunk/python/TorCtl/TorUtil.py 2009-05-27 11:32:48 UTC (rev 19572)
+++ torctl/trunk/python/TorCtl/TorUtil.py 2009-05-28 03:08:58 UTC (rev 19573)
@@ -225,7 +225,7 @@
## XXX: Make this a class?
loglevel = "DEBUG"
-loglevels = {"DEBUG" : 0, "INFO" : 1, "NOTICE" : 2, "WARN" : 3, "ERROR" : 4}
+loglevels = {"DEBUG" : 0, "INFO" : 1, "NOTICE" : 2, "WARN" : 3, "ERROR" : 4, "NONE" : 5}
logfile=None
def plog(level, msg): # XXX: Timestamps