[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [arm/release] Interpretor help for SETEVENTS
commit 6bd40f61ae5e8155be787514da80668505f56e78
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Sep 18 21:15:09 2011 -0700
Interpretor help for SETEVENTS
Basic usage information and lists the event types recognized by tor. Note that
this option still isn't implemented (issuing a SETEVENTS will likely screw up
caching and there's currently no option for seeing the events).
---
src/util/torInterpretor.py | 36 +++++++++++++++++++++++++++++++-----
1 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/util/torInterpretor.py b/src/util/torInterpretor.py
index c2579ae..7e96d3c 100644
--- a/src/util/torInterpretor.py
+++ b/src/util/torInterpretor.py
@@ -59,7 +59,7 @@ Tor commands include:
GETINFO - queries information from tor
GETCONF, SETCONF, RESETCONF - show or edit a configuration option
SIGNAL - issues control signal to the process (for resetting, stopping, etc)
- SETEVENT - configures the events tor will notify us of
+ SETEVENTS - configures the events tor will notify us of
USEFEATURE - enables custom behavior for the controller
SAVECONF - writes tor's current configuration to our torrc
@@ -138,6 +138,16 @@ SIGNAL_DESCRIPTIONS = (
("NEWNYM", "clears the DNS cache and uses new circuits for future connections")
)
+HELP_SETEVENTS = """Sets the events that we will receive. This turns off any events that aren't
+listed so sending 'SETEVENTS' without any values will turn off all event reporting.
+
+For Tor versions between 0.1.1.9 and 0.2.2.1 adding 'EXTENDED' causes some
+events to give us additional information. After version 0.2.2.1 this is
+always on.
+
+Events include...
+"""
+
HELP_OPTIONS = {
"HELP": ("/help [OPTION]", HELP_HELP),
"WRITE": ("/write [PATH]", HELP_WRITE),
@@ -149,6 +159,7 @@ HELP_OPTIONS = {
"SETCONF": ("SETCONF PARAM[=VALUE]", HELP_SETCONF),
"RESETCONF": ("RESETCONF PARAM[=VALUE]", HELP_RESETCONF),
"SIGNAL": ("SIGNAL SIG", HELP_SIGNAL),
+ "SETEVENTS": ("SETEVENTS [EXTENDED] [EVENTS]", HELP_SETEVENTS),
}
class InterpretorClosed(Exception):
@@ -233,11 +244,11 @@ class TorControlCompleter:
self.commands.append("SETCONF ")
self.commands.append("RESETCONF ")
- # adds all of the valid SETEVENT options
+ # adds all of the valid SETEVENTS options
eventOptions = conn.getInfo("events/names")
if eventOptions:
- self.commands += ["SETEVENT %s" % event for event in eventOptions.split(" ")]
- else: self.commands.append("SETEVENT ")
+ self.commands += ["SETEVENTS %s" % event for event in eventOptions.split(" ")]
+ else: self.commands.append("SETEVENTS ")
# adds all of the valid USEFEATURE options
featureOptions = conn.getInfo("features/names")
@@ -391,7 +402,7 @@ class ControlInterpretor:
if confOptions:
confEntries = [opt.split(" ", 1)[0] for opt in confOptions.split("\n")]
- # displays four columns of 30 characters
+ # displays two columns of 42 characters
for i in range(0, len(confEntries), 2):
lineEntries = confEntries[i : i+2]
@@ -407,6 +418,21 @@ class ControlInterpretor:
for signal, description in SIGNAL_DESCRIPTIONS:
outputEntry.append(("%-15s" % signal, OUTPUT_FORMAT + (Attr.BOLD, )))
outputEntry.append((" - %s\n" % description, OUTPUT_FORMAT))
+ elif arg == "SETEVENTS":
+ # lists all of the event types
+ eventOptions = torTools.getConn().getInfo("events/names")
+ if eventOptions:
+ eventEntries = eventOptions.split()
+
+ # displays four columns of 20 characters
+ for i in range(0, len(eventEntries), 4):
+ lineEntries = eventEntries[i : i+4]
+
+ lineContent = ""
+ for entry in lineEntries:
+ lineContent += "%-20s" % entry
+
+ outputEntry.append((lineContent + "\n", OUTPUT_FORMAT))
else:
# check if this is a configuration option
manEntry = torConfig.getConfigDescription(arg)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits