mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
tor: Minor improvements
- Minimize loading of Augeas since it takes time. - Make some methods private - PEP8 fixes
This commit is contained in:
1 parent
2afae80dd8
commit
70001c841f
4 files changed
+55
-52
No files matched your search
@@ -77,7 +77,7 @@ def init():
|
||||
hostname = status['hs_hostname']
|
||||
hs_virtports = [port['virtport'] for port in status['hs_ports']]
|
||||
|
||||
if utils.is_enabled() and utils.is_running() and \
|
||||
if status['enabled'] and status['is_running'] and \
|
||||
status['hs_enabled'] and status['hs_hostname']:
|
||||
hs_services = []
|
||||
for service_type in SERVICES:
|
||||
@@ -120,7 +120,6 @@ def update_hidden_service_domain(status=None):
|
||||
services=status['hs_services'])
|
||||
|
||||
|
||||
|
||||
def diagnose():
|
||||
"""Run diagnostics and return the results."""
|
||||
results = []
|
||||
|
||||
@@ -94,34 +94,34 @@
|
||||
</form>
|
||||
|
||||
{% if status.relay_enabled %}
|
||||
<h3>{% trans "Bridge Relay" %}</h3>
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
If your {{ box_name }} is behind a router or firewall, you should
|
||||
make sure the following ports are open, and port-forwarded, if
|
||||
necessary:
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<table class="table table-bordered table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Service" %}</th>
|
||||
<th>{% trans "Port" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for name, port in status.ports.items %}
|
||||
<h3>{% trans "Bridge Relay" %}</h3>
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
If your {{ box_name }} is behind a router or firewall, you should
|
||||
make sure the following ports are open, and port-forwarded, if
|
||||
necessary:
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<table class="table table-bordered table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{{ name }}</td>
|
||||
<td>{{ port }}</td>
|
||||
<th>{% trans "Service" %}</th>
|
||||
<th>{% trans "Port" %}</th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for name, port in status.ports.items %}
|
||||
<tr>
|
||||
<td>{{ name }}</td>
|
||||
<td>{{ port }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<h3>{% trans "SOCKS" %}</h3>
|
||||
|
||||
@@ -48,7 +48,6 @@ def get_status():
|
||||
"""Return current Tor status."""
|
||||
output = actions.superuser_run('tor', ['get-status'])
|
||||
status = json.loads(output)
|
||||
ports = status['ports']
|
||||
|
||||
hs_info = status['hidden_service']
|
||||
hs_services = []
|
||||
@@ -60,21 +59,21 @@ def get_status():
|
||||
return {'enabled': is_enabled(),
|
||||
'is_running': is_running(),
|
||||
'relay_enabled': status['relay_enabled'],
|
||||
'ports': ports,
|
||||
'ports': status['ports'],
|
||||
'hs_enabled': hs_info['enabled'],
|
||||
'hs_status': hs_info['status'],
|
||||
'hs_hostname': hs_info['hostname'],
|
||||
'hs_ports': hs_info['ports'],
|
||||
'hs_services': hs_services,
|
||||
'apt_transport_tor_enabled': \
|
||||
_is_apt_transport_tor_enabled()
|
||||
'apt_transport_tor_enabled':
|
||||
_is_apt_transport_tor_enabled()
|
||||
}
|
||||
|
||||
|
||||
def iter_apt_uris(aug):
|
||||
"""Iterate over all the APT source URIs."""
|
||||
return itertools.chain.from_iterable([aug.match(path) for \
|
||||
path in APT_SOURCES_URI_PATHS])
|
||||
return itertools.chain.from_iterable([aug.match(path)
|
||||
for path in APT_SOURCES_URI_PATHS])
|
||||
|
||||
|
||||
def get_real_apt_uri_path(aug, path):
|
||||
@@ -104,7 +103,8 @@ def get_augeas():
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug.set('/augeas/load/Aptsources/lens', 'Aptsources.lns')
|
||||
aug.set('/augeas/load/Aptsources/incl[last() + 1]', '/etc/apt/sources.list')
|
||||
aug.set('/augeas/load/Aptsources/incl[last() + 1]',
|
||||
'/etc/apt/sources.list')
|
||||
aug.set('/augeas/load/Aptsources/incl[last() + 1]',
|
||||
'/etc/apt/sources.list.d/*.list')
|
||||
aug.load()
|
||||
|
||||
Reference in new issue
Block a user