summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-11-09 11:15:48 +0000
committerRoger Dingledine <arma@torproject.org>2004-11-09 11:15:48 +0000
commita6d2bf19c1ec720c3cc4b74ca01d2246c86d6f80 (patch)
treeeb8bc3d376e2845d0171642617b9d1f2625bcdfb
parentca070e7de6b0196b185d58efc033c875626d21e7 (diff)
downloadtor-a6d2bf19c1ec720c3cc4b74ca01d2246c86d6f80.tar.gz
tor-a6d2bf19c1ec720c3cc4b74ca01d2246c86d6f80.zip
tweak the tor-control some more
svn:r2749
-rwxr-xr-xcontrib/tor-control.py31
1 files changed, 26 insertions, 5 deletions
diff --git a/contrib/tor-control.py b/contrib/tor-control.py
index 66c43b32ff..929ee43b01 100755
--- a/contrib/tor-control.py
+++ b/contrib/tor-control.py
@@ -5,9 +5,13 @@ import socket
import struct
import sys
-MSG_TYPE_SETCONF = 0x0002
-MSG_TYPE_GETCONF = 0x0003
-MSG_TYPE_AUTH = 0x0007
+MSG_TYPE_SETCONF = 0x0002
+MSG_TYPE_GETCONF = 0x0003
+MSG_TYPE_SETEVENTS = 0x0005
+MSG_TYPE_AUTH = 0x0007
+
+EVENT_TYPE_BANDWIDTH = 0x0004
+EVENT_TYPE_WARN = 0x0005
def parseHostAndPort(h):
host, port = "localhost", 9051
@@ -57,14 +61,31 @@ def set_option(s,msg):
length,type,body = receive_message(s)
return
+def get_event(s,events):
+ eventbody = struct.pack("!H", events)
+ s.sendall(pack_message(MSG_TYPE_SETEVENTS,eventbody))
+ length,type,body = receive_message(s)
+ return
+
+def listen_for_events(s):
+ while(1):
+ length,type,body = receive_message(s)
+ return
+
def do_main_loop(host,port):
print "host is %s:%d"%(host,port)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
authenticate(s)
get_option(s,"nickname")
- set_option(s,"runasdaemon 1")
-# get_option(s,"DirFetchPostPeriod\n")
+ get_option(s,"DirFetchPostPeriod\n")
+ set_option(s,"1")
+ set_option(s,"bandwidthburstbytes 100000")
+# set_option(s,"runasdaemon 1")
+# get_event(s,EVENT_TYPE_WARN)
+ get_event(s,EVENT_TYPE_BANDWIDTH)
+
+ listen_for_events(s)
return