Fix websocket url in docker container.

This commit is contained in:
tecnovert
2024-10-18 15:08:20 +02:00
parent 1eca1b60ab
commit 5e71367c21
3 changed files with 11 additions and 10 deletions

View File

@@ -312,6 +312,7 @@ def runClient(fp, data_dir, chain, start_only_coins):
swap_client.log.info(f'Starting ws server at {ws_url}.') swap_client.log.info(f'Starting ws server at {ws_url}.')
swap_client.ws_server = WebsocketServer(host=settings['wshost'], port=settings['wsport']) swap_client.ws_server = WebsocketServer(host=settings['wshost'], port=settings['wsport'])
swap_client.ws_server.client_port = settings.get('wsclientport', settings['wsport'])
swap_client.ws_server.set_fn_new_client(ws_new_client) swap_client.ws_server.set_fn_new_client(ws_new_client)
swap_client.ws_server.set_fn_client_left(ws_client_left) swap_client.ws_server.set_fn_client_left(ws_client_left)
swap_client.ws_server.set_fn_message_received(ws_message_received) swap_client.ws_server.set_fn_message_received(ws_message_received)

View File

@@ -135,7 +135,7 @@ class HttpHandler(BaseHTTPRequestHandler):
def render_template(self, template, args_dict, status_code=200, version=__version__): def render_template(self, template, args_dict, status_code=200, version=__version__):
swap_client = self.server.swap_client swap_client = self.server.swap_client
if swap_client.ws_server: if swap_client.ws_server:
args_dict['ws_url'] = swap_client.ws_server.url args_dict['ws_port'] = swap_client.ws_server.client_port
if swap_client.debug: if swap_client.debug:
args_dict['debug_mode'] = True args_dict['debug_mode'] = True
if swap_client.debug_ui: if swap_client.debug_ui:

View File

@@ -97,7 +97,7 @@ document.addEventListener('DOMContentLoaded', function() {
function updateShutdownButtons() { function updateShutdownButtons() {
const activeSwaps = parseInt(shutdownButtons[0].getAttribute('data-active-swaps') || '0'); const activeSwaps = parseInt(shutdownButtons[0].getAttribute('data-active-swaps') || '0');
shutdownButtons.forEach(button => { shutdownButtons.forEach(button => {
if (activeSwaps > 0) { if (activeSwaps > 0) {
button.classList.add('shutdown-disabled'); button.classList.add('shutdown-disabled');
@@ -199,7 +199,7 @@ document.addEventListener('DOMContentLoaded', function() {
<li> <li>
<a href="/changepassword" class="flex items-center block py-4 px-4 hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white"> <span class="sr-only">Change/Set Password</span> <a href="/changepassword" class="flex items-center block py-4 px-4 hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white"> <span class="sr-only">Change/Set Password</span>
{{ change_password_svg | safe }} Change/Set Password</a> {{ change_password_svg | safe }} Change/Set Password</a>
</li> </li>
{% if debug_mode == true %} {% if debug_mode == true %}
<li> <li>
<a href="/rpc" class="flex items-center block py-4 px-4 hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white"> <span class="sr-only">RPC</span> <a href="/rpc" class="flex items-center block py-4 px-4 hover:bg-gray-100 dark:hover:bg-gray-700 dark:text-white"> <span class="sr-only">RPC</span>
@@ -242,14 +242,14 @@ document.addEventListener('DOMContentLoaded', function() {
{% endif %} {% endif %}
</ul> </ul>
<div class="text-sm text-gray-700"> <div class="text-sm text-gray-700">
<a href="/shutdown/{{ shutdown_token }}" <a href="/shutdown/{{ shutdown_token }}"
class="shutdown-button flex items-center block py-4 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white" class="shutdown-button flex items-center block py-4 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white"
data-active-swaps="{{ summary.num_swapping }}"> data-active-swaps="{{ summary.num_swapping }}">
{{ shutdown_svg | safe }} {{ shutdown_svg | safe }}
<span class="ml-2">Shutdown</span> <span class="ml-2">Shutdown</span>
</a> </a>
</div> </div>
</div> </div>
<div id="shutdownModal" tabindex="-1" class="hidden fixed inset-0 z-50 overflow-y-auto overflow-x-hidden"> <div id="shutdownModal" tabindex="-1" class="hidden fixed inset-0 z-50 overflow-y-auto overflow-x-hidden">
<div class="fixed inset-0 bg-black bg-opacity-60 transition-opacity"></div> <div class="fixed inset-0 bg-black bg-opacity-60 transition-opacity"></div>
@@ -363,13 +363,13 @@ document.addEventListener('DOMContentLoaded', function() {
<p><b>Debug mode:</b> Active</p> <p><b>Debug mode:</b> Active</p>
{% if debug_ui_mode == true %} {% if debug_ui_mode == true %}
<p><b>Debug UI mode:</b> Active</p> <p><b>Debug UI mode:</b> Active</p>
{% endif %} {% endif %}
</div> </div>
</li> </li>
</ul> </ul>
<!-- dev mode icons on/off --> <!-- dev mode icons on/off -->
{% endif %} {% endif %}
{% if encrypted == true %} {% if encrypted == true %}
<ul class="xl:flex"><li> <ul class="xl:flex"><li>
{% if locked == true %} {% if locked == true %}
@@ -598,7 +598,7 @@ document.addEventListener('DOMContentLoaded', function() {
{% endif %} {% endif %}
</ul> </ul>
<div class="pt-8 text-sm font-medium"> <div class="pt-8 text-sm font-medium">
<a href="/shutdown/{{ shutdown_token }}" <a href="/shutdown/{{ shutdown_token }}"
class="shutdown-button flex items-center block py-4 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white" class="shutdown-button flex items-center block py-4 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white"
data-active-swaps="{{ summary.num_swapping }}"> data-active-swaps="{{ summary.num_swapping }}">
{{ shutdown_svg | safe }} {{ shutdown_svg | safe }}
@@ -611,7 +611,7 @@ document.addEventListener('DOMContentLoaded', function() {
<!-- mobile sidebar --> <!-- mobile sidebar -->
</section> </section>
{% if ws_url %} {% if ws_port %}
<script> <script>
// Configuration object // Configuration object
const notificationConfig = { const notificationConfig = {
@@ -620,7 +620,7 @@ const notificationConfig = {
showBidAccepted: true showBidAccepted: true
}; };
var ws = new WebSocket("{{ ws_url }}"), var ws = new WebSocket("ws://" + window.location.hostname + ":{{ ws_port }}"),
floating_div = document.createElement('div'); floating_div = document.createElement('div');
floating_div.classList.add('floatright'); floating_div.classList.add('floatright');
messages = document.createElement('ul'); messages = document.createElement('ul');