%
# 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!
# from tob_template_tools import *
import psutil
cpu_count = psutil.cpu_count()
host = get('host')
tor = get('tor')
oo_factory = get('oo_factory')
family_fp = get('family_fp')
fam_details = oo_factory.details(family_fp)
# print(fam_details._document.document_data)
ef = fam_details('effective_family')
af = fam_details('alleged_family')
indf = fam_details('indirect_family')
fmatrix = {}
if ef or af or indf:
%>
{{!header_row('Tor', 'Family Performance', 'family')}}
<%
#
#
%>
<%
fmatrix = {'Effective': ef, 'Alleged': af, 'Indirect': indf}
for key, family_nodes in fmatrix.items():
if family_nodes is not None:
nodes = {}
unnamed_counter = 0
error_counter = 0
for fp in family_nodes:
# // onionoo protocol v5.0 (fp[0] === '$' removed) adaptation
fp = fp[1:] if fp[0] is '$' else fp
try:
# // test for valid fingerprint (hex chars only)
int(fp,16)
# // ok; final test
if len(fp) != 40:
raise ValueError
end
# // this seems to be a valid fingerprint
node_det = oo_factory.details(fp[1:])
if node_det is not None:
if node_det.is_unknown():
nn = 'unnamed'
else:
nn = node_det('nickname')
if nn is None or nn == '':
nn = 'unnamed'
end
end
if nn.lower() == 'unnamed':
nn = '_{}'.format(unnamed_counter)
unnamed_counter += 1
end
nodes[nn] = fp
end
except ValueError, TypeError:
# This is not a fingerprint
# but already a nickname!
nn = '!{}'.format(error_counter)
error_counter += 1
nodes[nn] = fp
end
end
# print(nodes)
for nn in sorted(nodes):
group_nn = ''
fp = ''
no_data = False
if nn[0] == '_':
group_nn = 'Unnamed'
fp = nodes[nn]
fp = fp[1:] if fp[0] is '$' else fp
elif nn[0] == '!':
group_nn = nodes[nn]
fp = None
not_found = True
else:
group_nn = nn
fp = nodes[nn]
fp = fp[1:] if fp[0] is '$' else fp
end
%>
{{!group_row(group_nn, color='black', bold=True, target='family_node_'+(fp if fp is not None else group_nn))}}
% if fp is not None:
{{!standard_row('Fingerprint', fp)}}
% end
% if fp and oo_factory.details(fp):
% flags = oo_factory.details(fp)('flags')
% if flags is not None and len(flags) > 0:
{{!standard_row('Flags', ' | '.join(flags))}}
% end
% end
% if fp:
% else:
This node is only known by nickname. Onionoo has not provided a fingerprint or other data. Most probably this is a configuration error.
To overcome you should provide consistent fingerprint entries in your torrc for all the relays in your family.
% end
% end
% end
% end
%end