summaryrefslogtreecommitdiffstats
path: root/src/network/kernel
Commit message (Collapse)AuthorAgeFilesLines
...
* QDnsLookup/Unix: cache previously decoded domain namesThiago Macieira2023-06-031-3/+29
| | | | | Change-Id: I5f7f427ded124479baa6fffd175f3ce37f0e49aa Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup/Windows: add a simple decoded domain cacheThiago Macieira2023-06-031-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid decoding multiple times the domain name when it comes in sequence. This happens when a given domain label either has multiple entries in its record set or when it's a CNAME (or both), such as in: ;; ANSWER SECTION: cname-cname.test.qt-project.org. 3600 IN CNAME cname.test.qt-project.org. cname.test.qt-project.org. 1614 IN CNAME multi.test.qt-project.org. multi.test.qt-project.org. 1614 IN A 198.51.100.2 multi.test.qt-project.org. 1614 IN A 198.51.100.3 multi.test.qt-project.org. 1614 IN A 198.51.100.1 Label targets from other records such as MX and SRV usually do show up again, in the Additional section, but the chance that they are sequential isn't very good, so we don't cache those. ;; ANSWER SECTION: mx-multi.test.qt-project.org. 3354 IN MX 10 multi.test.qt-project.org. mx-multi.test.qt-project.org. 3354 IN MX 20 a-single.test.qt-project.org. ;; ADDITIONAL SECTION: multi.test.qt-project.org. 1145 IN A 198.51.100.3 multi.test.qt-project.org. 1145 IN A 198.51.100.1 multi.test.qt-project.org. 1145 IN A 198.51.100.2 a-single.test.qt-project.org. 3364 IN A 192.0.2.1 Change-Id: I5f7f427ded124479baa6fffd175f5cf88939ee73 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-034-41/+62
| | | | | | | | | | | | | | | 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>
* CMake: remove "res_ninit" feature and collapse to just "libresolv"Thiago Macieira2023-05-272-4/+4
| | | | | | | | | | | | | Testing for "res_ninit" when WrapResolv.cmake has already checked for far more complex functions was pointless. Instead, just accept the library that was found by find_package() as good enough and rename the feature as "libresolv". Amends 4a46ba1209907796f4a14f6feb35ed4d70155d7d and 68b625901f9eb7c34e3d7aa302e1c0a454d3190b. Change-Id: Ib5ce7a497e034ebabb2cfffd1762c0afa2fac6e0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: add TimeoutError for timeoutsThiago Macieira2023-05-265-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/Unix large replies: manually handle VC [3/3]Thiago Macieira2023-05-261-4/+18
| | | | | | | | | | | | | | | The current code was inefficient when replies exceeded the initial buffer size because the res_nsend() function switched to VC to get the full reply, but that wouldn't fit our buffer before we enlarged it. This commit tells res_nsend() to only use UDP or only use TCP, avoiding the two unnecessary transactions in the lookup. Since we don't get that second TCP reply now that would tell us the size of the reply, we must allocate the largest possible buffer for a DNS reply. Change-Id: I3e3bfef633af4130a03afffd175e73d2e9fa9bf1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup/Unix large replies: use EDNS0 [2/3]Thiago Macieira2023-05-261-4/+31
| | | | | | | | | | | | | | | | | | | | The current code is inefficient when dealing with replies exceeding the PACKETSZ default size. This commit adds an EDNS0 footer to the DNS query informing the DNS server how big our buffer is. We choose a larger buffer than the old PACKETSZ so more will fit before a Virtual Circuit (TCP socket) is required. The choice is based on IPv6 requirements for the minimum MTU. Any network incapable of transmitting frames with that big a payload must support fragmenting and reassembly at the Layer 2 level, below IP. Ethernet MTU is usually 1500, so we leave a bit on the table, but this avoids having to discover our Path MTU to the DNS server. This is incomplete: DNS queries above the 1232-byte limit still perform the same query four times. Change-Id: I3e3bfef633af4130a03afffd175e72f7fbc9265d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup/Unix large replies: use res_nmkquery & res_nsend [1/3]Thiago Macieira2023-05-261-14/+47
| | | | | | | | | | | | | | | | | | | | The current code is inefficient when dealing with replies exceeding the PACKETSZ default size and especially those that require the use of a Virtual Circuit (TCP socket). When the TC (Truncated) bit is set in the DNS reply header, res_nquery() automatically switches to VC so it is able to return the full size of the reply to us. This means we make the same request four times: 1) over UDP, getting ~512 bytes of data 2) over TCP, getting the full reply but returning ~512 to us 3) over UDP again, getting (maybe) 1400 bytes of data 4) over TCP again, getting all the data This commit splits res_nquery() into its two component functions, res_nmkquery() and res_nsend(). This is incomplete: the four queries above still happen. Change-Id: I3e3bfef633af4130a03afffd175e728d96d6a604 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup: centralize printing of warningsThiago Macieira2023-05-234-14/+44
| | | | | | | | | | 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-232-53/+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-233-19/+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-235-15/+96
| | | | | | | | | | | | | | 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-234-142/+118
| | | | | | | | 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/Windows: add missing typedefs for older mingwSamuli Piippo2023-05-221-0/+11
| | | | | | | | | | | | | | | | | | Amend 9a73bc5f3d48f6ccaef02871ad62284dd61eff38 with more typedefs missing from older mingw headers: | src/network/kernel/qdnslookup_win.cpp:40:3: error: 'PDNS_QUERY_COMPLETION_ROUTINE' does not name a type; did you mean 'LPOVERLAPPED_COMPLETION_ROUTINE'? | 40 | PDNS_QUERY_COMPLETION_ROUTINE pQueryCompletionCallback; | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | src/network/kernel/qdnslookup_win.cpp:47:9: error: 'PDNS_QUERY_RESULT' has not been declared | 47 | PDNS_QUERY_RESULT pQueryResults, | | ^~~~~~~~~~~~~~~~~ | src/network/kernel/qdnslookup_win.cpp:77:5: error: 'DNS_QUERY_RESULT' was not declared in this scope; did you mean 'DNS_QUERY_REQUEST'? | 77 | DNS_QUERY_RESULT results = {}; | | ^~~~~~~~~~~~~~~~ Change-Id: I812525aaa938764d337923820d0eb8b3e24a0004 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDnsLookup: reject looking up domain names that are too longThiago Macieira2023-05-162-1/+4
| | | | | | | | | | | | | | | | | 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-165-17/+16
| | | | | | | Simplifies arguments and will allow me to add stateful helper methods. Change-Id: I3e3bfef633af4130a03afffd175d6044829a96f2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup/Windows: don't append domain search suffixesThiago Macieira2023-05-161-1/+1
| | | | | | | | | | | | The Unix code doesn't do that. [ChangeLog][Important Behavior Changes] QDnsLookup on Windows will no longer append the system's configured domain name for look ups that contained only a single label (that is, no dots). This matches the Unix behavior. Change-Id: I5f7f427ded124479baa6fffd175f69e537cf9ca2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup/Unix: rework the buffer-size check codeThiago Macieira2023-05-161-34/+31
| | | | | | | | | | | | | | | | | This is neater with a simple offset and avoids the potential UB code this was carrying in: p += size; (p < response + responseLength) It's UB to add to a pointer a size that moves it past the end of its array. In practice we don't expect this to happen because of construction (p is always pointing to a heap or auxiliary-thread stack buffer), but in theory it could happen that said buffer is too close to the end of the virtual address space and adding `size` causes it to overflow back to small values. Change-Id: I5f7f427ded124479baa6fffd175f59939c15c666 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup/Unix: modernize with qFromBigEndianThiago Macieira2023-05-151-10/+10
| | | | | | | Instead of explicit code. Change-Id: I3e3bfef633af4130a03afffd175d515f846a629a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup/Unix: do skip DNS records that aren't of class INThiago Macieira2023-05-151-0/+3
| | | | | | | | | | | | There's nothing saying the server can't supply those to us, so let's explicitly skip them. The Windows version already does this because the windns.h API only supports records of class IN. Test for this after setNameserverPort() is added. Pick-to: 6.5 Change-Id: I3e3bfef633af4130a03afffd175e6ddc756c91c5 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup/Windows: use DnsQueryEx so IPv6 servers are supportedThiago Macieira2023-05-141-19/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar test with link-local server on the same network: $ $objdir/tests/manual/qdnslookup/qdnslookup.exe @fe80::1e1b:dff:fee2:49e6%Ethernet ; <<>> QDnsLookup 6.6.0 <<>> qdnslookup @fe80::1e1b:dff:fee2:49e6%Ethernet ;; status: NoError ;; QUESTION: ;qt-project.org IN A ;; ANSWER: qt-project.org 3532 IN A 52.18.144.254 ;; Query time: 17 ms ;; SERVER: fe80::1e1b:dff:fee2:49e6%Ethernet#53 Server's dnsmasq log shows it was queried. We don't know why we must set the port to 0. It works for me the regular way, but not for everyone who tested this patch. [ChangeLog][QtNetwork][QDnsLookup] setNameserver() now supports IPv6 servers with on Apple systems, AIX, FreeBSD, NetBSD, Solaris, and Windows. (AIX, NetBSD and Solaris not directly tested, but their docs online show they have res_setservers()) Change-Id: I3e3bfef633af4130a03afffd175d5bfd4e7922b9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup/Unix: add support for res_setservers()Thiago Macieira2023-05-141-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | This API is found on FreeBSD, Darwin, Solaris, AIX, and Android Bionic. That means we complement IPv6 support for most platforms. Test on macOS: $ $objdir/tests/manual/qdnslookup/qdnslookup @fe80::1e1b:dff:fee2:49e6%en0 ; <<>> QDnsLookup 6.6.0 ;; status: NoError ;; QUESTION: ;qt-project.org IN A ;; ANSWER: qt-project.org 3336 IN A 52.18.144.254 ;; Query time: 2 ms ;; SERVER: fe80::1e1b:dff:fee2:49e6%en0#53 Dnsmasq log on the server confirms it was queried. Change-Id: I3e3bfef633af4130a03afffd175d59c67faa463f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup/Unix: modernize the setting of IPv6 server addressesThiago Macieira2023-05-142-38/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of using #if, this now uses SFINAE to detect the presence of the glibc extensions to set IPv6 nameserver addresses. It's also possible that this fixes some bugs that have always been there, but never checked because we don't have a way to unit-test explicit name servers. To that effect, this commit adds a manual unit test that mimics the BIND tool "dig". When running: ./qdnslookup qt-project.org any @dns.google it printed for me: ; <<>> QDnsLookup 6.6.0 ;; status: NoError ;; QUESTION: ;qt-project.org IN ANY ;; ANSWER: qt-project.org 3600 IN MX 10 mx.qt-project.org qt-project.org 3600 IN NS ns14.cloudns.net qt-project.org 3600 IN NS ns11.cloudns.net qt-project.org 3600 IN NS ns12.cloudns.net qt-project.org 3600 IN NS ns13.cloudns.net qt-project.org 3600 IN A 52.18.144.254 qt-project.org 3600 IN TXT "v=spf1 mx ip4:193.209.87.4 include:spf.protection.outlook.com ~all" ;; Query time: 241 ms ;; SERVER: 2001:4860:4860::8844#53 strace confirms the DNS queries were sent to the correct address. Change-Id: I3e3bfef633af4130a03afffd175d56a92371ed16 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDnsLookup/Unix: make sure we don't overflow the bufferThiago Macieira2023-05-141-6/+25
| | | | | | | | | | | | | | | | | The DNS Records are variable length and encode their size in 16 bits before the Record Data (RDATA). Ensure that both the RDATA and the Record header fields before it fall inside the buffer we have. Additionally reject any replies containing more than one query records. [ChangeLog][QtNetwork][QDnsLookup] Fixed a bug that could cause a buffer overflow in Unix systems while parsing corrupt, malicious, or truncated replies. Pick-to: 5.15 6.2 6.5 6.5.1 Change-Id: I3e3bfef633af4130a03afffd175e4b9547654b95 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* QDnsLookup: remove the #if QT_CONFIG(thread) checkThiago Macieira2023-05-142-9/+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-132-4/+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>
* QDnsLookup: treat NOTIMP replies as server failuresThiago Macieira2023-05-112-0/+2
| | | | | | | | "Not implemented" is not "invalid reply". Pick-to: 6.5 Change-Id: I3e3bfef633af4130a03afffd175e2687e7585f36 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Network: link directly to libresolv instead of dlopen()ing itAmir Masoud Abdol2023-05-113-274/+86
| | | | | | | | | | | | | | | | | | There's little need for us to dynamically load it. The reasons why that was necessary aren't in the public history (Qt 4.5 already had it[1]). I remember writing the code in 2007-2008, I just don't remember why. On modern Linux and FreeBSD, there's no libresolv.so any more and those symbols have been rolled up into libc.so. It's still necessary on Darwin systems, so this commit introduces WrapResolv. It also resolves the unity build issues relating to libresolv symbols. [1] https://code.qt.io/cgit/qt/qt.git/tree/src/network/kernel/qhostinfo_unix.cpp?h=v4.5.1 Task-number: QTBUG-109394 Change-Id: Ic5799e4d000b6c9395109e008780643bac52122b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Rename QFunctorSlotObject to QCallableObjectVolker Hilsheimer2023-05-101-1/+1
| | | | | | | | | | | | | | After the recent changes we only have a single implementation of QSlotObjectBase, which can handle free functions, member functions, functors, and lambdas. Rename it to callable, and explicitly hide the static implementation function so that it doesn't become a symbol of static libraries using Qt. Also rename makeSlotObject to makeCallableObject, and polish coding style and comments in the qobjectdefs_impl header a bit. Change-Id: Id19107cedfe9c624f807cd8089beb80e9eb99f50 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Fix documentation warningsTopi Reinio2023-04-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These warnings slipped in during a time period where documentation testing in the CI was disabled. src/network/kernel/qhostinfo.cpp:254: (qdoc) warning: clang couldn't find function when parsing \fn template<typename Functor> int QHostInfo::lookupHost(const QString &name, Functor functor) src/widgets/widgets/qcheckbox.cpp:102: (qdoc) warning: clang couldn't find function when parsing \fn void QCheckBox::stateChanged(Qt::CheckState state) src/corelib/kernel/qcoreapplication.cpp:2769: (qdoc) warning: clang couldn't find function when parsing \fn template<typename Functor> void QCoreApplication::requestPermission( const QPermission &permission, Functor functor) src/corelib/serialization/qxmlstream.cpp:3806: (qdoc) warning: clang couldn't find function when parsing \fn bool QXmlStreamAttributes::hasAttribute( const QString &qualifiedName) const src/corelib/text/qtliterals.qdoc:11: (qdoc) warning: Multiple topic commands found in comment: \namespace and \headerfile. Pick-to: 6.5 Change-Id: I38c605f358dbca1ef3e2bfe20a6424f7a4d44b4a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add a helper for better error messages when functor is incompatibleVolker Hilsheimer2023-04-281-0/+1
| | | | | | | | | | | | Amends 207aae5560aa2865ec55ddb9ecbb50048060c0c0 to make it easy to create human-friendly error messages. Since the functor-accepting member functions are not removed from the API, the first compile error will be that there is no suitable overload of the makeSlotObject helper, which. With the assert helper, the first error message is easier to understand. Change-Id: I4878ec35a44ddfa5dc9d9e358d81c3fd40389c0c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Support free functions and const functors as callbacksVolker Hilsheimer2023-04-281-4/+4
| | | | | | | | | | | | | | | | | | Amend 207aae5560aa2865ec55ddb9ecbb50048060c0c0, as code checker complained that we std::move'd a potential lvalue. This warning was valid if the public API did not accept the functor parameter by value. Fix this by consistently std::forward'ing the parameters through the call stack, and add a compile-time test. Writing that test revealed that the helper API didn't work with free functions, so fix that as well. It also revealed that QFunctorSlotObject couldn't work with a const functor, which is also fixed by this change. We cannot support move-only functors with that change, as it requires a change to QFunctorSlotObject that breaks the QMetaObject test. Change-Id: Iafd747baf4cb0213ecedb391ed46b4595388182b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify the creation of APIs that take a callbackVolker Hilsheimer2023-04-261-43/+11
| | | | | | | | | | | | | | | | | | | | | | | Functions in Qt that take a callback need to support callables with or without context objects, and member functions of an object. The implementation of those overloads follows a pattern that ultimately results in a QSlotObjectBase implementation being created and passed to an implementation helper that takes care of the logic. Factor that common pattern into a new helper template in QtPrivate that returns a suitable QSlotObjectBase after checking that the functor is compatible with the specified argument types. Use that new helper template in the implementation of QCoreApplication::requestPermission and QHostInfo::lookupHost. The only disadvantage of centralizing this logic is that we cannot print a more detailed error message indicating which argument types the caller expects. However, that information is visible from the detailed compiler errors anyway. Change-Id: I24cf0b2442217857b96ffc4d2d6c997c4fae34e0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add helper template for metacall event creationVolker Hilsheimer2023-04-181-11/+1
| | | | | | | | | | Setting up the args and types arrays is cumbersome and error prone, and we do it at least twice in qtbase. Provide a central implementation as a variadic template function, and make it exception-safe with a unique_ptr (the destructor of QMetaCallEvent will destroy the cloned arguments). Change-Id: I5ff400467928446264eaedddb394691e9e23d22e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add test function for private networkYAMAMOTO Atsushi2023-03-112-7/+26
| | | | | | | | | | Add a function QHostAddress::isPrivateUse to test for IPv4 private networks and IPv6 unique local unicast addresses. Task-number: QTBUG-111211 Change-Id: Ic8abefa7aa974fa83118aeb9f2506a5713f79f0d Reviewed-by: Tasuku Suzuki <tasuku.suzuki@signal-slot.co.jp> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNetworkInterface/Unix: replace one Q_ASSERT with static_assertsThiago Macieira2023-03-041-1/+2
| | | | | | | | | | This requires compilers with constexpr offsetof(), which Clang seems to be since at least 3.0 and GCC since 4.7, both of which are way older than anything we need to support. Pick-to: 6.5 Change-Id: I7f354474adce419ca6c2fffd1748b3dcfc616f4a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Doc: Remove duplicate wordsAndreas Eliasson2023-02-281-1/+1
| | | | | | Change-Id: Ia7a38a1035bd34d00f20351a0adc3927e473b2e7 Pick-to: 6.5 6.4 6.2 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QtNetwork: Split out QNativeSocketEnginePrivateFriedemann Kleint2023-02-021-1/+1
| | | | | | | | | | | The aim is to have fewer files including <windows.h>. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Id9cc08f54b5daf6d7e317fad27036dc2efaacbb8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove redundant qsharedpointer.h #includesAhmad Samir2023-01-313-4/+0
| | | | | | | In some cases added #include <QtCore/qshareddata.h>. Change-Id: Idc84c4ad6b0bd58e1a67af335dfcff67fdf80b2a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtNetwork: Disambiguate static variablesFriedemann Kleint2023-01-311-4/+4
| | | | | | | | | They causes clashes in CMake Unity (Jumbo) builds. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Ifd0539c3b56dc395a860de927736f60ad766224a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qnetworkproxy_mac: use API available both on iOS and macOSTimur Pocheptsov2023-01-302-39/+95
| | | | | | | | | | | | | | | To extract system proxies, the one we used previously, was not available on iOS and thus we could not obtain system proxies there. Support is limited - no such things, as SOCKS/FTP/etc. proxies, only PAC (auto configuration), and HTTP/HTTPS. There are no keys to extract info about HTTPS, so instead we'll use CFNetworkCopyProxiesForURL ( looks like this enables exclusion lists (which are hidden) functionality and apparently from the system point of view HTTP/HTTPS are the same. Fixes: QTBUG-39869 Change-Id: I73af719a2e2b5cded706e6b3faa4b8eaa879352b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Update description of topleveldomain featurePeter Varga2023-01-172-5/+2
| | | | | | | | | | | | qTopLevelDomain() is misleading in the configure summary. The function has been removed by commit 50b3097683 Also clean up the topleveldomain files. Pick-to: 6.5 Change-Id: Ib577962909a83f4f41d1660a26fd80b37803ae18 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Export QAuthenticatorPrivate for use in QtWebSocketsMårten Nordheim2022-12-151-1/+1
| | | | | Change-Id: I0e3e35d2b9d0fdce37ede5781b86741f7604257d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QHostAddress: unexport QIPv6AddressThiago Macieira2022-11-181-1/+1
| | | | | | | | Only affect MSVC anyway. For all the others, since everything is inline, there's nothing to import or export. Change-Id: Id8e48e8f498c4a029619fffd17288befde9b5f83 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Windows: centralize how we handle error messagesYuhang Zhao2022-11-161-15/+10
| | | | | | | | | | | | | | | | Currently QtBase contains multiple implementation of how to get the Win32 and COM error messages, and they are almost exactly the same, what's worse, Qt already has a private QSystemError class to do such things, so we are re-inventing the wheel in many places. This patch removes all other custom error message implementations besides the QSystemError one. And since there are a lot of places need the COM error message, move the implementation to QSystemError so that it can handle both Win32 error and COM error. Since I'm touching these lines anyway, break them into short lines if they are above the length limit. Change-Id: I1067c874011800303f0f114b5cb8830ac6810fc0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QHostAddress: Fix incorrect comparison against 'Any'Mårten Nordheim2022-11-021-1/+1
| | | | | | | | | | | | When 'this' is IPv6 and 'other' is Any then there is no point in testing 'other's IPv6 address. Added extra tests against QHostAddress::Any*. Pick-to: 6.4 6.2 5.15 Fixes: QTBUG-108103 Change-Id: I09f32b1b147b1ec8380546c91cd89684a6bebe2e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace usages of Q_CLANG_QDOC with Q_QDOCLuca Di Sera2022-10-212-2/+2
| | | | | | | | | | | | | | | | | | | | | | | To allow the user to customize the C++ code that QDoc sees, so as to be able to work-around some limitations on QDoc itself, QDoc defines two symbols: Q_QDOC and Q_CLANG_QDOC, both of which are "true" during an entire execution of QDoc. At a certain point in time, QDoc allowed the user the choice between a custom C++ parser and a Clang based one. The Q_QDOC symbol would always be defined while the Q_CLANG_QDOC symbol would be defined only when the Clang based parser was chosen. In more recent times, QDoc always uses a Clang based parser, such that both Q_CLANG_QDOC and Q_QDOC are always defined, making them equivalent. To avoid using different symbols, and the possible confusion and fragmentation that derives from it, all usages of Q_CLANG_QDOC are now replaced by the equivalent usages of Q_QDOC. Change-Id: I5810abb9ad1016a4c5bbea99acd03381b8514b3f Reviewed-by: Kai Koehne <kai.koehne@qt.io>