mirror of
https://github.com/basicswap/basicswap.git
synced 2025-01-18 16:44:34 +00:00
ui: Add tor info to page header
This commit is contained in:
parent
7319d46988
commit
af766876a1
3 changed files with 32 additions and 7 deletions
|
@ -45,7 +45,7 @@ from .ui.page_automation import (
|
||||||
)
|
)
|
||||||
from .ui.page_bids import page_bids, page_bid
|
from .ui.page_bids import page_bids, page_bid
|
||||||
from .ui.page_offers import page_offers, page_offer, page_newoffer
|
from .ui.page_offers import page_offers, page_offer, page_newoffer
|
||||||
from .ui.page_tor import page_tor
|
from .ui.page_tor import page_tor, get_tor_established_state
|
||||||
from .ui.page_wallet import page_wallets, page_wallet
|
from .ui.page_wallet import page_wallets, page_wallet
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,6 +107,15 @@ class HttpHandler(BaseHTTPRequestHandler):
|
||||||
args_dict['debug_mode'] = True
|
args_dict['debug_mode'] = True
|
||||||
if swap_client.debug_ui:
|
if swap_client.debug_ui:
|
||||||
args_dict['debug_ui_mode'] = True
|
args_dict['debug_ui_mode'] = True
|
||||||
|
if swap_client.use_tor_proxy:
|
||||||
|
args_dict['use_tor_proxy'] = True
|
||||||
|
# TODO: Cache value?
|
||||||
|
try:
|
||||||
|
args_dict['tor_established'] = True if get_tor_established_state(swap_client) == '1' else False
|
||||||
|
except Exception:
|
||||||
|
if swap_client.debug:
|
||||||
|
swap_client.log.error(traceback.format_exc())
|
||||||
|
|
||||||
return bytes(template.render(
|
return bytes(template.render(
|
||||||
title=self.server.title,
|
title=self.server.title,
|
||||||
h2=self.server.title,
|
h2=self.server.title,
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
{% if debug_ui_mode == true %}
|
{% if debug_ui_mode == true %}
|
||||||
<p>Debug UI mode: Active</p>
|
<p>Debug UI mode: Active</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if use_tor_proxy == true %}
|
||||||
|
<p>Tor mode: Active{% if tor_established == true %}, Connected{% endif %}</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if ws_url %}
|
{% if ws_url %}
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -16,20 +16,33 @@ def extract_data(bytes_in):
|
||||||
return str_in[start: end]
|
return str_in[start: end]
|
||||||
|
|
||||||
|
|
||||||
|
def get_tor_established_state(swap_client):
|
||||||
|
rv = swap_client.torControl('GETINFO status/circuit-established')
|
||||||
|
return extract_data(rv)
|
||||||
|
|
||||||
|
|
||||||
def page_tor(self, url_split, post_string):
|
def page_tor(self, url_split, post_string):
|
||||||
|
|
||||||
swap_client = self.server.swap_client
|
swap_client = self.server.swap_client
|
||||||
|
|
||||||
page_data = {}
|
page_data = {}
|
||||||
|
|
||||||
rv = swap_client.torControl('GETINFO status/circuit-established')
|
try:
|
||||||
page_data['circuit_established'] = extract_data(rv)
|
page_data['circuit_established'] = get_tor_established_state(swap_client)
|
||||||
|
except Exception:
|
||||||
|
page_data['circuit_established'] = 'error'
|
||||||
|
|
||||||
|
try:
|
||||||
rv = swap_client.torControl('GETINFO traffic/read')
|
rv = swap_client.torControl('GETINFO traffic/read')
|
||||||
page_data['bytes_written'] = extract_data(rv)
|
page_data['bytes_written'] = extract_data(rv)
|
||||||
|
except Exception:
|
||||||
|
page_data['bytes_written'] = 'error'
|
||||||
|
|
||||||
|
try:
|
||||||
rv = swap_client.torControl('GETINFO traffic/written')
|
rv = swap_client.torControl('GETINFO traffic/written')
|
||||||
page_data['bytes_read'] = extract_data(rv)
|
page_data['bytes_read'] = extract_data(rv)
|
||||||
|
except Exception:
|
||||||
|
page_data['bytes_read'] = 'error'
|
||||||
|
|
||||||
messages = []
|
messages = []
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue