1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et tw=80 : */
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 #ifndef nsDNSService2_h__
8 #define nsDNSService2_h__
10 #include "nsClassHashtable.h"
11 #include "nsPIDNSService.h"
12 #include "nsIIDNService.h"
13 #include "nsIMemoryReporter.h"
14 #include "nsIObserver.h"
15 #include "nsHostResolver.h"
17 #include "nsTHashtable.h"
18 #include "nsHashKeys.h"
19 #include "mozilla/Mutex.h"
20 #include "mozilla/Attributes.h"
21 #include "TRRService.h"
25 class nsDNSService final
: public nsPIDNSService
,
27 public nsIMemoryReporter
{
29 NS_DECL_THREADSAFE_ISUPPORTS
30 NS_DECL_NSPIDNSSERVICE
33 NS_DECL_NSIMEMORYREPORTER
37 static already_AddRefed
<nsIDNSService
> GetXPCOMSingleton();
39 size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf
) const;
41 bool GetOffline() const;
44 friend class nsAuthSSPI
;
46 nsresult
DeprecatedSyncResolve(
47 const nsACString
& aHostname
, uint32_t flags
,
48 const mozilla::OriginAttributes
& aOriginAttributes
,
49 nsIDNSRecord
** result
);
54 nsresult
ReadPrefs(const char* name
);
55 static already_AddRefed
<nsDNSService
> GetSingleton();
57 uint16_t GetAFForLookup(const nsACString
& host
, uint32_t flags
);
59 nsresult
PreprocessHostname(bool aLocalDomain
, const nsACString
& aInput
,
60 nsIIDNService
* aIDN
, nsACString
& aACE
);
62 nsresult
AsyncResolveInternal(
63 const nsACString
& aHostname
, uint16_t type
, uint32_t flags
,
64 nsIDNSResolverInfo
* aResolver
, nsIDNSListener
* aListener
,
65 nsIEventTarget
* target_
,
66 const mozilla::OriginAttributes
& aOriginAttributes
,
67 nsICancelable
** result
);
69 nsresult
CancelAsyncResolveInternal(
70 const nsACString
& aHostname
, uint16_t aType
, uint32_t aFlags
,
71 nsIDNSResolverInfo
* aResolver
, nsIDNSListener
* aListener
,
72 nsresult aReason
, const mozilla::OriginAttributes
& aOriginAttributes
);
74 nsresult
ResolveInternal(const nsACString
& aHostname
, uint32_t flags
,
75 const mozilla::OriginAttributes
& aOriginAttributes
,
76 nsIDNSRecord
** result
);
78 bool DNSForbiddenByActiveProxy(const nsACString
& aHostname
, uint32_t flags
);
80 RefPtr
<nsHostResolver
> mResolver
;
81 nsCOMPtr
<nsIIDNService
> mIDN
;
83 // mLock protects access to mResolver, mLocalDomains, mIPv4OnlyDomains and
84 // mFailedSVCDomainNames
87 // mIPv4OnlyDomains is a comma-separated list of domains for which only
88 // IPv4 DNS lookups are performed. This allows the user to disable IPv6 on
89 // a per-domain basis and work around broken DNS servers. See bug 68796.
90 nsCString mIPv4OnlyDomains
;
91 nsCString mForceResolve
;
93 bool mDisablePrefetch
;
95 bool mNotifyResolution
;
96 bool mOfflineLocalhost
;
98 nsTHashtable
<nsCStringHashKey
> mLocalDomains
;
99 RefPtr
<mozilla::net::TRRService
> mTrrService
;
100 mozilla::Atomic
<bool, mozilla::Relaxed
> mHasSocksProxy
;
102 uint32_t mResCacheEntries
;
103 uint32_t mResCacheExpiration
;
104 uint32_t mResCacheGrace
;
105 bool mResolverPrefsUpdated
;
106 nsClassHashtable
<nsCStringHashKey
, nsTArray
<nsCString
>> mFailedSVCDomainNames
;
109 #endif // nsDNSService2_h__