% # Note that this file is not a valid *.html file! # It is intended to be a bottlepy - style template # used for the scripting part of TheOnionBox! import os configs_used = [] configs_all = [] try: # get all valid configuration names (only and drop attached information) config_names = tor.get_info('config/names') names_with_values = config_names.splitlines() config_params = {} for line in names_with_values: # print(line) config = line.split(' ') config_params[config[0]] = config[1] end except: pass end enable_print = False if enable_print is True: print(tor.get_info('config/defaults')) print('-----') print(tor.get_info('config/names')) print('-----') print(tor.get_info('config-text')) end %> {{!header_row('Tor', 'Configuration', 'config')}} <% import psutil cmd_line = [] if tor.is_localhost(): try: pid = tor.get_pid() p = psutil.Process(pid) cmd_line = p.cmdline() # This returns a list! except: pass end end if len(cmd_line) > 0: %>
# Commandline
<% out = '' for cmd in cmd_line: if len(out): out += ' ' end out += cmd end %> {{out}}
Configuration Files
torrc
{{!tor.get_info('config-file')}}
torrc.defaults
{{!tor.get_info('config-defaults-file')}}
{{group.title()}}
% if option[:2] != '__': # {{option}} % else: {{option}} % end
<%
pt = config_params[option] # pt => parameter-type
#optngrp = {'ControlPort': 'CONTROL',
# 'DirPort': 'DIR',
# 'ORPort': 'OR',
# 'SocksPort': 'SOCKS'}
values = []
#if option in optngrp:
# port_tuples = tor.get_listeners(optngrp[option], '')
# values = [prt[0] + ':' + str(prt[1]) for prt in port_tuples]
#end
if len(values) == 0:
values = configs_used[option]
end
%>
% if pt == 'Boolean':
{{values[0] == '1'}}
<%
elif pt == 'DataSize':
out = pretty_number(int(values[0]), calc = 'iec')
# These are options that use the 'DataSize' type
# yet define data without time reference (/s)
# Therefore: Don't add a '/s' when indicating this value!
datasize_no_s = {'AccountingMax', 'ConstrainedSockSize', 'MaxMemInQueues'}
if option not in datasize_no_s:
out += '/s'
end
%>
{{out}}
<%
elif pt == 'LineList':
sep = '
'
if option == 'ExitPolicy':
sep = ' | '
end
out = ''
for value in values:
if option in ['HashedControlPassword', '__HashedControlSessionPassword']:
value = value[:43] + '...' # no need to transmit this completely!
# value += '
Why is this value always truncated?'
end
if len(out) > 0:
out += sep
end
out += value
end
%>
{{!out}}
% elif len(pt) > 0:
% if values is not None and len(values) > 0:
{{values[0]}}
% else:
none
% end
% else:
Error
% end
Remark
Any configuration option not displayed above is set to its default value.