diff options
Diffstat (limited to 'src/network/kernel/qnetworkinterface.cpp')
-rw-r--r-- | src/network/kernel/qnetworkinterface.cpp | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index e546c8d949..ec58fa65c0 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -119,8 +119,15 @@ QList<QSharedDataPointer<QNetworkInterfacePrivate> > QNetworkInterfaceManager::a QList<QSharedDataPointer<QNetworkInterfacePrivate> > result; result.reserve(list.size()); - for (QNetworkInterfacePrivate *ptr : list) + for (QNetworkInterfacePrivate *ptr : list) { + if ((ptr->flags & QNetworkInterface::IsUp) == 0) { + // if the network interface isn't UP, the addresses are ineligible for DNS + for (auto &addr : ptr->addressEntries) + addr.setDnsEligibility(QNetworkAddressEntry::DnsIneligible); + } + result << QSharedDataPointer<QNetworkInterfacePrivate>(ptr); + } return result; } @@ -159,6 +166,32 @@ QString QNetworkInterfacePrivate::makeHwAddress(int len, uchar *data) */ /*! + \enum QNetworkAddressEntry::DnsEligilibilityStatus + \since 5.11 + + This enum indicates whether a given host address is eligible to be + published in the Domain Name System (DNS) or other similar name resolution + mechanisms. In general, an address is suitable for publication if it is an + address this machine will be reached at for an indeterminate amount of + time, though it need not be permanent. For example, addresses obtained via + DHCP are often eligible, but cryptographically-generated temporary IPv6 + addresses are not. + + \value DnsEligibilityUnknown Qt and the operating system could not determine + whether this address should be published or not. + The application may need to apply further + heuristics if it cannot find any eligible + addresses. + \value DnsEligible This address is eligible for publication in DNS. + \value DnsIneligible This address should not be published in DNS and + should not be transmitted to other parties, + except maybe as the source address of an outgoing + packet. + + \sa dnsEligibility(), setDnsEligibility() +*/ + +/*! Constructs an empty QNetworkAddressEntry object. */ QNetworkAddressEntry::QNetworkAddressEntry() @@ -213,6 +246,39 @@ bool QNetworkAddressEntry::operator==(const QNetworkAddressEntry &other) const } /*! + \since 5.11 + + Returns whether this address is eligible for publication in the Domain Name + System (DNS) or similar name resolution mechanisms. + + In general, an address is suitable for publication if it is an address this + machine will be reached at for an indeterminate amount of time, though it + need not be permanent. For example, addresses obtained via DHCP are often + eligible, but cryptographically-generated temporary IPv6 addresses are not. + + On some systems, QNetworkInterface will need to heuristically determine + which addresses are eligible. + + \sa isLifetimeKnown(), isPermanent(), setDnsEligibility() +*/ +QNetworkAddressEntry::DnsEligibilityStatus QNetworkAddressEntry::dnsEligibility() const +{ + return d->dnsEligibility; +} + +/*! + \since 5.11 + + Sets the DNS eligibility flag for this address to \a status. + + \sa dnsEligibility() +*/ +void QNetworkAddressEntry::setDnsEligibility(DnsEligibilityStatus status) +{ + d->dnsEligibility = status; +} + +/*! \fn bool QNetworkAddressEntry::operator!=(const QNetworkAddressEntry &other) const Returns \c true if this network address entry is different from \a |