1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=4 sw=2 sts=2 et cin: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "GetAddrInfo.h"
8 #include "mozilla/net/DNSPacket.h"
9 #include "nsIDNSService.h"
10 #include "mozilla/Maybe.h"
15 #include <netinet/in.h>
18 namespace mozilla::net
{
20 #define LOG(msg, ...) \
21 MOZ_LOG(gGetAddrInfoLog, LogLevel::Debug, ("[DNS]: " msg, ##__VA_ARGS__))
23 nsresult
ResolveHTTPSRecordImpl(const nsACString
& aHost
, uint16_t aFlags
,
24 TypeRecordResultType
& aResult
, uint32_t& aTTL
) {
26 nsAutoCString
host(aHost
);
30 LOG("resolving %s\n", host
.get());
32 rv
= packet
.FillBuffer(
33 [&](unsigned char response
[DNSPacket::MAX_SIZE
]) -> int {
36 len
= res_nquery(&_res
, host
.get(), ns_c_in
,
37 nsIDNSService::RESOLVE_TYPE_HTTPSSVC
, response
,
39 #elif defined(XP_MACOSX)
41 res_query(host
.get(), ns_c_in
, nsIDNSService::RESOLVE_TYPE_HTTPSSVC
,
42 response
, DNSPacket::MAX_SIZE
);
46 LOG("DNS query failed");
54 return ParseHTTPSRecord(host
, packet
, aResult
, aTTL
);
57 } // namespace mozilla::net