disable IPv6

This commit is contained in:
Michael Zanetti 2018-09-28 01:28:58 +02:00
parent 7c30c66b43
commit cbb834b92c
9 changed files with 43 additions and 32 deletions

2
.gitmodules vendored
View File

@ -1,6 +1,6 @@
[submodule "QtZeroConf"] [submodule "QtZeroConf"]
path = QtZeroConf path = QtZeroConf
url = https://github.com/jbagg/QtZeroConf.git url = https://github.com/mzanetti/QtZeroConf.git
[submodule "nymea-remoteproxy"] [submodule "nymea-remoteproxy"]
path = nymea-remoteproxy path = nymea-remoteproxy
url = https://github.com/guh/nymea-remoteproxy.git url = https://github.com/guh/nymea-remoteproxy.git

@ -1 +1 @@
Subproject commit 31119114cec29b890bc755bed0272a208b7130bf Subproject commit 2990b858e6334fae4dd37a77c770336bd6e1b2d9

View File

@ -642,13 +642,13 @@ void AWSClient::registerPushNotificationEndpoint(const QString &registrationId,
payload.insert("mobileDeviceUuid", mobileDeviceId); payload.insert("mobileDeviceUuid", mobileDeviceId);
QJsonDocument jsonDoc = QJsonDocument::fromVariant(payload); QJsonDocument jsonDoc = QJsonDocument::fromVariant(payload);
qDebug() << "Registering push notification endpoint:"; // qDebug() << "Registering push notification endpoint:";
qDebug() << "POST" << url.toString(); // qDebug() << "POST" << url.toString();
qDebug() << "HEADERS:"; // qDebug() << "HEADERS:";
foreach (const QByteArray &hdr, request.rawHeaderList()) { // foreach (const QByteArray &hdr, request.rawHeaderList()) {
qDebug() << hdr << ":" << request.rawHeader(hdr); // qDebug() << hdr << ":" << request.rawHeader(hdr);
} // }
qDebug() << "Payload:" << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Compact)); // qDebug() << "Payload:" << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Compact));
QNetworkReply *reply = m_nam->post(request, jsonDoc.toJson(QJsonDocument::Compact)); QNetworkReply *reply = m_nam->post(request, jsonDoc.toJson(QJsonDocument::Compact));
connect(reply, &QNetworkReply::finished, this, [reply]() { connect(reply, &QNetworkReply::finished, this, [reply]() {
@ -658,7 +658,7 @@ void AWSClient::registerPushNotificationEndpoint(const QString &registrationId,
qWarning() << "Error registering push notification endpoint:" << reply->error() << reply->errorString() << qUtf8Printable(data); qWarning() << "Error registering push notification endpoint:" << reply->error() << reply->errorString() << qUtf8Printable(data);
return; return;
} }
qDebug() << "Push notification endpoint registered" << data; // qDebug() << "Push notification endpoint registered" << data;
}); });
} }
@ -887,7 +887,7 @@ void AWSClient::fetchDevices()
m_callQueue.append(QueuedCall("fetchDevices")); m_callQueue.append(QueuedCall("fetchDevices"));
return; return;
} }
qDebug() << "Fetching cloud devices"; // qDebug() << "Fetching cloud devices";
QUrl url(QString("https://%1/users/devices").arg(m_configs.at(m_usedConfigIndex).apiEndpoint)); QUrl url(QString("https://%1/users/devices").arg(m_configs.at(m_usedConfigIndex).apiEndpoint));
QNetworkRequest request(url); QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
@ -914,7 +914,7 @@ void AWSClient::fetchDevices()
QString deviceId = entry.toMap().value("deviceId").toString(); QString deviceId = entry.toMap().value("deviceId").toString();
QString name = entry.toMap().value("name").toString(); QString name = entry.toMap().value("name").toString();
bool online = entry.toMap().value("online").toBool(); bool online = entry.toMap().value("online").toBool();
qDebug() << "Have cloud device:" << deviceId << name << "online:" << online; // qDebug() << "Have cloud device:" << deviceId << name << "online:" << online;
AWSDevice *d = m_devices->getDevice(deviceId); AWSDevice *d = m_devices->getDevice(deviceId);
if (!d) { if (!d) {

View File

@ -45,7 +45,7 @@ void BluetoothServiceDiscovery::discover()
if (m_discovering) if (m_discovering)
return; return;
qDebug() << "BluetoothServiceDiscovery: Service scan started for service: " << m_nymeaServiceUuid.toString(); // qDebug() << "BluetoothServiceDiscovery: Service scan started for service: " << m_nymeaServiceUuid.toString();
setDiscovering(true); setDiscovering(true);
m_serviceDiscovery->setUuidFilter(m_nymeaServiceUuid); m_serviceDiscovery->setUuidFilter(m_nymeaServiceUuid);
@ -116,7 +116,7 @@ void BluetoothServiceDiscovery::onServiceDiscovered(const QBluetoothServiceInfo
void BluetoothServiceDiscovery::onServiceDiscoveryFinished() void BluetoothServiceDiscovery::onServiceDiscoveryFinished()
{ {
qDebug() << "BluetoothServiceDiscovery: Service discovery finished."; // qDebug() << "BluetoothServiceDiscovery: Service discovery finished.";
setDiscovering(false); setDiscovering(false);
foreach (const QBluetoothServiceInfo &serviceInfo, m_serviceDiscovery->discoveredServices()) { foreach (const QBluetoothServiceInfo &serviceInfo, m_serviceDiscovery->discoveredServices()) {
@ -130,7 +130,7 @@ void BluetoothServiceDiscovery::onServiceDiscoveryFinished()
return; return;
} }
qDebug() << "BluetoothServiceDiscovery: Restart service discovery"; // qDebug() << "BluetoothServiceDiscovery: Restart service discovery";
discover(); discover();
} }
} }

View File

@ -88,7 +88,6 @@ DiscoveryModel *NymeaDiscovery::discoveryModel() const
void NymeaDiscovery::syncCloudDevices() void NymeaDiscovery::syncCloudDevices()
{ {
qDebug() << "Cloud devices fetched";
for (int i = 0; i < Engine::instance()->awsClient()->awsDevices()->rowCount(); i++) { for (int i = 0; i < Engine::instance()->awsClient()->awsDevices()->rowCount(); i++) {
AWSDevice *d = Engine::instance()->awsClient()->awsDevices()->get(i); AWSDevice *d = Engine::instance()->awsClient()->awsDevices()->get(i);
DiscoveryDevice *device = m_discoveryModel->find(d->id()); DiscoveryDevice *device = m_discoveryModel->find(d->id());
@ -96,6 +95,7 @@ void NymeaDiscovery::syncCloudDevices()
device = new DiscoveryDevice(); device = new DiscoveryDevice();
device->setUuid(d->id()); device->setUuid(d->id());
device->setName(d->name()); device->setName(d->name());
qDebug() << "CloudDiscovery: Adding new host:" << device->name() << device->uuid().toString();
m_discoveryModel->addDevice(device); m_discoveryModel->addDevice(device);
} }
QUrl url; QUrl url;
@ -104,6 +104,7 @@ void NymeaDiscovery::syncCloudDevices()
Connection *conn = device->connections()->find(url); Connection *conn = device->connections()->find(url);
if (!conn) { if (!conn) {
conn = new Connection(url, Connection::BearerTypeCloud, true, d->id()); conn = new Connection(url, Connection::BearerTypeCloud, true, d->id());
qDebug() << "CloudDiscovery: Adding new connection to host:" << device->name() << conn->url().toString();
device->connections()->addConnection(conn); device->connections()->addConnection(conn);
} }
conn->setOnline(d->online()); conn->setOnline(d->online());

View File

@ -9,24 +9,34 @@ ZeroconfDiscovery::ZeroconfDiscovery(DiscoveryModel *discoveryModel, QObject *pa
m_discoveryModel(discoveryModel) m_discoveryModel(discoveryModel)
{ {
#ifdef WITH_ZEROCONF #ifdef WITH_ZEROCONF
// NOTE: There seem to be too many issues in QtZeroConf and IPv6.
// See https://github.com/jbagg/QtZeroConf/issues/22
// IPv6 resolving is disabled completely for android in avahicore.cpp for now
// Limiting this to IPv4 for now...
m_zeroconfJsonRPC = new QZeroConf(this); m_zeroconfJsonRPC = new QZeroConf(this);
connect(m_zeroconfJsonRPC, &QZeroConf::serviceAdded, this, &ZeroconfDiscovery::serviceEntryAdded); connect(m_zeroconfJsonRPC, &QZeroConf::serviceAdded, this, &ZeroconfDiscovery::serviceEntryAdded);
connect(m_zeroconfJsonRPC, &QZeroConf::serviceUpdated, this, &ZeroconfDiscovery::serviceEntryAdded); connect(m_zeroconfJsonRPC, &QZeroConf::serviceUpdated, this, &ZeroconfDiscovery::serviceEntryAdded);
connect(m_zeroconfJsonRPC, &QZeroConf::serviceRemoved, this, &ZeroconfDiscovery::serviceEntryRemoved); connect(m_zeroconfJsonRPC, &QZeroConf::serviceRemoved, this, &ZeroconfDiscovery::serviceEntryRemoved);
m_zeroconfJsonRPC->startBrowser("_jsonrpc._tcp", QAbstractSocket::AnyIPProtocol); m_zeroconfJsonRPC->startBrowser("_jsonrpc._tcp", QAbstractSocket::IPv4Protocol);
qDebug() << "ZeroConf: Created service browser for _jsonrpc._tcp:" << m_zeroconfJsonRPC->browserExists(); qDebug() << "ZeroConf: Created service browser for _jsonrpc._tcp:" << m_zeroconfJsonRPC->browserExists();
m_zeroconfWebSocket = new QZeroConf(this); m_zeroconfWebSocket = new QZeroConf(this);
connect(m_zeroconfWebSocket, &QZeroConf::serviceAdded, this, &ZeroconfDiscovery::serviceEntryAdded); connect(m_zeroconfWebSocket, &QZeroConf::serviceAdded, this, &ZeroconfDiscovery::serviceEntryAdded);
connect(m_zeroconfWebSocket, &QZeroConf::serviceUpdated, this, &ZeroconfDiscovery::serviceEntryAdded); connect(m_zeroconfWebSocket, &QZeroConf::serviceUpdated, this, &ZeroconfDiscovery::serviceEntryAdded);
connect(m_zeroconfWebSocket, &QZeroConf::serviceRemoved, this, &ZeroconfDiscovery::serviceEntryRemoved); connect(m_zeroconfWebSocket, &QZeroConf::serviceRemoved, this, &ZeroconfDiscovery::serviceEntryRemoved);
m_zeroconfWebSocket->startBrowser("_ws._tcp", QAbstractSocket::AnyIPProtocol); m_zeroconfWebSocket->startBrowser("_ws._tcp", QAbstractSocket::IPv4Protocol);
qDebug() << "TeroConf: Created service browser for _ws._tcp:" << m_zeroconfWebSocket->browserExists(); qDebug() << "ZeroConf: Created service browser for _ws._tcp:" << m_zeroconfWebSocket->browserExists();
#else #else
qDebug() << "Zeroconf support not compiled in. Zeroconf will not be available."; qDebug() << "Zeroconf support not compiled in. Zeroconf will not be available.";
#endif #endif
} }
ZeroconfDiscovery::~ZeroconfDiscovery()
{
qDebug() << "ZeroConf: Shutting down service browsers";
}
bool ZeroconfDiscovery::available() const bool ZeroconfDiscovery::available() const
{ {
#ifdef WITH_ZEROCONF #ifdef WITH_ZEROCONF
@ -46,18 +56,21 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
{ {
if (!entry.name().startsWith("nymea")) { if (!entry.name().startsWith("nymea")) {
// Skip non-nymea services altogether // Skip non-nymea services altogether
qDebug() << "Skipping Avahi entry:" << entry << entry.ip() << entry.ipv6() << entry.txt() << entry.type();
return; return;
} }
if (entry.ip().isNull() && entry.ipv6().isNull()) { if (entry.ip().isNull() && entry.ipv6().isNull()) {
// Skip entries that don't have an ip address at all for some reason // Skip entries that don't have an ip address at all for some reason
qDebug() << "Skipping Avahi entry:" << entry << entry.ip() << entry.ipv6() << entry.txt() << entry.type();
return; return;
} }
if (entry.ip().isNull() && entry.ipv6().toString().startsWith("fe80")) { if (entry.ip().isNull() && entry.ipv6().toString().startsWith("fe80")) {
// Skip link-local-IPv6-only results // Skip link-local-IPv6-only results
qDebug() << "Skipping Avahi entry:" << entry << entry.ip() << entry.ipv6() << entry.txt() << entry.type();
return; return;
} }
// qDebug() << "zeroconf service discovered" << entry << entry.ip() << entry.ipv6() << entry.txt() << entry.type(); qDebug() << "zeroconf service discovered" << entry.type() << entry.name() << " IP:" << entry.ip() << "IPv6:" << entry.ipv6() << entry.txt();
QString uuid; QString uuid;
bool sslEnabled = false; bool sslEnabled = false;

View File

@ -15,6 +15,7 @@ class ZeroconfDiscovery : public QObject
public: public:
explicit ZeroconfDiscovery(DiscoveryModel *discoveryModel, QObject *parent = nullptr); explicit ZeroconfDiscovery(DiscoveryModel *discoveryModel, QObject *parent = nullptr);
~ZeroconfDiscovery();
bool available() const; bool available() const;
bool discovering() const; bool discovering() const;

View File

@ -126,7 +126,7 @@ void BluetoothDiscovery::setDiscovering(bool discovering)
void BluetoothDiscovery::onBluetoothHostModeChanged(const QBluetoothLocalDevice::HostMode &hostMode) void BluetoothDiscovery::onBluetoothHostModeChanged(const QBluetoothLocalDevice::HostMode &hostMode)
{ {
qDebug() << "BluetoothDiscovery: host mode changed" << hostMode; // qDebug() << "BluetoothDiscovery: host mode changed" << hostMode;
switch (hostMode) { switch (hostMode) {
case QBluetoothLocalDevice::HostPoweredOff: case QBluetoothLocalDevice::HostPoweredOff:
setBluetoothEnabled(false); setBluetoothEnabled(false);
@ -148,7 +148,7 @@ void BluetoothDiscovery::deviceDiscovered(const QBluetoothDeviceInfo &deviceInfo
BluetoothDeviceInfo *deviceInformation = new BluetoothDeviceInfo(deviceInfo); BluetoothDeviceInfo *deviceInformation = new BluetoothDeviceInfo(deviceInfo);
bool isLowEnergy = deviceInfo.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration; bool isLowEnergy = deviceInfo.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration;
qDebug() << "BluetoothDiscovery: [+]" << deviceInformation->name() << "(" << deviceInformation->address() << ")" << (isLowEnergy ? "LE" : ""); // qDebug() << "BluetoothDiscovery: [+]" << deviceInformation->name() << "(" << deviceInformation->address() << ")" << (isLowEnergy ? "LE" : "");
if (!isLowEnergy || deviceInformation->name().isEmpty()) { if (!isLowEnergy || deviceInformation->name().isEmpty()) {
delete deviceInformation; delete deviceInformation;
@ -158,7 +158,7 @@ void BluetoothDiscovery::deviceDiscovered(const QBluetoothDeviceInfo &deviceInfo
// Check if we already have added this device info // Check if we already have added this device info
foreach (BluetoothDeviceInfo *di, m_deviceInfos->deviceInfos()) { foreach (BluetoothDeviceInfo *di, m_deviceInfos->deviceInfos()) {
if (di->address() == deviceInformation->address()) { if (di->address() == deviceInformation->address()) {
qWarning() << "BluetoothDiscover: device" << deviceInformation->name() << "(" << deviceInformation->address() << ") already added"; // qWarning() << "BluetoothDiscover: device" << deviceInformation->name() << "(" << deviceInformation->address() << ") already added";
deviceInformation->deleteLater(); deviceInformation->deleteLater();
return; return;
} }
@ -169,7 +169,7 @@ void BluetoothDiscovery::deviceDiscovered(const QBluetoothDeviceInfo &deviceInfo
void BluetoothDiscovery::discoveryFinished() void BluetoothDiscovery::discoveryFinished()
{ {
qDebug() << "BluetoothDiscovery: Discovery finished"; // qDebug() << "BluetoothDiscovery: Discovery finished";
if (m_enabled) { if (m_enabled) {
m_discoveryAgent->start(); m_discoveryAgent->start();
} }
@ -197,7 +197,7 @@ void BluetoothDiscovery::start()
return; return;
} }
qDebug() << "BluetoothDiscovery: Start discovering."; // qDebug() << "BluetoothDiscovery: Start discovering.";
m_discoveryAgent->start(); m_discoveryAgent->start();
setDiscovering(true); setDiscovering(true);
} }
@ -209,7 +209,7 @@ void BluetoothDiscovery::stop()
if (!m_discoveryAgent) if (!m_discoveryAgent)
return; return;
qDebug() << "BluetoothDiscovery: Stop discovering."; // qDebug() << "BluetoothDiscovery: Stop discovering.";
m_discoveryAgent->stop(); m_discoveryAgent->stop();
setDiscovering(false); setDiscovering(false);
} }

View File

@ -36,12 +36,8 @@ void PushNotifications::connectClient()
m_client_pointer = this; m_client_pointer = this;
m_firebase_initializer.Initialize(m_firebaseApp, m_firebase_initializer.Initialize(m_firebaseApp, nullptr, [](::firebase::App * fapp, void *) {
nullptr, [](::firebase::App * fapp, void *) { return ::firebase::messaging::Initialize( *fapp, (::firebase::messaging::Listener *)m_client_pointer);
qDebug() << "Trying to initialize Firebase Messaging";
return ::firebase::messaging::Initialize(
*fapp,
(::firebase::messaging::Listener *)m_client_pointer);
}); });
while (m_firebase_initializer.InitializeLastResult().status() != while (m_firebase_initializer.InitializeLastResult().status() !=