<% import psutil cpu_count = psutil.cpu_count() # template_directory = get('template_directory') import socket host_name = socket.gethostname() from tob_template_tools import * import datetime # from stem.version import Version # in_version = get('version', "0.0.0.0-NoVersion") # x_version = Version(in_version) # short_version = ("{}.{}.{}.{}").format(x_version.major, x_version.minor, x_version.micro, x_version.patch)--> tor_info = get('tor_info') # This is Copy/Paste from ARM! # see dir-spec.txt for description of FLAGS FLAG_LABELS = {"Authority": "default", "BadExit": "danger", "BadDirectory": "danger", "Exit": "warning", "Fast": "primary", "Guard": "primary", "HSDir": "info", "Named": "primary", "Stable": "primary", "Running": "success", "Unnamed": "warning", "Valid": "success", "V2Dir": "default", "V3Dir": "default"} FLAG_COLORS = {"Authority": "black", "BadExit": "red", "BadDirectory": "red", "Exit": "orange", "Fast": "blue", "Guard": "blue", "HSDir": "deepskyblue", "Named": "blue", "Stable": "blue", "Running": "green", "Unnamed": "red", "Valid": "green", "V2Dir": "black", "V3Dir": "black", "Tor Communication Error": "red"} VERSION_STATUS_COLORS = {"new": "blue", "new in series": "blue", "obsolete": "red", "recommended": "green", "old": "red", "unrecommended": "red", "unknown": "cyan"} box_bold_grid = 'col-xs-3 col-md-2 box_bold' box_section_grid = 'col-xs-8 col-md-9 box_section' box_datum_grid = 'col-xs-3 col-md-2 box_datum' box_value_grid = 'col-xs-8 col-md-9 box_value' box_title_grid = 'col-xs-8 col-md-9 box_title' box_subtitle_grid = 'col-xs-8 col-md-9 box_subtitle' def standard_row(datum, value): out = "
" out += "
{}
".format(box_datum_grid, datum) out += "

{}

".format(box_value_grid, value) out += "
" out += "
" return out end def header_row(bold, section, target): out = "
".format(target) out += "
{}
".format(box_bold_grid, bold) out += "

{}

".format(box_section_grid, section) out += "
" out += "
" return out end %> The Onion Box % include('css/box.css')
The Onion Box

{{!"Tor {} @ {}
{}".format(tor_info['tor/version/short'], host_name, tor_info['tor/fingerprint'])}}


{{!header_row('HOST', 'General Information', 'host')}} {{!standard_row('Name', tor_info['host/name'])}} {{!standard_row('OS', "{} {} (Version: {})".format(tor_info['host/system'], tor_info['host/release'], tor_info['host/version']))}} {{!standard_row('System', "{} {}".format(tor_info['host/processor'], tor_info['host/machine']))}}
CPU Usage
% for count in range(cpu_count):
% end
{{!standard_row('Memory', "{} MB".format(tor_info['host/memory/MB']))}}
Memory Usage

{{!header_row('Tor', 'System Settings', 'tor')}}

Nickname

% nn = tor_info['tor/nickname'] % if nn=="Unnamed":

( {{nn}} )

% else:

{{nn}}

% end

Fingerprint

Version

{{tor_info['tor/version']}} % tvc = tor_info['tor/version/current'] % if tvc in VERSION_STATUS_COLORS: {{tvc}} % end

% if tor_info['tor/orListenAddress']: {{!standard_row('Address', "{}:{}".format(tor_info['tor/orListenAddress'], tor_info['tor/orPort']))}} % else: {{!standard_row('Address', "{}:{}".format(tor_info['tor/address'], tor_info['tor/orPort']))}} % end % if tor_info['tor/dirPort'] != 0: {{!standard_row('DirPort', tor_info['tor/dirPort'])}} % end % if tor_info['tor/controlPort'] == "0": {{!standard_row('Control Socket', tor_info['tor/controlSocket'])}} % else:

Control Port

<% _cat_color = {"open": "black", "Password": "green", "Cookie": "blue"} _cat = "open" if tor_info['tor/isAuthPassword']: _cat = "Password" elif tor_info['tor/isAuthCookie']: _cat = "Cookie" end %> {{tor_info['tor/controlPort']}} {{_cat}}

% end

Flags

<% fs = '' for flag in tor_info['tor/flags']: if fs is not '': fs += ' ' end fs += '' + flag + '' end %> {{!fs}}

Exit Policy

<% _ep = "" for ep in tor_info['tor/exitPolicies']: if _ep is not '': _ep += ' | ' end _ep += ep end %> {{_ep}}


{{!header_row('Tor', 'Bandwidth', 'bandwidth')}}

Charts

Download

Total: 0 Bytes | Current: 0 Bytes/s

Upload

Total: 0 Bytes | Current: 0 Bytes/s


{{!header_row('Tor', 'Accounting', 'accounting')}} % accounting_on = get('accounting_on') % if accounting_on == False:

Status

disabled

% else: % accounting_stats = get('accounting_stats')

Status

{{accounting_stats.status}}

{{!standard_row('Download', "{} (Max: {})".format(pretty_number(accounting_stats.read_bytes, '', 'si'), pretty_number(accounting_stats.read_limit, '', 'si')))}} {{!standard_row('Upload', "{} (Max: {})".format(pretty_number(accounting_stats.written_bytes, '', 'si'), pretty_number(accounting_stats.write_limit, '', 'si')))}} {{!standard_row('Time to Reset', datetime.timedelta(seconds=accounting_stats.time_until_reset))}} % end
{{!header_row('Tor', 'Messages', 'messages')}}

Level

Messages

%# {{!preserved_events}}

% include('scripts/box.js')