mirror of
https://github.com/ChronosX88/Influence-cjdns.git
synced 2024-11-23 07:32:19 +00:00
Added a function that recognizes your IPv6.
This commit is contained in:
parent
d557b16c6a
commit
fd20de0e38
@ -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());
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <QtNetwork>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QNetworkInterface>
|
||||
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user