ui: Fix shutdown link.

This commit is contained in:
tecnovert 2022-11-14 22:56:30 +02:00
parent 8022ada01f
commit 5d4db2c1df
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
2 changed files with 6 additions and 7 deletions

View File

@ -131,7 +131,6 @@ class HttpHandler(BaseHTTPRequestHandler):
if swap_client._show_notifications: if swap_client._show_notifications:
args_dict['notifications'] = swap_client.getNotifications() args_dict['notifications'] = swap_client.getNotifications()
# TODO: Remove _withids
if 'messages' in args_dict: if 'messages' in args_dict:
messages_with_ids = [] messages_with_ids = []
for msg in args_dict['messages']: for msg in args_dict['messages']:
@ -145,6 +144,10 @@ class HttpHandler(BaseHTTPRequestHandler):
self.server.msg_id_counter += 1 self.server.msg_id_counter += 1
args_dict['err_messages'] = err_messages_with_ids args_dict['err_messages'] = err_messages_with_ids
shutdown_token = os.urandom(8).hex()
self.server.session_tokens['shutdown'] = shutdown_token
args_dict['shutdown_token'] = shutdown_token
if self.server.msg_id_counter >= 0x7FFFFFFF: if self.server.msg_id_counter >= 0x7FFFFFFF:
self.server.msg_id_counter = 0 self.server.msg_id_counter = 0
@ -486,16 +489,12 @@ class HttpHandler(BaseHTTPRequestHandler):
swap_client.checkSystemStatus() swap_client.checkSystemStatus()
summary = swap_client.getSummary() summary = swap_client.getSummary()
shutdown_token = os.urandom(8).hex()
self.server.session_tokens['shutdown'] = shutdown_token
template = env.get_template('index.html') template = env.get_template('index.html')
return self.render_template(template, { return self.render_template(template, {
'refresh': 30, 'refresh': 30,
'version': __version__, 'version': __version__,
'summary': summary, 'summary': summary,
'use_tor_proxy': swap_client.use_tor_proxy, 'use_tor_proxy': swap_client.use_tor_proxy
'shutdown_token': shutdown_token
}) })
def page_404(self, url_split): def page_404(self, url_split):

View File

@ -162,7 +162,7 @@ class Test(BaseTest):
rate_swap = make_int(random.uniform(0.2, 20.0), scale=12, r=1) rate_swap = make_int(random.uniform(0.2, 20.0), scale=12, r=1)
offer_id = swap_clients[0].postOffer( offer_id = swap_clients[0].postOffer(
Coins.PART_BLIND, Coins.XMR, amt_swap, rate_swap, amt_swap, SwapTypes.XMR_SWAP, Coins.PART_BLIND, Coins.XMR, amt_swap, rate_swap, amt_swap, SwapTypes.XMR_SWAP,
lock_type=TxLockTypes.SEQUENCE_LOCK_BLOCKS, lock_value=12) lock_type=TxLockTypes.SEQUENCE_LOCK_BLOCKS, lock_value=32)
wait_for_offer(test_delay_event, swap_clients[1], offer_id) wait_for_offer(test_delay_event, swap_clients[1], offer_id)
offer = swap_clients[1].getOffer(offer_id) offer = swap_clients[1].getOffer(offer_id)