summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qdnslookup.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QDnsLookup: add support for TLSA recordsThiago Macieira4 days1-0/+234
| | | | | | | | | [ChangeLog][QtNetwork][QDnsLookup] Added support for querying records of type TLSA, which are useful in DNS-based Authentication of Named Entities (DANE). Change-Id: I455fe22ef4ad4b2f9b01fffd17c723aa6ab7f278 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: add the ability to tell if the reply was authenticatedThiago Macieira4 days1-2/+53
| | | | | | | | | This is implemented for DNS-over-TLS and for the native Unix resolver, because I can find no way to get the state of the reply on Windows with the WinDNS.h API. Change-Id: I455fe22ef4ad4b2f9b01fffd17c7bc022ded2363 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: implement DNS-over-TLSThiago Macieira4 days1-2/+92
| | | | | | | | | | | | | | | For the libresolv (Unix) implementation, we already had the packet prepared by res_nmkquery(). This commit moves the res_nsend() to a separate function so QDnsLookupRunnable::query() can be more concise. On the Windows side, this commit creates a separate function for the DoT case, because we now need to use two other functions from WinDNS so we can create a query and parse the reply. The rest is just QSslSocket. Change-Id: I455fe22ef4ad4b2f9b01fffd17c805a3cb0466eb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: add initial support for DNS-over-TLS (DoT)Thiago Macieira4 days1-7/+172
| | | | | | | | | | | | | This is just an empty shell for now. The implementation will come in the next commit. [ChangeLog][QtNetwork][QDnsLookup] The class now supports DNS-over-TLS and some other DNSSEC experimental features, on some platforms. Use QDnsLookup::isProtocolSupported to know if the protocol is supported on a given platform. Change-Id: I455fe22ef4ad4b2f9b01fffd17c7e034dee75533 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: allow looking up the root domainThiago Macieira2023-06-031-0/+8
| | | | | | | | | [ChangeLog][QtNetwork][QDnsLookup] It is now possible to look up the root DNS domain, by setting the name property to an empty string. This query is usually done while setting the query type to NS. Change-Id: I5f7f427ded124479baa6fffd175f688395941610 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: merge some of the domain label expansion codeThiago Macieira2023-06-031-1/+11
| | | | | | | | | | | | | | | Use qt_ACE_do directly from QtCore, to avoid going through Latin1 (US-ASCII) multiple times. Drive-by reduce the size of the buffers from PACKETSZ (512) to the maximum name a label can be (255 plus 1 for the null, just in case). Drive-by replace the last QString::fromWCharArray with QStringView, saving an unnecessary memory allocation before calling QtPrivate::convertToLatin1(). Change-Id: I3e3bfef633af4130a03afffd175d8be1feb5d74b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: add TimeoutError for timeoutsThiago Macieira2023-05-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We were getting InvalidReplyError because it was simply unknown, which is not very useful. Previously, the Unix code used res_nquery(), which does not return timeouts as a condition. It returns -1 if a timeout did happen, but the content in errno could be a left-over from a previous timeout (see the "Not a typewriter"[1] problem). With the rewrite to using res_nmkquery() and res_nsend() from the previous commits, we can rely on errno being set properly by res_nsend(). $ $objdir/tests/manual/qdnslookup/qdnslookup @0.0.0.1 ; <<>> QDnsLookup 6.6.0 <<>> qdnslookup @0.0.0.1 ;; status: TimeoutError (Request timed out) ;; QUESTION: ;qt-project.org IN A ;; Query time: 10008 ms ;; SERVER: 0.0.0.1#53 Tested on FreeBSD, Linux, macOS, and Windows. [1] https://en.wikipedia.org/wiki/Not_a_typewriter Change-Id: I3e3bfef633af4130a03afffd175e31958247f9b1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: centralize printing of warningsThiago Macieira2023-05-231-10/+41
| | | | | | | | | | Any resolution error that is caused by an invalid request, invalid reply (only happens on Unix), or a system error can be printed as a warning, using category "qt.network.dnslookup". Those warnings are disabled by default. Change-Id: I5f7f427ded124479baa6fffd175fc40b3e21c969 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: replace Q_GLOBAL_STATIC with Q_APPLICATION_STATICThiago Macieira2023-05-231-37/+18
| | | | | | | Replaces a lot of the manual content. Change-Id: I3e3bfef633af4130a03afffd175e839f4b05975c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: simplify the processing of the runnable and replyThiago Macieira2023-05-231-16/+15
| | | | | Change-Id: I3e3bfef633af4130a03afffd175e827dce2af966 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: add support for setting the port number of the serverThiago Macieira2023-05-231-3/+67
| | | | | | | | | | | | | | I couldn't make my Windows 10 or 11 query a non-standard port. It kept complaining about "The parameter is incorrect.", so as a result the unit test doesn't actually test the new feature there. I can't find a single example of this on the Internet; my speculation is that the backend API that DnsQueryEx uses does not support setting port numbers (DnsQuery_{A,W} didn't offer that option). [ChangeLog][QtNetwork][QDnsLookup] Added setNameserverPort(). Change-Id: I3e3bfef633af4130a03afffd175d60a581cc0a9c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: add a number of functions to simply setting error conditionsThiago Macieira2023-05-231-4/+1
| | | | | | | | This also updates a few messages and transfers the translation context from QDnsLookupRunnable to QDnsLookup. Change-Id: I3e3bfef633af4130a03afffd175e86715e4a25e3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: reject looking up domain names that are too longThiago Macieira2023-05-161-1/+3
| | | | | | | | | | | | | | | | | Both the libresolv and the Win32 API operate in 32-bit quantities, so we could be aliasing with low values. In any case, RFC 1035 limits to 255. Various objects and parameters in the DNS have size limits. They are listed below. Some could be easily changed, others are more fundamental. labels 63 octets or less names 255 octets or less Pick-to: 6.5 Change-Id: I3e3bfef633af4130a03afffd175e8957cd860bef Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: make the query() function non-staticThiago Macieira2023-05-161-2/+9
| | | | | | | Simplifies arguments and will allow me to add stateful helper methods. Change-Id: I3e3bfef633af4130a03afffd175d6044829a96f2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: remove the #if QT_CONFIG(thread) checkThiago Macieira2023-05-141-7/+2
| | | | | | | | | | There's no fallback anywhere, so this class simply doesn't work if threading isn't supported. Writing it is an exercise left for whoever cares for that configuration. Change-Id: I3e3bfef633af4130a03afffd175e6f68a3f4673f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: remove the explicit metatype registration for the Reply typeThiago Macieira2023-05-131-5/+3
| | | | | | | | | It's unnecessary in Qt 6 if we use the new-style connect or if the type was fully defined in the compilation of the unit containing the moc output. Change-Id: I3e3bfef633af4130a03afffd175e6f4e87adf5e1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Network: Remove Q_DECL_METATYPE_EXTERN for single-.cpp metatypesThiago Macieira2023-05-131-2/+0
| | | | | | | | | | | | | | | These were added in commit 20e6a049fee48e876c8c6903101b58f918b5aab2 as a massive sweep of all Q_DECLARE_METATYPE, without thought as to whether they were actually needed or not. If they are used as a metatype in a single .cpp file, they don't need to be. Incidentally removes the entirely incorrect Q_NETWORK_EXPORT of QDnsLookupReply. Pick-to: 6.5 Change-Id: I3e3bfef633af4130a03afffd175e6f378f09a3aa Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtNetwork: sweep Q_DECLARE_METATYPE → QT_DECL_METATYPE_EXTERN [2/2]: ↵Marc Mutz2022-04-061-0/+2
| | | | | | | | | | | | | | | private API It's one of our best tools to improve compile times. Can't backport to Qt 6.2 because the macros don't exist there. Pick-to: 6.3 Task-number: QTBUG-102206 Change-Id: Ic8f3870d8eec6211c4be506dc67717cc4e0ff7d6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtNetwork: Include moc filesMårten Nordheim2022-01-151-0/+1
| | | | | Change-Id: I227a9541bf76c1c048a694f022b8fc419c0c2544 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove unnecessary int() casting in QRandomGenerator::boundedThiago Macieira2021-03-171-1/+1
| | | | | | | | | Commit 21d39168170c6833512c4a5f53985272741bd7e7 added the 64-bit version, so qsizetype now works cross-platform. The casts were added to make qtbase compile on commit df853fed66d891077ae2d04ecfa171d7e2cd5202. Change-Id: I26b8286f61534f88b649fffd166c409c5c232230 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup - port to the new property systemTimur Pocheptsov2021-01-271-12/+21
| | | | | | | | | Read/write/notify properties, 3 out of 5 defined in this class. Task-number: QTBUG-85520 Change-Id: Ic6c74f90a2fa3c71d71cf9a5d557f1b6fc489d35 Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Use qsizetype in QListLars Knoll2020-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | The change creates a slight source incompatibility. The main things to take care of are * code using printf statements on list.size(). Using qsizetype in printf statements will always require a cast to work on both 32 and 64 bit. * A few places where overloads now get ambiguous. One example is QRandomGenerator::bounded() that has overloads for int, uint and double, but not int64. * Streaming list.size() to a QDataStream will change the format depending on the architecture. [ChangeLog][QtCore][QList] QList now uses qsizetype to index into elements. Change-Id: Iaff562a4d072b97f458417b670f95971bd47cbc6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-2/+2
| | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* wasm: enable Network for nothreadLorn Potter2018-09-281-1/+6
| | | | | | | Task-number: QTBUG-70208 Change-Id: Ib73ca0d3c0736336bf517ffb968cbdbab4610319 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Change almost all other uses of qrand() to QRandomGeneratorThiago Macieira2017-11-081-8/+3
| | | | | | | | | | | | | | | | | | | The vast majority is actually switched to QRandomGenerator::bounded(), which gives a mostly uniform distribution over the [0, bound) range. There are very few floating point cases left, as many of those that did use floating point did not need to, after all. (I did leave some that were too ugly for me to understand) This commit also found a couple of calls to rand() instead of qrand(). This commit does not include changes to SSL code that continues to use qrand() (job for someone else): src/network/ssl/qsslkey_qt.cpp src/network/ssl/qsslsocket_mac.cpp tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* doc: removed illegal qdoc commentsMartin Smith2017-01-041-2/+2
| | | | | | | | | Removed qdoc comment marker from two comments for static function defined in the cpp file. Tbey are not known globally. Change-Id: I485fa06142879b6c732b6865d264395deafade33 Reviewed-by: Martin Smith <martin.smith@qt.io>
* QtNetwork: use const (and const APIs) moreAnton Kudryavtsev2016-04-271-11/+11
| | | | | | | | | | | For CoW types, prefer const methods to avoid needless detach()ing. Mark predictNextRequest() as const, because this method does not modify the object. Change-Id: Ic94e2b31445ece46ab1423bf5b5f4e66d9a5b6ca Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Updated license headersJani Heikkinen2016-01-151-13/+19
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QtNetwork: Standardize error message about IPv6 addresses for nameservers.v5.6.0-beta1Friedemann Kleint2015-12-141-0/+3
| | | | | | | | Add a const char * message with QDnsLookupRunnable's translation context and use that for untranslated warnings and errorString. Change-Id: I1b6c9fb259fb9ff824a0c3829b2c00c36aaecdfa Reviewed-by: Richard J. Moore <rich@kde.org>
* Update copyright headersJani Heikkinen2015-02-111-6/+6
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Add missing QDnsLookup constructor implementationAndy Shaw2014-06-201-1/+13
| | | | | | | Task-number: QTBUG-39136 Change-Id: I4d2626416fae99339988cd994653ce7ec753f081 Reviewed-by: Richard J. Moore <rich@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Mark the missing QDnsLookup constructor as \internalAndy Shaw2014-05-211-0/+5
| | | | | | | | | Implementation will be added for Qt 5.4.0 as it cannot be done sooner. Change-Id: I4d2626416fae99339988cd994653ce7ec753f081 Reviewed-by: Richard J. Moore <rich@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDnsLookup: Add support for custom DNS serverMandeep Sandhu2014-02-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implemented the use of the new QDnsLookup property "nameserver". On the Linux platform, we can specify both IPv4 and IPv6 addresses for the nameserver. On Windows since we are using DnsQuery_W(), which does not have a way of accepting IPv6 addresses, passing IPv6 nameserver address is not supported. On OSX/BSD platforms, specifying IPv6 addresses for nameserver require access to the __res_state_ext structure which is in a private header of libresolv (this header is different for BSDs and OSX). If this feature has to be enabled in the future, we have to figure out a way to access this struct by either accessing the private header or by specifying one of our own. Currently, I'm disabling it till such a solution is arrived at. Nameserver support on different platforms: Platform | IPv4 | IPv6 -------------+---------------+--------------- Linux/X11 | supported | supported -------------+---------------+--------------- Windows | supported | not supported -------------+---------------+--------------- OSX | supported | not supported -------------+---------------+--------------- WinRT | not supported | not supported -------------+---------------+--------------- Others | supported | not supported | (not tested) | -------------+---------------+--------------- Task-number: QTBUG-30166 Change-Id: Iedbddf15b9a62738ce4c2cfa0fce051514d64766 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDnsLookup: Support for custom DNS serverMandeep Sandhu2013-10-211-0/+19
| | | | | | | | | | This commit only adds a new QProperty, "nameserver", to QDnsLookup. This property currently does not do anything and is not used internally by QDnsLookup. The next commit will implement it's usage. Task-number: QTBUG-30166 Change-Id: I85b72bd6661603128cab4068c1b83883fb2bfd1a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QDns* classes to the list of the implicitly shared onesGiuseppe D'Angelo2012-11-301-0/+5
| | | | | | Change-Id: I29dd678a51dc693285c389f235d748120ca58fe1 Reviewed-by: Jeremy Lainé <jeremy.laine@m4x.org> Reviewed-by: hjk <qthjk@ovi.com>
* Remove qSort usages from QDnsLookupGiuseppe D'Angelo2012-11-081-2/+4
| | | | | Change-Id: I2f7dfcfdf13cdd85af5ba251478e10cafe7f649b Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-23/+23
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* QtNetwork: add member-swap to shared classesMarc Mutz2012-07-061-0/+30
| | | | | | | | Implemented as in other shared classes (e.g. QPen). Change-Id: Ib3d87ff99603e617cc8810489f9f5e9fe054cd2a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
* Doc: Modularize QtNetwork documentation.Casper van Donderen2012-05-091-2/+2
| | | | | | | This change moves the snippets and imagesto the modularized directories. Change-Id: If14912692a7f72d7de345eaf88d9ec9752310fca Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
* Various minor fixes for qdoc warnings.Richard Moore2012-05-061-2/+1
| | | | | Change-Id: I54c5ab6e1bfb1816bb510be9e2bfa1e3362faa36 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Document new APIs in 5.0Shane Kearns2012-05-031-0/+1
| | | | | | | | The \since 5.0 directive was missing from many places. Task-number: QTBUG-24001 Change-Id: I191ba8891ae66d78f923164bcab2fccb16eabef9 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Add support for DNS lookups using native APIsJeremy Lainé2012-01-301-0/+988
The QDnsLookup class provides asynchronous APIs for performing DNS lookups. For now, the following lookups are supported: - A and AAAA - CNAME as defined per RFC 1035 - MX as defined per RFC 1035 - NS as defined per RFC 1035 - PTR as defined per RFC 1035 - SRV as defined per RFC 2782 - TXT as defined per RFC 1035 Task-number: QTBUG-10481 Change-Id: I46c1741ec23615863eeca3a1231d5e3f8942495e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>