diff --git a/src/kernel/network.cpp b/src/kernel/network.cpp index 26b37d1..f90cf17 100644 --- a/src/kernel/network.cpp +++ b/src/kernel/network.cpp @@ -13,7 +13,6 @@ void Network::sendDatagram(QJsonObject j, QString s) { QHostAddress ip = QHostAddress(s); QByteArray baDatagram; - //QDataStream out(&baDatagram, QIODevice::WriteOnly); QJsonDocument jbuff = QJsonDocument(j); quint16 p = 6552; baDatagram = jbuff.toJson(QJsonDocument::Compact); @@ -30,7 +29,15 @@ void Network::processTheDatagram() QJsonDocument jbuff = QJsonDocument::fromJson(baDatagram); QJsonObject j = QJsonObject(jbuff.object()); - //QDataStream in(&baDatagram, QIODevice::ReadOnly); - //in >> jbuff.fromBinaryData(baDatagram); emit json_received(j); } + +QString Network::local_ipv6() +{ + QHostAddress address; + foreach (address, QNetworkInterface::allAddresses()) { + if (address.protocol() == QAbstractSocket::IPv6Protocol && address != QHostAddress(QHostAddress::LocalHost)) + break; + } + return(address.toString()); +} diff --git a/src/kernel/network.hpp b/src/kernel/network.hpp index 5eb40bb..6b0679f 100644 --- a/src/kernel/network.hpp +++ b/src/kernel/network.hpp @@ -3,6 +3,7 @@ #include #include #include +#include class Network : public QObject { @@ -12,6 +13,7 @@ class Network : public QObject QUdpSocket* udpSocket; public: Network(bool is_server = true); + static QString local_ipv6(); public slots: void sendDatagram(QJsonObject j, QString s); signals: