Websocket spectrum: decode special addresses when setting from string

This commit is contained in:
f4exb 2020-05-11 21:30:10 +02:00
parent 05d878fa82
commit 07be58b0fb
2 changed files with 12 additions and 1 deletions

View File

@ -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()));

View File

@ -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;