Check if the IPv6 to v4 conversion succeeds, use v6 if it doesn't.
This commit is contained in:
parent
25b86c6c7f
commit
df61e8f0e6
2 changed files with 18 additions and 4 deletions
|
@ -56,13 +56,27 @@ void LanDeviceLink::reset(QSslSocket* socket, ConnectionStarted connectionSource
|
||||||
|
|
||||||
mConnectionSource = connectionSource;
|
mConnectionSource = connectionSource;
|
||||||
|
|
||||||
QHostAddress addr = socket->peerAddress();
|
|
||||||
mHostAddress = (addr.protocol() == QAbstractSocket::IPv6Protocol) ? QHostAddress(addr.toIPv4Address()) : addr;
|
|
||||||
|
|
||||||
QString certString = KdeConnectConfig::instance()->getDeviceProperty(deviceId(), QStringLiteral("certificate"));
|
QString certString = KdeConnectConfig::instance()->getDeviceProperty(deviceId(), QStringLiteral("certificate"));
|
||||||
DeviceLink::setPairStatus(certString.isEmpty()? PairStatus::NotPaired : PairStatus::Paired);
|
DeviceLink::setPairStatus(certString.isEmpty()? PairStatus::NotPaired : PairStatus::Paired);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QHostAddress LanDeviceLink::hostAddress() const
|
||||||
|
{
|
||||||
|
if (!mSocketLineReader) {
|
||||||
|
return QHostAddress::Null;
|
||||||
|
}
|
||||||
|
QHostAddress addr = mSocketLineReader->mSocket->peerAddress();
|
||||||
|
if (addr.protocol() == QAbstractSocket::IPv6Protocol) {
|
||||||
|
bool success;
|
||||||
|
QHostAddress convertedAddr = QHostAddress(addr.toIPv4Address(&success));
|
||||||
|
if (success) {
|
||||||
|
qCDebug(KDECONNECT_CORE) << "Converting IPv6" << addr << "to IPv4" << convertedAddr;
|
||||||
|
addr = convertedAddr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
QString LanDeviceLink::name()
|
QString LanDeviceLink::name()
|
||||||
{
|
{
|
||||||
return QStringLiteral("LanLink"); // Should be same in both android and kde version
|
return QStringLiteral("LanLink"); // Should be same in both android and kde version
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
|
|
||||||
bool linkShouldBeKeptAlive() override;
|
bool linkShouldBeKeptAlive() override;
|
||||||
|
|
||||||
QHostAddress hostAddress() const { return mHostAddress; }
|
QHostAddress hostAddress() const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void dataReceived();
|
void dataReceived();
|
||||||
|
|
Loading…
Reference in a new issue