commit 04b716fa2c851295d335ee8c90eb01ce76b3d255
Author: Damian Johnson <atagar(a)torproject.org>
Date: Sun Oct 23 14:00:21 2016 -0700
Update nyxrc options
Rewriting our nyxrc.sample and revising the option names (as well as clearing
cruft that's no longer around). Much more compact, and hopefully easier for
users to read.
---
nyx/__init__.py | 36 +++----
nyx/curses.py | 20 ++--
nyx/panel/config.py | 14 +--
nyx/panel/connection.py | 14 +--
nyx/panel/graph.py | 54 +++++-----
nyx/panel/header.py | 4 +-
nyx/panel/log.py | 30 +++---
nyx/settings/attributes.cfg | 3 +
nyx/starter.py | 16 +--
nyx/tracker.py | 12 +--
nyxrc.sample | 252 +++++++++++++++-----------------------------
test/__init__.py | 4 +-
12 files changed, 191 insertions(+), 268 deletions(-)
diff --git a/nyx/__init__.py b/nyx/__init__.py
index a66c95b..f711cd0 100644
--- a/nyx/__init__.py
+++ b/nyx/__init__.py
@@ -66,19 +66,19 @@ __all__ = [
def conf_handler(key, value):
- if key == 'features.redrawRate':
+ if key == 'redraw_rate':
return max(1, value)
CONFIG = stem.util.conf.config_dict('nyx', {
- 'features.confirmQuit': True,
- 'features.panels.show.graph': True,
- 'features.panels.show.log': True,
- 'features.panels.show.connection': True,
- 'features.panels.show.config': True,
- 'features.panels.show.torrc': True,
- 'features.panels.show.interpreter': True,
- 'features.redrawRate': 5,
+ 'confirm_quit': True,
+ 'redraw_rate': 5,
+ 'show_graph': True,
+ 'show_log': True,
+ 'show_connections': True,
+ 'show_config': True,
+ 'show_torrc': True,
+ 'show_interpreter': True,
'start_time': 0,
}, conf_handler)
@@ -136,7 +136,7 @@ def draw_loop():
if next_key:
key, next_key = next_key, None
else:
- key = nyx.curses.key_input(CONFIG['features.redrawRate'])
+ key = nyx.curses.key_input(CONFIG['redraw_rate'])
if key.match('right'):
interface.set_page((interface.get_page() + 1) % interface.page_count())
@@ -147,7 +147,7 @@ def draw_loop():
elif key.match('m'):
nyx.menu.show_menu()
elif key.match('q'):
- if CONFIG['features.confirmQuit']:
+ if CONFIG['confirm_quit']:
confirmation_key = show_message(msg('confirm_quit'), nyx.curses.BOLD, max_wait = 30)
if not confirmation_key.match('q'):
@@ -256,7 +256,7 @@ def expand_path(path, config):
return None
try:
- chroot = config.get('tor.chroot', '')
+ chroot = config.get('tor_chroot', '')
tor_cwd = stem.util.system.cwd(tor_controller().get_pid(None))
return chroot + stem.util.system.expand_path(path, tor_cwd)
except IOError as exc:
@@ -344,25 +344,25 @@ class Interface(object):
self._header_panel = nyx.panel.header.HeaderPanel()
first_page_panels = []
- if CONFIG['features.panels.show.graph']:
+ if CONFIG['show_graph']:
first_page_panels.append(nyx.panel.graph.GraphPanel())
- if CONFIG['features.panels.show.log']:
+ if CONFIG['show_log']:
first_page_panels.append(nyx.panel.log.LogPanel())
if first_page_panels:
self._page_panels.append(first_page_panels)
- if CONFIG['features.panels.show.connection']:
+ if CONFIG['show_connections']:
self._page_panels.append([nyx.panel.connection.ConnectionPanel()])
- if CONFIG['features.panels.show.config']:
+ if CONFIG['show_config']:
self._page_panels.append([nyx.panel.config.ConfigPanel()])
- if CONFIG['features.panels.show.torrc']:
+ if CONFIG['show_torrc']:
self._page_panels.append([nyx.panel.torrc.TorrcPanel()])
- if CONFIG['features.panels.show.interpreter']:
+ if CONFIG['show_interpreter']:
self._page_panels.append([nyx.panel.interpreter.InterpreterPanel()])
visible_panels = self.page_panels()
diff --git a/nyx/curses.py b/nyx/curses.py
index d610edf..112fd2e 100644
--- a/nyx/curses.py
+++ b/nyx/curses.py
@@ -166,17 +166,17 @@ Dimensions = collections.namedtuple('Dimensions', ['width', 'height'])
def conf_handler(key, value):
- if key == 'features.colorOverride':
+ if key == 'color_override':
if value not in Color and value != 'None':
raise ValueError(msg('usage.unable_to_set_color_override', color = value))
- elif key == 'features.torrc.maxLineWrap':
+ elif key == 'max_line_wrap':
return max(1, value)
CONFIG = stem.util.conf.config_dict('nyx', {
- 'features.colorOverride': 'None',
- 'features.colorInterface': True,
- 'features.maxLineWrap': 8,
+ 'color_interface': True,
+ 'color_override': 'None',
+ 'max_line_wrap': 8,
}, conf_handler)
@@ -558,7 +558,7 @@ def get_color_override():
overwritten with, **None** if no override is set
"""
- color_override = CONFIG.get('features.colorOverride', 'None')
+ color_override = CONFIG.get('color_override', 'None')
return None if color_override == 'None' else color_override
@@ -575,9 +575,9 @@ def set_color_override(color = None):
nyx_config = stem.util.conf.get_config('nyx')
if color is None:
- nyx_config.set('features.colorOverride', 'None')
+ nyx_config.set('color_override', 'None')
elif color in Color:
- nyx_config.set('features.colorOverride', color)
+ nyx_config.set('color_override', color)
else:
raise ValueError(msg('usage.unable_to_set_color_override', color = color))
@@ -591,7 +591,7 @@ def _color_attr():
global COLOR_ATTR
if COLOR_ATTR is None:
- if not CONFIG['features.colorInterface']:
+ if not CONFIG['color_interface']:
COLOR_ATTR = DEFAULT_COLOR_ATTR
elif curses.has_colors():
color_attr = dict(DEFAULT_COLOR_ATTR)
@@ -777,7 +777,7 @@ class _Subwindow(object):
x = self.addstr(x, y, draw_msg, *attr)
msg = msg.lstrip()
- if (y - orig_y + 1) >= CONFIG['features.maxLineWrap']:
+ if (y - orig_y + 1) >= CONFIG['max_line_wrap']:
break # maximum number we'll wrap
if msg:
diff --git a/nyx/panel/config.py b/nyx/panel/config.py
index 0f454f3..726df64 100644
--- a/nyx/panel/config.py
+++ b/nyx/panel/config.py
@@ -31,16 +31,16 @@ VALUE_WIDTH = 15
def conf_handler(key, value):
- if key == 'features.config.order':
+ if key == 'config_order':
return conf.parse_enum_csv(key, value[0], SortAttr, 3)
CONFIG = conf.config_dict('nyx', {
'attr.config.category_color': {},
'attr.config.sort_color': {},
- 'features.config.order': [SortAttr.MAN_PAGE_ENTRY, SortAttr.NAME, SortAttr.IS_SET],
- 'features.config.state.showPrivateOptions': False,
- 'features.config.state.showVirtualOptions': False,
+ 'config_order': [SortAttr.MAN_PAGE_ENTRY, SortAttr.NAME, SortAttr.IS_SET],
+ 'show_private_options': False,
+ 'show_virtual_options': False,
}, conf_handler)
@@ -127,7 +127,7 @@ class ConfigPanel(nyx.panel.Panel):
self._contents = []
self._scroller = nyx.curses.CursorScroller()
- self._sort_order = CONFIG['features.config.order']
+ self._sort_order = CONFIG['config_order']
self._show_all = False # show all options, or just the important ones
data_dir = data_directory()
@@ -162,9 +162,9 @@ class ConfigPanel(nyx.panel.Panel):
# skips private and virtual entries if not configured to show them
- if name.startswith('__') and not CONFIG['features.config.state.showPrivateOptions']:
+ if name.startswith('__') and not CONFIG['show_private_options']:
continue
- elif value_type == 'Virtual' and not CONFIG['features.config.state.showVirtualOptions']:
+ elif value_type == 'Virtual' and not CONFIG['show_virtual_options']:
continue
self._contents.append(ConfigEntry(name, value_type, manual))
diff --git a/nyx/panel/connection.py b/nyx/panel/connection.py
index f8b41ee..2858ee9 100644
--- a/nyx/panel/connection.py
+++ b/nyx/panel/connection.py
@@ -67,16 +67,16 @@ Line = collections.namedtuple('Line', [
def conf_handler(key, value):
- if key == 'features.connection.order':
+ if key == 'connection_order':
return conf.parse_enum_csv(key, value[0], SortAttr, 3)
CONFIG = conf.config_dict('nyx', {
'attr.connection.category_color': {},
'attr.connection.sort_color': {},
- 'features.connection.resolveApps': True,
- 'features.connection.order': [SortAttr.CATEGORY, SortAttr.IP_ADDRESS, SortAttr.UPTIME],
- 'features.connection.showIps': True,
+ 'connection_order': [SortAttr.CATEGORY, SortAttr.IP_ADDRESS, SortAttr.UPTIME],
+ 'resolve_processes': True,
+ 'show_addresses': True,
}, conf_handler)
@@ -207,7 +207,7 @@ class ConnectionEntry(Entry):
@lru_cache()
def is_private(self):
- if not CONFIG['features.connection.showIps']:
+ if not CONFIG['show_addresses']:
return True
if self.get_type() == Category.INBOUND:
@@ -264,7 +264,7 @@ class ConnectionPanel(nyx.panel.DaemonPanel):
self._scroller = nyx.curses.CursorScroller()
self._entries = [] # last fetched display entries
self._show_details = False # presents the details panel if true
- self._sort_order = CONFIG['features.connection.order']
+ self._sort_order = CONFIG['connection_order']
self._pause_time = 0
self._last_resource_fetch = -1 # timestamp of the last ConnectionResolver results used
@@ -523,7 +523,7 @@ class ConnectionPanel(nyx.panel.DaemonPanel):
self._entries = sorted(new_entries, key = lambda entry: [entry.sort_value(attr) for attr in self._sort_order])
self._last_resource_fetch = resolution_count
- if CONFIG['features.connection.resolveApps']:
+ if CONFIG['resolve_processes']:
local_ports, remote_ports = [], []
for entry in new_entries:
diff --git a/nyx/panel/graph.py b/nyx/panel/graph.py
index 59b201c..f8b507e 100644
--- a/nyx/panel/graph.py
+++ b/nyx/panel/graph.py
@@ -52,22 +52,22 @@ WIDE_LABELING_GRAPH_COL = 50 # minimum graph columns to use wide spacing for x-
def conf_handler(key, value):
- if key == 'features.graph.height':
+ if key == 'graph_height':
return max(1, value)
- elif key == 'features.graph.max_width':
+ elif key == 'max_graph_width':
return max(1, value)
- elif key == 'features.graph.type':
+ elif key == 'graph_stat':
if value != 'none' and value not in GraphStat:
- log.warn("'%s' isn't a valid graph type, options are: none, %s" % (CONFIG['features.graph.type'], ', '.join(GraphStat)))
- return CONFIG['features.graph.type'] # keep the default
- elif key == 'features.graph.interval':
+ log.warn("'%s' isn't a valid graph type, options are: none, %s" % (CONFIG['graph_stat'], ', '.join(GraphStat)))
+ return CONFIG['graph_stat'] # keep the default
+ elif key == 'graph_interval':
if value not in Interval:
log.warn("'%s' isn't a valid graphing interval, options are: %s" % (value, ', '.join(Interval)))
- return CONFIG['features.graph.interval'] # keep the default
- elif key == 'features.graph.bound':
+ return CONFIG['graph_interval'] # keep the default
+ elif key == 'graph_bound':
if value not in Bounds:
log.warn("'%s' isn't a valid graph bounds, options are: %s" % (value, ', '.join(Bounds)))
- return CONFIG['features.graph.bound'] # keep the default
+ return CONFIG['graph_bound'] # keep the default
CONFIG = conf.config_dict('nyx', {
@@ -75,14 +75,14 @@ CONFIG = conf.config_dict('nyx', {
'attr.graph.title': {},
'attr.graph.header.primary': {},
'attr.graph.header.secondary': {},
- 'features.graph.height': 7,
- 'features.graph.type': GraphStat.BANDWIDTH,
- 'features.graph.interval': Interval.EACH_SECOND,
- 'features.graph.bound': Bounds.LOCAL_MAX,
- 'features.graph.max_width': 300, # we need some sort of max size so we know how much graph data to retain
- 'features.panels.show.connection': True,
- 'features.graph.bw.transferInBytes': False,
- 'features.graph.bw.accounting.show': True,
+ 'graph_bound': Bounds.LOCAL_MAX,
+ 'graph_height': 7,
+ 'graph_interval': Interval.EACH_SECOND,
+ 'graph_stat': GraphStat.BANDWIDTH,
+ 'max_graph_width': 300, # we need some sort of max size so we know how much graph data to retain
+ 'show_accounting': True,
+ 'show_bytes': False,
+ 'show_connections': True,
}, conf_handler)
@@ -111,7 +111,7 @@ class GraphData(object):
self.latest_value = 0
self.total = 0
self.tick = 0
- self.values = dict([(i, CONFIG['features.graph.max_width'] * [0]) for i in Interval])
+ self.values = dict([(i, CONFIG['max_graph_width'] * [0]) for i in Interval])
self._category = category
self._is_primary = is_primary
@@ -412,10 +412,10 @@ class GraphPanel(nyx.panel.Panel):
def __init__(self):
nyx.panel.Panel.__init__(self)
- self._displayed_stat = None if CONFIG['features.graph.type'] == 'none' else CONFIG['features.graph.type']
- self._update_interval = CONFIG['features.graph.interval']
- self._bounds_type = CONFIG['features.graph.bound']
- self._graph_height = CONFIG['features.graph.height']
+ self._displayed_stat = None if CONFIG['graph_stat'] == 'none' else CONFIG['graph_stat']
+ self._update_interval = CONFIG['graph_interval']
+ self._bounds_type = CONFIG['graph_bound']
+ self._graph_height = CONFIG['graph_height']
self._accounting_stats = None
self._accounting_stats_paused = None
@@ -427,10 +427,10 @@ class GraphPanel(nyx.panel.Panel):
self._stats_paused = None
- if CONFIG['features.panels.show.connection']:
+ if CONFIG['show_connections']:
self._stats[GraphStat.CONNECTIONS] = ConnectionStats()
elif self._displayed_stat == GraphStat.CONNECTIONS:
- log.warn("The connection graph is unavailble when you set 'features.panels.show.connection false'.")
+ log.warn("The connection graph is unavailble when you set 'show_connections false'.")
self._displayed_stat = GraphStat.BANDWIDTH
controller = tor_controller()
@@ -563,7 +563,7 @@ class GraphPanel(nyx.panel.Panel):
stat = type(stat)(stat) # clone the GraphCategory
subgraph_height = self._graph_height + 2 # graph rows + header + x-axis label
- subgraph_width = min(subwindow.width // 2, CONFIG['features.graph.max_width'])
+ subgraph_width = min(subwindow.width // 2, CONFIG['max_graph_width'])
interval, bounds_type = self._update_interval, self._bounds_type
subwindow.addstr(0, 0, stat.title(subwindow.width), HIGHLIGHT)
@@ -575,7 +575,7 @@ class GraphPanel(nyx.panel.Panel):
_draw_accounting_stats(subwindow, DEFAULT_CONTENT_HEIGHT + subgraph_height - 2, accounting_stats)
def _update_accounting(self, event):
- if not CONFIG['features.graph.bw.accounting.show']:
+ if not CONFIG['show_accounting']:
self._accounting_stats = None
elif not self._accounting_stats or time.time() - self._accounting_stats.retrieved >= ACCOUNTING_RATE:
old_accounting_stats = self._accounting_stats
@@ -710,4 +710,4 @@ def _size_label(byte_count, decimal = 1):
or bytes.
"""
- return str_tools.size_label(byte_count, decimal, is_bytes = CONFIG['features.graph.bw.transferInBytes'])
+ return str_tools.size_label(byte_count, decimal, is_bytes = CONFIG['show_bytes'])
diff --git a/nyx/panel/header.py b/nyx/panel/header.py
index 394ef7b..df4fb8d 100644
--- a/nyx/panel/header.py
+++ b/nyx/panel/header.py
@@ -33,7 +33,7 @@ UPDATE_RATE = 5 # rate in seconds at which we refresh
CONFIG = conf.config_dict('nyx', {
'attr.flag_colors': {},
'attr.version_status_colors': {},
- 'tor.chroot': '',
+ 'tor_chroot': '',
})
@@ -129,7 +129,7 @@ class HeaderPanel(nyx.panel.DaemonPanel):
try:
try:
- controller.reconnect(chroot_path = CONFIG['tor.chroot'])
+ controller.reconnect(chroot_path = CONFIG['tor_chroot'])
except stem.connection.MissingPassword:
password = input_prompt('Controller Password: ')
diff --git a/nyx/panel/log.py b/nyx/panel/log.py
index 6e1d14d..ed3d947 100644
--- a/nyx/panel/log.py
+++ b/nyx/panel/log.py
@@ -26,21 +26,21 @@ from stem.util import conf, log
def conf_handler(key, value):
- if key == 'features.log.prepopulateReadLimit':
+ if key == 'prepopulate_read_limit':
return max(0, value)
- elif key == 'cache.log_panel.size':
+ elif key == 'max_log_size':
return max(1000, value)
CONFIG = conf.config_dict('nyx', {
'attr.log_color': {},
- 'cache.log_panel.size': 1000,
- 'features.logFile': '',
- 'features.log.showDuplicateEntries': False,
- 'features.log.prepopulate': True,
- 'features.log.prepopulateReadLimit': 5000,
- 'features.log.regex': [],
+ 'deduplicate_log': True,
'logged_events': 'NOTICE,WARN,ERR,NYX_NOTICE,NYX_WARNING,NYX_ERROR',
+ 'logging_filter': [],
+ 'max_log_size': 1000,
+ 'prepopulate_log': True,
+ 'prepopulate_read_limit': 5000,
+ 'write_logs_to': '',
}, conf_handler)
UPDATE_RATE = 0.3
@@ -77,12 +77,12 @@ class LogPanel(nyx.panel.DaemonPanel):
logged_events = ['NOTICE', 'WARN', 'ERR', 'NYX_NOTICE', 'NYX_WARNING', 'NYX_ERROR']
log.warn("Your --log argument had the following events tor doesn't recognize: %s" % ', '.join(invalid_events))
- self._event_log = nyx.log.LogGroup(CONFIG['cache.log_panel.size'], group_by_day = True)
+ self._event_log = nyx.log.LogGroup(CONFIG['max_log_size'], group_by_day = True)
self._event_log_paused = None
self._event_types = nyx.log.listen_for_events(self._register_tor_event, logged_events)
- self._log_file = nyx.log.LogFileOutput(CONFIG['features.logFile'])
- self._filter = nyx.log.LogFilters(initial_filters = CONFIG['features.log.regex'])
- self._show_duplicates = CONFIG['features.log.showDuplicateEntries']
+ self._log_file = nyx.log.LogFileOutput(CONFIG['write_logs_to'])
+ self._filter = nyx.log.LogFilters(initial_filters = CONFIG['logging_filter'])
+ self._show_duplicates = not CONFIG['deduplicate_log']
self._scroller = nyx.curses.Scroller()
self._has_new_event = False
@@ -90,12 +90,12 @@ class LogPanel(nyx.panel.DaemonPanel):
# fetches past tor events from log file, if available
- if CONFIG['features.log.prepopulate']:
+ if CONFIG['prepopulate_log']:
log_location = nyx.log.log_file_path(tor_controller())
if log_location:
try:
- for entry in reversed(list(nyx.log.read_tor_log(log_location, CONFIG['features.log.prepopulateReadLimit']))):
+ for entry in reversed(list(nyx.log.read_tor_log(log_location, CONFIG['prepopulate_read_limit']))):
if entry.type in self._event_types:
self._event_log.add(entry)
except IOError as exc:
@@ -152,7 +152,7 @@ class LogPanel(nyx.panel.DaemonPanel):
Clears the contents of the event log.
"""
- self._event_log = nyx.log.LogGroup(CONFIG['cache.log_panel.size'], group_by_day = True)
+ self._event_log = nyx.log.LogGroup(CONFIG['max_log_size'], group_by_day = True)
self.redraw()
def save_snapshot(self, path):
diff --git a/nyx/settings/attributes.cfg b/nyx/settings/attributes.cfg
index 37e8ebc..f35bafd 100644
--- a/nyx/settings/attributes.cfg
+++ b/nyx/settings/attributes.cfg
@@ -1,3 +1,6 @@
+prepopulate_read_limit 5000 # Maximum number of log entries to prepopulate with.
+max_line_wrap 8 # Maximum number of lines to wrap strings for.
+
# General configuration data used by nyx.
attr.flag_colors Authority => White
diff --git a/nyx/starter.py b/nyx/starter.py
index d23e157..ce23929 100644
--- a/nyx/starter.py
+++ b/nyx/starter.py
@@ -69,7 +69,7 @@ def main(config):
control_port = control_port,
control_socket = control_socket,
password_prompt = True,
- chroot_path = config.get('tor.chroot', ''),
+ chroot_path = config.get('tor_chroot', ''),
)
if controller is None:
@@ -85,7 +85,7 @@ def main(config):
_set_process_name()
try:
- nyx.curses.start(nyx.draw_loop, acs_support = config.get('features.acsSupport', True), transparent_background = True, cursor = False)
+ nyx.curses.start(nyx.draw_loop, acs_support = config.get('acs_support', True), transparent_background = True, cursor = False)
except UnboundLocalError as exc:
if os.environ['TERM'] != 'xterm':
print(msg('setup.unknown_term', term = os.environ['TERM']))
@@ -153,13 +153,13 @@ def _load_user_nyxrc(path, config):
# If the user provided us with a chroot then validate and normalize the
# path.
- chroot = config.get('tor.chroot', '').strip().rstrip(os.path.sep)
+ chroot = config.get('tor_chroot', '').strip().rstrip(os.path.sep)
if chroot and not os.path.exists(chroot):
log.notice('setup.chroot_doesnt_exist', path = chroot)
- config.set('tor.chroot', '')
+ config.set('tor_chroot', '')
else:
- config.set('tor.chroot', chroot) # use the normalized path
+ config.set('tor_chroot', chroot) # use the normalized path
except IOError as exc:
log.warn('config.unable_to_read_file', error = exc.strerror)
else:
@@ -206,12 +206,12 @@ def _setup_freebsd_chroot(controller, config):
If we're running under FreeBSD then check the system for a chroot path.
"""
- if not config.get('tor.chroot', None) and platform.system() == 'FreeBSD':
+ if not config.get('tor_chroot', None) and platform.system() == 'FreeBSD':
jail_chroot = stem.util.system.bsd_jail_path(controller.get_pid(0))
if jail_chroot and os.path.exists(jail_chroot):
log.info('setup.set_freebsd_chroot', path = jail_chroot)
- config.set('tor.chroot', jail_chroot)
+ config.set('tor_chroot', jail_chroot)
def _use_english_subcommands():
@@ -241,7 +241,7 @@ def _use_unicode(config):
initializing curses.
"""
- if not config.get('features.printUnicode', True):
+ if not config.get('unicode_support', True):
return
is_lang_unicode = 'utf-' in os.getenv('LANG', '').lower()
diff --git a/nyx/tracker.py b/nyx/tracker.py
index 204f97b..a42b357 100644
--- a/nyx/tracker.py
+++ b/nyx/tracker.py
@@ -61,9 +61,9 @@ from nyx import log, tor_controller
from stem.util import conf, connection, enum, proc, str_tools, system
CONFIG = conf.config_dict('nyx', {
- 'queries.connections.rate': 5,
- 'queries.resources.rate': 5,
- 'queries.port_usage.rate': 5,
+ 'connection_rate': 5,
+ 'resource_rate': 5,
+ 'port_usage_rate': 5,
})
CONNECTION_TRACKER = None
@@ -114,7 +114,7 @@ def get_connection_tracker():
global CONNECTION_TRACKER
if CONNECTION_TRACKER is None:
- CONNECTION_TRACKER = ConnectionTracker(CONFIG['queries.connections.rate'])
+ CONNECTION_TRACKER = ConnectionTracker(CONFIG['connection_rate'])
CONNECTION_TRACKER.start()
return CONNECTION_TRACKER
@@ -128,7 +128,7 @@ def get_resource_tracker():
global RESOURCE_TRACKER
if RESOURCE_TRACKER is None:
- RESOURCE_TRACKER = ResourceTracker(CONFIG['queries.resources.rate'])
+ RESOURCE_TRACKER = ResourceTracker(CONFIG['resource_rate'])
RESOURCE_TRACKER.start()
return RESOURCE_TRACKER
@@ -142,7 +142,7 @@ def get_port_usage_tracker():
global PORT_USAGE_TRACKER
if PORT_USAGE_TRACKER is None:
- PORT_USAGE_TRACKER = PortUsageTracker(CONFIG['queries.port_usage.rate'])
+ PORT_USAGE_TRACKER = PortUsageTracker(CONFIG['port_usage_rate'])
PORT_USAGE_TRACKER.start()
return PORT_USAGE_TRACKER
diff --git a/nyxrc.sample b/nyxrc.sample
index bbce437..b3c17ed 100644
--- a/nyxrc.sample
+++ b/nyxrc.sample
@@ -1,170 +1,90 @@
-# Events that are shown by default in the log. You can also set these with
-# 'nyx --log <events>'.
-
-logged_events NOTICE,WARN,ERR,NYX_NOTICE,NYX_WARNING,NYX_ERROR
-
-# Location where information is cached. You can disable caching by setting this
-# to 'disabled'.
-
-data_directory ~/.nyx
-
-# Seconds between querying information
-
-queries.connections.rate 5
-queries.resources.rate 5
-queries.port_usage.rate 5
-
-queries.refreshRate.rate 5
-
-# allows individual panels to be included/excluded
-features.panels.show.graph true
-features.panels.show.log true
-features.panels.show.connection true
-features.panels.show.config true
-features.panels.show.torrc true
-
-# Renders the interface with color if set and the terminal supports it
-features.colorInterface true
-
-# Uses ACS (alternate character support) to display nice borders. This may not
-# work on all terminals.
-features.acsSupport true
-
-# Replaces all colored content (ie, anything that isn't white) with this
-# color. Valid options are:
-# none, red, green, yellow, blue, cyan, magenta, black, white
-features.colorOverride none
-
-# Includes unicode characters in the interface.
-features.printUnicode true
-
-# Set this if you're running in a chroot jail or other environment where tor's
-# resources (log, state, etc) should have a prefix in their paths.
-
-tor.chroot
-
-# If set, nyx appends any log messages it reports while running to the given
-# log file. This does not take filters into account or include prepopulated
-# events.
-features.logFile
-
-# Seconds to wait on user input before refreshing content
-features.redrawRate 5
-
-# Confirms promt to confirm when quiting if true
-features.confirmQuit true
-
-# Paremters for the log panel
-# ---------------------------
-# showDuplicateEntries
-# shows all log entries if true, otherwise collapses similar entries with an
-# indicator for how much is being hidden
-# prepopulate
-# attempts to read past events from the log file if true
-# prepopulateReadLimit
-# maximum entries read from the log file, used to prevent huge log files from
-# causing a slow startup time.
-# regex
-# preconfigured regular expression pattern, up to five will be loaded
-
-features.log.showDuplicateEntries false
-features.log.prepopulate true
-features.log.prepopulateReadLimit 5000
-#features.log.regex My First Regex Pattern
-#features.log.regex ^My Second Regex Pattern$
-
-features.maxLineWrap 8
-
-# Paremters for the config panel
-# ---------------------------
-# order
-# three comma separated configuration attributes, options including:
+data_directory ~/.nyx # Caching location, can be set to 'disabled'.
+tor_chroot /path # Chroot jail tor resides within if there is one.
+show_bytes false # Bandwidth rate as bytes if true, bits otherwise.
+confirm_quit true # Confirm before quitting.
+color_interface true # Uses color in our interface.
+color_override none # Replaces instances of color with this hue.
+unicode_support true # Render text as unicode.
+acs_support true # Uses ACS (alternate character set) for nice borders.
+
+redraw_rate 5 # Seconds to await user input before redrawing.
+connection_rate 5 # Seconds between querying connections.
+resource_rate 5 # Seconds between querying process resource usage.
+port_usage_rate 5 # Seconds between querying processes using ports.
+
+logged_events events # Events that are shown by default in the log. [1]
+deduplicate_log true # Hides duplicate log messages.
+prepopulate_log true # Populates with events that occure before we started.
+logging_filter pattern # Regex filter for log messages that are shown.
+write_logs_to /path # Writes events that occure while running here.
+max_log_size 1000 # Maximum number of log entries.
+
+graph_stat bandwidth # Statistic to be graphed. [2]
+graph_interval each second # Graph sampling interval. [3]
+graph_bound max_local # Bounding for the graph min and max. [4]
+graph_height 7 # Height of the graph.
+max_graph_width 300 # Maximum number of samplings.
+
+config_order order # Order for tor config options. [5]
+show_private_options false # Shows configurations with a '__option' prefix.
+show_virtual_options false # Shows unsettable tor configurations.
+
+connection_order order # Order for connections. [6]
+resolve_processes true # Shows processes for SOCKS and CONTROL connections.
+show_addresses true # Shows addresses of connections.
+
+show_graph true # Shows the graph.
+show_accounting true # Shows accounting stats if AccountingMax is set.
+show_log true # Shows the event log.
+show_connections true # Shows connection information.
+show_config true # Shows tor's configuration.
+show_torrc true # Shows the torrc.
+show_interpreter true # Shows the control interpreter.
+
+# [1] logged_events is a comma separated list. Default value is...
#
-# * NAME
-# * VALUE
-# * VALUE_TYPE
-# * CATEGORY
-# * USAGE
-# * SUMMARY
-# * DESCRIPTION
-# * MAN_PAGE_ENTRY
-# * IS_SET
+# NOTICE, WARN, ERR, NYX_NOTICE, NYX_WARNING, NYX_ERROR
#
-# state.showPrivateOptions
-# tor provides config options of the form "__<option>" that can be dangerous
-# to set, if true nyx provides these on the config panel
-# state.showVirtualOptions
-# virtual options are placeholders for other option groups, never having
-# values or being setable themselves
-# file.maxLinesPerEntry
-# max number of lines to display for a single entry in the torrc
-
-features.config.order MAN_PAGE_ENTRY, NAME, IS_SET
-features.config.state.showPrivateOptions false
-features.config.state.showVirtualOptions false
-features.config.file.maxLinesPerEntry 8
-
-# General graph parameters
-# ------------------------
-# height
-# height of graphed stats
-# maxWidth
-# maximum number of graphed entries
-# interval
-# each second, 5 seconds, 30 seconds, minutely,
-# 15 minute, 30 minute, hourly, daily
-# bound
-# global_max - global maximum (highest value ever seen)
-# local_max - local maximum (highest value currently on the graph)
-# tight - local maximum and minimum
-# type
-# none, bandwidth, connections, resources
-
-features.graph.height 7
-features.graph.maxWidth 150
-features.graph.interval each second
-features.graph.bound local_max
-features.graph.type bandwidth
-
-# Parameters for graphing bandwidth stats
-# ---------------------------------------
-# prepopulate
-# attempts to use tor's state file to prepopulate the bandwidth graph at the
-# 15-minute interval (this requires the minimum of a day's worth of uptime)
-# transferInBytes
-# shows rate measurments in bytes if true, bits otherwise
-# accounting.show
-# provides accounting stats if AccountingMax was set
-
-features.graph.bw.transferInBytes false
-features.graph.bw.accounting.show true
-
-# Parameters for connection display
-# ---------------------------------
-# order
-# three comma separated configuration attributes, options including:
+# [2] graph_stat options include...
#
-# * CATEGORY
-# * UPTIME
-# * IP_ADDRESS
-# * PORT
-# * FINGERPRINT
-# * NICKNAME
-# * COUNTRY
+# none - hide the graph
+# bandwidth - bandwidth rate downloaded/uploaded
+# connections- number of connections inbound/outbound
+# resources - cpu/memory usage of tor
#
-# resolveApps
-# issues lsof queries to determining the applications involved in local
-# SOCKS and CONTROL connections
-# showIps
-# shows ip addresses for other tor relays, dropping this information if
-# false
-
-features.connection.order CATEGORY, IP_ADDRESS, UPTIME
-features.connection.resolveApps true
-features.connection.showIps true
-
-# Caching parameters
-cache.logPanel.size 1000
-cache.nyxLog.size 1000
-cache.nyxLog.trimSize 200
-
+# [3] graph_interval options include...
+#
+# each second, 5 seconds, 30 seconds, minutely,
+# 15 minute, 30 minute, hourly, daily
+#
+# [4] graph_bound options include...
+#
+# global_max - global maximum (highest value ever seen)
+# local_max - local maximum (highest value currently on the graph)
+# tight - local maximum and minimum
+#
+# [5] config_order is three comma separated values that can include...
+#
+# * NAME
+# * VALUE
+# * VALUE_TYPE
+# * CATEGORY
+# * USAGE
+# * SUMMARY
+# * DESCRIPTION
+# * MAN_PAGE_ENTRY
+# * IS_SET
+#
+# Default is: MAN_PAGE_ENTRY, NAME, IS_SET
+#
+# [6] connection_order is three comma separated values that can include...
+#
+# * CATEGORY
+# * UPTIME
+# * IP_ADDRESS
+# * PORT
+# * FINGERPRINT
+# * NICKNAME
+# * COUNTRY
+#
+# Default is: CATEGORY, IP_ADDRESS, UPTIME
diff --git a/test/__init__.py b/test/__init__.py
index 6e534e1..6e3ade3 100644
--- a/test/__init__.py
+++ b/test/__init__.py
@@ -115,11 +115,11 @@ class TestBaseUtil(unittest.TestCase):
self.assertEqual('/absolute/path/to/torrc', expand_path('/absolute/path/to/torrc'))
self.assertEqual('/your_cwd/torrc', expand_path('torrc'))
- config.set('tor.chroot', '/chroot')
+ config.set('tor_chroot', '/chroot')
self.assertEqual('/chroot/absolute/path/to/torrc', expand_path('/absolute/path/to/torrc'))
self.assertEqual('/chroot/your_cwd/torrc', expand_path('torrc'))
- config.set('tor.chroot', None)
+ config.set('tor_chroot', None)
def test_join(self):
# check our pydoc examples