Notifications: correct IP address formatting

This commit is contained in:
Stéphane L 2017-09-08 00:23:17 +02:00
parent 3b0cf02574
commit c3346f9192
2 changed files with 8 additions and 6 deletions

View File

@ -386,10 +386,12 @@ void Utils::SysTrayNotify(QString &text,
}
QString Utils::FormatIPAddress(QHostAddress &addr) {
if (addr.protocol() == QAbstractSocket::IPv4Protocol)
QString v4addr = addr.toString().replace("::fff:", "");
return addr.toString();
QRegExp v4regex("(::ffff:)(((\\d).){3})", Qt::CaseInsensitive);
QString addrString = addr.toString();
if (addrString.contains(v4regex)) {
addrString = QHostAddress(addr.toIPv4Address()).toString();
}
return addrString;
}
const char* Utils::GetRecordingFolder() {

View File

@ -103,7 +103,7 @@ void WSServer::onNewConnection() {
QString msg = QString(obs_module_text("OBSWebsocket.ConnectNotify.ClientIP"))
+ QString(" ")
+ clientAddr.toString();
+ Utils::FormatIPAddress(clientAddr);
Utils::SysTrayNotify(msg,
QSystemTrayIcon::Information,
@ -138,7 +138,7 @@ void WSServer::onSocketDisconnected() {
QString msg = QString(obs_module_text("OBSWebsocket.ConnectNotify.ClientIP"))
+ QString(" ")
+ clientAddr.toString();
+ Utils::FormatIPAddress(clientAddr);
Utils::SysTrayNotify(msg,
QSystemTrayIcon::Information,