Skip to content

Commit 5dea040

Browse files
WSS support (#1114)
* add ssl scheme * use protocol * set port * remove last legacy entry
1 parent c92956d commit 5dea040

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

src/lobby.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ void Lobby::list_servers()
471471
QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_serverlist_tree);
472472
treeItem->setData(0, Qt::DisplayRole, i);
473473

474-
if (i_server.legacy)
474+
if (i_server.protocol == "tcp")
475475
{
476476
treeItem->setText(1, "(Legacy) " + i_server.name);
477477
treeItem->setBackground(0, Qt::darkRed);
@@ -504,7 +504,7 @@ void Lobby::list_favorites()
504504
QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_favorites_tree);
505505
treeItem->setData(0, Qt::DisplayRole, i);
506506

507-
if (i_server.legacy)
507+
if (i_server.protocol == "tcp")
508508
{
509509
treeItem->setText(1, "(Legacy) " + i_server.name);
510510
treeItem->setBackground(0, Qt::darkRed);

src/network/serverinfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ServerInfo
99
QString description;
1010
QString address;
1111
quint16 port = 0;
12-
bool legacy = false;
12+
QString protocol = "ws";
1313

1414
QString toString() const;
1515
};

src/network/websocketconnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void WebSocketConnection::connectToServer(const ServerInfo &server)
3232
disconnectFromServer();
3333

3434
QUrl url;
35-
url.setScheme("ws");
35+
url.setScheme(server.protocol);
3636
url.setHost(server.address);
3737
url.setPort(server.port);
3838

src/networkmanager.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,20 @@ void NetworkManager::ms_request_finished(QNetworkReply *reply)
6060
server.address = entry["ip"].toString();
6161
server.name = entry["name"].toString();
6262
server.description = entry["description"].toString(tr("No description provided."));
63-
if (entry.contains("ws_port"))
63+
if (entry.contains("wss_port"))
64+
{
65+
server.port = entry["wss_port"].toInt();
66+
server.protocol = "wss";
67+
}
68+
else if (entry.contains("ws_port"))
6469
{
6570
server.port = entry["ws_port"].toInt();
71+
server.protocol = "ws";
6672
}
6773
else
6874
{
6975
server.port = entry["port"].toInt();
70-
server.legacy = true;
76+
server.protocol = "tcp";
7177
}
7278

7379
if (server.port != 0)

src/options.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,11 +680,11 @@ QVector<ServerInfo> Options::favorites()
680680
f_server.description = favorite.value("desc", "No description").toString();
681681
if (favorite.contains("protocol"))
682682
{
683-
f_server.legacy = favorite.value("protocol").toString() == "tcp";
683+
f_server.protocol = favorite.value("protocol").toString();
684684
}
685685
else
686686
{
687-
f_server.legacy = favorite.value("legacy", false).toBool();
687+
f_server.protocol = "tcp";
688688
}
689689

690690
serverlist.append(std::move(f_server));
@@ -705,7 +705,7 @@ void Options::setFavorites(QVector<ServerInfo> value)
705705
favorite.setValue("address", fav_server.address);
706706
favorite.setValue("port", fav_server.port);
707707
favorite.setValue("desc", fav_server.description);
708-
favorite.setValue("legacy", fav_server.legacy);
708+
favorite.setValue("protocol", fav_server.protocol);
709709
favorite.endGroup();
710710
}
711711
favorite.sync();
@@ -726,7 +726,7 @@ void Options::addFavorite(ServerInfo server)
726726
favorite.setValue("address", server.address);
727727
favorite.setValue("port", server.port);
728728
favorite.setValue("desc", server.description);
729-
favorite.setValue("legacy", server.legacy);
729+
favorite.setValue("protocol", server.protocol);
730730
favorite.endGroup();
731731
favorite.sync();
732732
}
@@ -738,7 +738,7 @@ void Options::updateFavorite(ServerInfo server, int index)
738738
favorite.setValue("address", server.address);
739739
favorite.setValue("port", server.port);
740740
favorite.setValue("desc", server.description);
741-
favorite.setValue("legacy", server.legacy);
741+
favorite.setValue("protocol", server.protocol);
742742
favorite.endGroup();
743743
favorite.sync();
744744
}

0 commit comments

Comments
 (0)