Websocket spectrum: decode special addresses when setting from string

pull/714/head
f4exb 2020-05-11 21:30:10 +02:00
rodzic 05d878fa82
commit 07be58b0fb
2 zmienionych plików z 12 dodań i 1 usunięć

Wyświetl plik

@ -90,6 +90,17 @@ void WSSpectrum::getPeers(QList<QHostAddress>& hosts, QList<quint16>& ports) con
}
}
void WSSpectrum::setListeningAddress(const QString& address)
{
if (address == "127.0.0.1") {
m_listeningAddress.setAddress(QHostAddress::LocalHost);
} else if (address == "0.0.0.0") {
m_listeningAddress.setAddress(QHostAddress::Any);
} else {
m_listeningAddress.setAddress(address);
}
}
QString WSSpectrum::getWebSocketIdentifier(QWebSocket *peer)
{
return QStringLiteral("%1:%2").arg(peer->peerAddress().toString(), QString::number(peer->peerPort()));

Wyświetl plik

@ -43,7 +43,7 @@ public:
void closeSocket();
bool socketOpened() const;
void getPeers(QList<QHostAddress>& hosts, QList<quint16>& ports) const;
void setListeningAddress(const QString& address) { m_listeningAddress.setAddress(address); }
void setListeningAddress(const QString& address);
void setPort(quint16 port) { m_port = port; }
QHostAddress getListeningAddress() const;
uint16_t getListeningPort() const;