diff --git a/data/ui/favorite_server_dialog.ui b/data/ui/favorite_server_dialog.ui
index b90514d..6352cf6 100644
--- a/data/ui/favorite_server_dialog.ui
+++ b/data/ui/favorite_server_dialog.ui
@@ -78,13 +78,27 @@
-
+
+
+ Secure Port:
+
+
+
+ -
+
+
+ 65535
+
+
+
+ -
Description:
- -
+
-
@@ -106,7 +120,7 @@
- -
+
-
QDialogButtonBox::Close|QDialogButtonBox::Save
diff --git a/src/network/serverinfo.h b/src/network/serverinfo.h
index 1f13e3e..41dd414 100644
--- a/src/network/serverinfo.h
+++ b/src/network/serverinfo.h
@@ -9,6 +9,7 @@ public:
QString description;
QString address;
quint16 port = 0;
+ quint16 secure_port = 0;
bool legacy = false;
QString toString() const;
diff --git a/src/network/websocketconnection.cpp b/src/network/websocketconnection.cpp
index 9d9183c..addc925 100644
--- a/src/network/websocketconnection.cpp
+++ b/src/network/websocketconnection.cpp
@@ -2,8 +2,9 @@
#include "aoapplication.h"
-#include
#include
+#include
+#include
WebSocketConnection::WebSocketConnection(AOApplication *ao_app, QObject *parent)
: QObject(parent)
@@ -31,15 +32,28 @@ void WebSocketConnection::connectToServer(const ServerInfo &server)
{
disconnectFromServer();
+ bool useWss = server.secure_port != 0;
+ QString scheme = useWss ? "wss" : "ws";
+ int port = useWss ? server.secure_port : server.port;
+
QUrl url;
- url.setScheme("ws");
+ url.setScheme(scheme);
url.setHost(server.address);
- url.setPort(server.port);
+ url.setPort(port);
QNetworkRequest req(url);
req.setHeader(QNetworkRequest::UserAgentHeader, QStringLiteral("AttorneyOnline/%1 (Desktop)").arg(ao_app->get_version_string()));
- m_socket->open(req);
+ qInfo().noquote() << "Connecting to WebSocket server at:" << url.toString();
+
+ // Set up SSL configuration if using wss
+ if (scheme == "wss") {
+ QSslConfiguration sslConf = QSslConfiguration::defaultConfiguration();
+ sslConf.setPeerVerifyMode(QSslSocket::VerifyNone);
+ m_socket->setSslConfiguration(sslConf);
+ }
+
+ m_socket->open(url);
}
void WebSocketConnection::disconnectFromServer()
@@ -94,4 +108,4 @@ void WebSocketConnection::onTextMessageReceived(QString message)
}
Q_EMIT receivedPacket(AOPacket(header, raw_content));
-}
+}
\ No newline at end of file
diff --git a/src/networkmanager.cpp b/src/networkmanager.cpp
index 2208c2f..9451546 100644
--- a/src/networkmanager.cpp
+++ b/src/networkmanager.cpp
@@ -71,6 +71,11 @@ void NetworkManager::ms_request_finished(QNetworkReply *reply)
server.legacy = true;
}
+ if (entry.contains("wss_port"))
+ {
+ server.secure_port = entry["wss_port"].toInt();
+ }
+
if (server.port != 0)
{
server_list.append(server);
diff --git a/src/options.cpp b/src/options.cpp
index caa559c..3178568 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -676,6 +676,7 @@ QVector Options::favorites()
favorite.beginGroup(group);
f_server.address = favorite.value("address", "127.0.0.1").toString();
f_server.port = favorite.value("port", 27016).toInt();
+ f_server.secure_port = favorite.value("secure_port", 0).toInt();
f_server.name = favorite.value("name", "Missing Name").toString();
f_server.description = favorite.value("desc", "No description").toString();
if (favorite.contains("protocol"))
@@ -704,6 +705,7 @@ void Options::setFavorites(QVector value)
favorite.setValue("name", fav_server.name);
favorite.setValue("address", fav_server.address);
favorite.setValue("port", fav_server.port);
+ favorite.setValue("secure_port", fav_server.secure_port);
favorite.setValue("desc", fav_server.description);
favorite.setValue("legacy", fav_server.legacy);
favorite.endGroup();
@@ -725,6 +727,7 @@ void Options::addFavorite(ServerInfo server)
favorite.setValue("name", server.name);
favorite.setValue("address", server.address);
favorite.setValue("port", server.port);
+ favorite.setValue("secure_port", server.secure_port);
favorite.setValue("desc", server.description);
favorite.setValue("legacy", server.legacy);
favorite.endGroup();
@@ -737,6 +740,7 @@ void Options::updateFavorite(ServerInfo server, int index)
favorite.setValue("name", server.name);
favorite.setValue("address", server.address);
favorite.setValue("port", server.port);
+ favorite.setValue("secure_port", server.secure_port);
favorite.setValue("desc", server.description);
favorite.setValue("legacy", server.legacy);
favorite.endGroup();
diff --git a/src/widgets/direct_connect_dialog.cpp b/src/widgets/direct_connect_dialog.cpp
index f8c77b8..deee7e8 100644
--- a/src/widgets/direct_connect_dialog.cpp
+++ b/src/widgets/direct_connect_dialog.cpp
@@ -61,9 +61,9 @@ 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:// is supported."));
return;
}
diff --git a/src/widgets/server_editor_dialog.cpp b/src/widgets/server_editor_dialog.cpp
index 03c8d6c..9217950 100644
--- a/src/widgets/server_editor_dialog.cpp
+++ b/src/widgets/server_editor_dialog.cpp
@@ -31,6 +31,7 @@ ServerEditorDialog::ServerEditorDialog(QWidget *parent)
FROM_UI(QLineEdit, name);
FROM_UI(QLineEdit, hostname);
FROM_UI(QSpinBox, port);
+ FROM_UI(QSpinBox, secure_port);
FROM_UI(QPlainTextEdit, description);
FROM_UI(QDialogButtonBox, button_box);
@@ -49,6 +50,7 @@ ServerEditorDialog::ServerEditorDialog(const ServerInfo &server, QWidget *parent
ui_name->setText(server.name);
ui_hostname->setText(server.address);
ui_port->setValue(server.port);
+ ui_secure_port->setValue(server.secure_port);
ui_description->setPlainText(server.description);
}
@@ -58,6 +60,7 @@ ServerInfo ServerEditorDialog::currentServerInfo() const
server.name = ui_name->text();
server.address = ui_hostname->text();
server.port = ui_port->value();
+ server.secure_port = ui_secure_port->value();
server.description = ui_description->toPlainText();
return server;
}
diff --git a/src/widgets/server_editor_dialog.h b/src/widgets/server_editor_dialog.h
index a8844d4..814ee08 100644
--- a/src/widgets/server_editor_dialog.h
+++ b/src/widgets/server_editor_dialog.h
@@ -29,6 +29,7 @@ private:
QLineEdit *ui_name;
QLineEdit *ui_hostname;
QSpinBox *ui_port;
+ QSpinBox *ui_secure_port;
QPlainTextEdit *ui_description;
QDialogButtonBox *ui_button_box;