aboutsummaryrefslogtreecommitdiff
path: root/src/widgets/direct_connect_dialog.cpp
diff options
context:
space:
mode:
authorOsmium Sorcerer <os@sof.beauty>2026-03-22 17:57:13 +0000
committerOsmium Sorcerer <os@sof.beauty>2026-03-29 22:22:25 +0000
commit79c2262cae02b513aee70943f7e07a9205316bdf (patch)
tree02efb824bad180a11bd1b68c41508088c167434b /src/widgets/direct_connect_dialog.cpp
parent06f34c776972542222623ca4f91880de97993fbf (diff)
Support Secure WebSocket
Add full WSS support to public server list (using wss_port, overriding insecure port), favorite servers list, and direct connections, and show which servers are secure. Revert the upstream's removal of `legacy` ServerInfo field, as I use it to filter out legacy servers. To differentiate schemes, the `scheme` field is used, either "ws" or "wss". I don't see the reason to add "tcp" protocol when we don't even support it. For the UI, add icons for secure and insecure connections. Highlight secure servers with a green background. In the favorite server dialog, a checkbox was added to select whether the server is using WSS. In the direct connection dialog, support "wss" scheme and default ports: 80 for WS, 443 for WSS, as per the WebSocket specification.
Diffstat (limited to 'src/widgets/direct_connect_dialog.cpp')
-rw-r--r--src/widgets/direct_connect_dialog.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/widgets/direct_connect_dialog.cpp b/src/widgets/direct_connect_dialog.cpp
index f8c77b85..9859889d 100644
--- a/src/widgets/direct_connect_dialog.cpp
+++ b/src/widgets/direct_connect_dialog.cpp
@@ -51,7 +51,7 @@ void DirectConnectDialog::onConnectPressed()
QString l_hostname = ui_direct_hostname_edit->text();
if (!SCHEME_PATTERN.match(l_hostname).hasMatch())
{
- l_hostname = "ws://" % l_hostname;
+ l_hostname = "wss://" % l_hostname;
}
QUrl l_url(l_hostname);
@@ -61,20 +61,21 @@ void DirectConnectDialog::onConnectPressed()
return;
}
- if (l_url.scheme() != "ws")
+ if (l_url.scheme() != "ws" && l_url.scheme() != "wss")
{
- call_error(tr("Invalid URL scheme. Only ws:// is supported."));
+ call_error(tr("Invalid URL scheme. Only ws: and wss: are supported."));
return;
}
- if (l_url.port() == -1)
+ int port = l_url.port();
+ if (port == -1)
{
- call_error(tr("Invalid server port."));
- return;
+ port = (l_url.scheme() == "wss") ? 443 : 80;
}
ServerInfo l_server;
l_server.address = l_url.host();
- l_server.port = l_url.port();
+ l_server.port = port;
+ l_server.scheme = l_url.scheme();
l_server.name = "Direct Connection";
net_manager->connect_to_server(l_server);