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"]
path = QtZeroConf
url = https://github.com/jbagg/QtZeroConf.git
url = https://github.com/mzanetti/QtZeroConf.git
[submodule "nymea-remoteproxy"]
path = nymea-remoteproxy
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);
QJsonDocument jsonDoc = QJsonDocument::fromVariant(payload);
qDebug() << "Registering push notification endpoint:";
qDebug() << "POST" << url.toString();
qDebug() << "HEADERS:";
foreach (const QByteArray &hdr, request.rawHeaderList()) {
qDebug() << hdr << ":" << request.rawHeader(hdr);
}
qDebug() << "Payload:" << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Compact));
// qDebug() << "Registering push notification endpoint:";
// qDebug() << "POST" << url.toString();
// qDebug() << "HEADERS:";
// foreach (const QByteArray &hdr, request.rawHeaderList()) {
// qDebug() << hdr << ":" << request.rawHeader(hdr);
// }
// qDebug() << "Payload:" << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Compact));
QNetworkReply *reply = m_nam->post(request, jsonDoc.toJson(QJsonDocument::Compact));
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);
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"));
return;
}
qDebug() << "Fetching cloud devices";
// qDebug() << "Fetching cloud devices";
QUrl url(QString("https://%1/users/devices").arg(m_configs.at(m_usedConfigIndex).apiEndpoint));
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
@ -914,7 +914,7 @@ void AWSClient::fetchDevices()
QString deviceId = entry.toMap().value("deviceId").toString();
QString name = entry.toMap().value("name").toString();
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);
if (!d) {

View File

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

View File

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

View File

@ -9,24 +9,34 @@ ZeroconfDiscovery::ZeroconfDiscovery(DiscoveryModel *discoveryModel, QObject *pa
m_discoveryModel(discoveryModel)
{
#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);
connect(m_zeroconfJsonRPC, &QZeroConf::serviceAdded, this, &ZeroconfDiscovery::serviceEntryAdded);
connect(m_zeroconfJsonRPC, &QZeroConf::serviceUpdated, this, &ZeroconfDiscovery::serviceEntryAdded);
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();
m_zeroconfWebSocket = new QZeroConf(this);
connect(m_zeroconfWebSocket, &QZeroConf::serviceAdded, this, &ZeroconfDiscovery::serviceEntryAdded);
connect(m_zeroconfWebSocket, &QZeroConf::serviceUpdated, this, &ZeroconfDiscovery::serviceEntryAdded);
connect(m_zeroconfWebSocket, &QZeroConf::serviceRemoved, this, &ZeroconfDiscovery::serviceEntryRemoved);
m_zeroconfWebSocket->startBrowser("_ws._tcp", QAbstractSocket::AnyIPProtocol);
qDebug() << "TeroConf: Created service browser for _ws._tcp:" << m_zeroconfWebSocket->browserExists();
m_zeroconfWebSocket->startBrowser("_ws._tcp", QAbstractSocket::IPv4Protocol);
qDebug() << "ZeroConf: Created service browser for _ws._tcp:" << m_zeroconfWebSocket->browserExists();
#else
qDebug() << "Zeroconf support not compiled in. Zeroconf will not be available.";
#endif
}
ZeroconfDiscovery::~ZeroconfDiscovery()
{
qDebug() << "ZeroConf: Shutting down service browsers";
}
bool ZeroconfDiscovery::available() const
{
#ifdef WITH_ZEROCONF
@ -46,18 +56,21 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
{
if (!entry.name().startsWith("nymea")) {
// Skip non-nymea services altogether
qDebug() << "Skipping Avahi entry:" << entry << entry.ip() << entry.ipv6() << entry.txt() << entry.type();
return;
}
if (entry.ip().isNull() && entry.ipv6().isNull()) {
// 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;
}
if (entry.ip().isNull() && entry.ipv6().toString().startsWith("fe80")) {
// Skip link-local-IPv6-only results
qDebug() << "Skipping Avahi entry:" << entry << entry.ip() << entry.ipv6() << entry.txt() << entry.type();
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;
bool sslEnabled = false;

View File

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

View File

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

View File

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