summaryrefslogtreecommitdiffstats
path: root/netwerk/dns/nsIDNSService.idl
blob: c1aecccd8c335894c9882e004eee9f96c6f1efdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "nsIRequest.idl"
#include "nsITRRSkipReason.idl"

%{ C++
#include "mozilla/BasePrincipal.h"
#include "mozilla/TypedEnumBits.h"
%}

interface nsICancelable;
interface nsIEventTarget;
interface nsIDNSRecord;
interface nsIDNSListener;
interface nsIDNSAdditionalInfo;

%{C++
#include "nsTArrayForwardDeclare.h"
namespace mozilla { namespace net {
    struct DNSCacheEntries;
} }
%}

[ptr] native EntriesArray(nsTArray<mozilla::net::DNSCacheEntries>);
[ref] native OriginAttributes(const mozilla::OriginAttributes);

/**
 * nsIDNSService
 */
[scriptable, builtinclass, uuid(de5642c6-61fc-4fcf-9a47-03226b0d4e21)]
interface nsIDNSService : nsISupports
{
    /**
     * These are the dns request types that are currently supported.
     * RESOLVE_TYPE_DEFAULT is standard A/AAAA lookup
     */
    cenum ResolveType : 16 {
        RESOLVE_TYPE_DEFAULT = 0,
        RESOLVE_TYPE_TXT = 16,
        RESOLVE_TYPE_HTTPSSVC = 65,
    };

    cenum ResolverMode : 32 { // 32 bits to allow this to be stored in an Atomic
        MODE_NATIVEONLY = 0,  // TRR OFF (by default)
        MODE_RESERVED1 = 1,   // Reserved value. Used to be parallel resolve.
        MODE_TRRFIRST = 2,    // fallback to native on TRR failure
        MODE_TRRONLY = 3,     // don't even fallback
        MODE_RESERVED4 = 4,   // Reserved value. Used to be race TRR with native.
        MODE_TRROFF = 5       // identical to MODE_NATIVEONLY but explicitly selected
    };

    cenum DNSFlags : 32 {
        RESOLVE_DEFAULT_FLAGS = 0,
        // if set, this flag suppresses the internal DNS lookup cache.
        RESOLVE_BYPASS_CACHE = (1 << 0),
        // if set, the canonical name of the specified host will be queried.
        RESOLVE_CANONICAL_NAME = (1 << 1),
        // If PRIORITY flags are set, the query is given lower priority.
        // Medium takes precedence if both MEDIUM and LOW are used.
        RESOLVE_PRIORITY_MEDIUM = (1 << 2),
        RESOLVE_PRIORITY_LOW    = (1 << 3),
        // if set, indicates request is speculative. Speculative requests
        // return errors if prefetching is disabled by configuration.
        RESOLVE_SPECULATE = (1 << 4),
        // If set, only IPv4 addresses will be returned from resolve/asyncResolve.
        RESOLVE_DISABLE_IPV6 = (1 << 5),
        // If set, only literals and cached entries will be returned from resolve/asyncResolve.
        RESOLVE_OFFLINE = (1 << 6),
        // If set, only IPv6 addresses will be returned from resolve/asyncResolve.
        RESOLVE_DISABLE_IPV4 = (1 << 7),
        // If set, allow name collision results (127.0.53.53) which are normally filtered.
        RESOLVE_ALLOW_NAME_COLLISION = (1 << 8),
        // If set, do not use TRR for resolving the host name.
        RESOLVE_DISABLE_TRR = (1 << 9),
        // if set (together with RESOLVE_BYPASS_CACHE), invalidate the DNS
        // existing cache entry first (if existing) then make a new resolve.
        RESOLVE_REFRESH_CACHE = (1 << 10),
        // These two bits encode the TRR mode of the request.
        // Use the static helper methods GetFlagsFromTRRMode and
        // GetTRRModeFromFlags to convert between the TRR mode and flags.
        RESOLVE_TRR_MODE_MASK = (1 << 11) | (1 << 12),
        RESOLVE_TRR_DISABLED_MODE = (1 << 11),
        // Force resolution even when SOCKS proxy with DNS forwarding is configured.
        // Only to be used for the proxy host resolution.
        RESOLVE_IGNORE_SOCKS_DNS = (1 << 13),
        // If set, only cached IP hint addresses will be returned from resolve/asyncResolve.
        RESOLVE_IP_HINT = (1 << 14),
        // If set, the DNS service will pass a DNS record to
        // OnLookupComplete even when there was a resolution error.
        RESOLVE_WANT_RECORD_ON_ERROR = (1 << 16),

        // Bitflag containing all possible flags.
        ALL_DNSFLAGS_BITS = ((1 << 17) - 1),
    };

    cenum ConfirmationState : 8 {
        CONFIRM_OFF = 0,
        CONFIRM_TRYING_OK = 1,
        CONFIRM_OK = 2,
        CONFIRM_FAILED = 3,
        CONFIRM_TRYING_FAILED = 4,
        CONFIRM_DISABLED = 5,
    };

    /**
     * kicks off an asynchronous host lookup.
     *
     * @param aHostName
     *        the hostname or IP-address-literal to resolve.
     * @param aType
     *        one of RESOLVE_TYPE_*.
     * @param aFlags
     *        a bitwise OR of the RESOLVE_ prefixed constants defined below.
     * @param aInfo
     *        a AdditionalInfo object that holds information about:
     *         - the resolver to be used such as TRR URL
     *         - the port number that could be used to construct a QNAME
     *           for HTTPS RR
     *        If null we use the default configuration.
     * @param aListener
     *        the listener to be notified when the result is available.
     * @param aListenerTarget
     *        optional parameter (may be null).  if non-null, this parameter
     *        specifies the nsIEventTarget of the thread on which the
     *        listener's onLookupComplete should be called.  however, if this
     *        parameter is null, then onLookupComplete will be called on an
     *        unspecified thread (possibly recursively).
     * @param aOriginAttributes
     *        the originAttribute for this resolving, the DNS cache will be
     *        separated according to this originAttributes. This attribute is
     *        optional to avoid breaking add-ons.
     *
     * @return An object that can be used to cancel the host lookup.
     */
    [implicit_jscontext, optional_argc]
    nsICancelable asyncResolve(in AUTF8String       aHostName,
                               in nsIDNSService_ResolveType aType,
                               in nsIDNSService_DNSFlags aFlags,
                               in nsIDNSAdditionalInfo aInfo,
                               in nsIDNSListener    aListener,
                               in nsIEventTarget    aListenerTarget,
                    [optional] in jsval aOriginAttributes);

    [notxpcom]
    nsresult asyncResolveNative(in AUTF8String       aHostName,
                                in nsIDNSService_ResolveType aType,
                                in nsIDNSService_DNSFlags aFlags,
                                in nsIDNSAdditionalInfo aInfo,
                                in nsIDNSListener    aListener,
                                in nsIEventTarget    aListenerTarget,
                                in OriginAttributes  aOriginAttributes,
                                out nsICancelable    aResult);

    /**
     * Returns a new nsIDNSAdditionalInfo object containing the URL we pass to it.
     */
    nsIDNSAdditionalInfo newAdditionalInfo(in AUTF8String aTrrURL,
                                           in int32_t aPort);

    /**
     * Attempts to cancel a previously requested async DNS lookup
     *
     * @param aHostName
     *        the hostname or IP-address-literal to resolve.
     * @param aType
     *        one of RESOLVE_TYPE_*.
     * @param aFlags
     *        a bitwise OR of the RESOLVE_ prefixed constants defined below.
     * @param aInfo
     *        a AdditionalInfo object that holds information about:
     *         - the resolver to be used such as TRR URL
     *         - the port number that could be used to construct a QNAME
     *           for HTTPS RR
     *        If null we use the default configuration.
     * @param aListener
     *        the original listener which was to be notified about the host lookup
     *        result - used to match request information to requestor.
     * @param aReason
     *        nsresult reason for the cancellation
     * @param aOriginAttributes
     *        the originAttribute for this resolving. This attribute is optional
     *        to avoid breaking add-ons.
     */
    [implicit_jscontext, optional_argc]
    void cancelAsyncResolve(in AUTF8String       aHostName,
                            in nsIDNSService_ResolveType aType,
                            in nsIDNSService_DNSFlags aFlags,
                            in nsIDNSAdditionalInfo aResolver,
                            in nsIDNSListener    aListener,
                            in nsresult          aReason,
                 [optional] in jsval             aOriginAttributes);

    [notxpcom]
    nsresult cancelAsyncResolveNative(in AUTF8String       aHostName,
                                      in nsIDNSService_ResolveType aType,
                                      in nsIDNSService_DNSFlags aFlags,
                                      in nsIDNSAdditionalInfo aResolver,
                                      in nsIDNSListener    aListener,
                                      in nsresult          aReason,
                                      in OriginAttributes  aOriginAttributes);

    /**
     * called to synchronously resolve a hostname.
     *
     * Since this method may block the calling thread for a long period of
     * time, it may not be accessed from the main thread.
     *
     * @param aHostName
     *        the hostname or IP-address-literal to resolve.
     * @param aFlags
     *        a bitwise OR of the RESOLVE_ prefixed constants defined below.
     * @param aOriginAttributes
     *        the originAttribute for this resolving, the DNS cache will be
     *        separated according to this originAttributes. This attribute is
     *        optional to avoid breaking add-ons.
     *
     * @return DNS record corresponding to the given hostname.
     * @throws NS_ERROR_UNKNOWN_HOST if host could not be resolved.
     * @throws NS_ERROR_NOT_AVAILABLE if accessed from the main thread.
     */
    [implicit_jscontext, optional_argc]
    nsIDNSRecord resolve(in AUTF8String   aHostName,
                         in nsIDNSService_DNSFlags aFlags,
              [optional] in jsval         aOriginAttributes);

    [notxpcom]
    nsresult resolveNative(in AUTF8String       aHostName,
                           in nsIDNSService_DNSFlags aFlags,
                           in OriginAttributes  aOriginAttributes,
                           out nsIDNSRecord     aResult);

    /**
     * The method takes a pointer to an nsTArray
     * and fills it with cache entry data
     * Called by the networking dashboard
     */
    [noscript] void getDNSCacheEntries(in EntriesArray args);


    /**
     * Clears the DNS cache.
     * @param aTrrToo
     *        If true we will clear TRR cached entries too. Since these
     *        are resolved remotely it's not necessary to clear them when
     *        the network status changes, but it's sometimes useful to do so
     *        for tests or other situations.
     */
    void clearCache(in boolean aTrrToo);

    /**
     * The method is used only for test purpose. We use this to recheck if
     * parental control is enabled or not.
     */
    void reloadParentalControlEnabled();

    /**
     * Notifies the TRR service of a TRR that was automatically detected based
     * on network preferences.
     */
    void setDetectedTrrURI(in AUTF8String aURI);

    /**
     * Stores the result of the TRR heuristic detection.
     * Will be TRR_OK if no heuristics failed.
     */
    void setHeuristicDetectionResult(in nsITRRSkipReason_value value);

    /**
     * Returns the result of the last TRR heuristic detection.
     * Will be TRR_OK if no heuristics failed.
     */
    readonly attribute nsITRRSkipReason_value heuristicDetectionResult;

    ACString getTRRSkipReasonName(in nsITRRSkipReason_value value);

    /**
     * The channel status of the last TRR confirmation attempt.
     * In strict mode it reflects the channel status of the last TRR request.
     */
    readonly attribute nsresult lastConfirmationStatus;

    /**
     * The TRR skip reason of the last TRR confirmation attempt.
     * In strict mode it reflects the TRR skip reason of the last TRR request.
     */
    readonly attribute nsITRRSkipReason_value lastConfirmationSkipReason;

    /**
     * Notifies the DNS service that we failed to connect to this alternative
     * endpoint.
     * @param aOwnerName
     *        The owner name of this HTTPS RRs.
     * @param aSVCDomainName
     *        The domain name of this alternative endpoint.
     */
    [noscript] void ReportFailedSVCDomainName(in ACString aOwnerName,
                                              in ACString aSVCDomainName);

    /**
     * Check if the given domain name was failed to connect to before.
     * @param aOwnerName
     *        The owner name of this HTTPS RRs.
     * @param aSVCDomainName
     *        The domain name of this alternative endpoint.
     */
    [noscript] boolean IsSVCDomainNameFailed(in ACString aOwnerName,
                                             in ACString aSVCDomainName);

    /**
     * Reset the exclusion list.
     * @param aOwnerName
     *        The owner name of this HTTPS RRs.
     */
    [noscript] void ResetExcludedSVCDomainName(in ACString aOwnerName);

    /**
     * Returns a string containing the URI currently used by the TRR service.
     */
    readonly attribute AUTF8String currentTrrURI;

    /**
     * Returns the value of the TRR Service's current default mode.
     */
    readonly attribute nsIDNSService_ResolverMode currentTrrMode;

    /**
     * The TRRService's current confirmation state.
     * This is mostly for testing purposes.
     */
    readonly attribute unsigned long currentTrrConfirmationState;

    /**
     * @return the hostname of the operating system.
     */
    readonly attribute AUTF8String myHostName;

    /**
     * returns the current TRR domain.
     */
    readonly attribute ACString trrDomain;

    /**
     * returns the telemetry key for current TRR domain.
     */
    readonly attribute ACString TRRDomainKey;

    /*************************************************************************
     * Listed below are the various flags that may be OR'd together to form
     * the aFlags parameter passed to asyncResolve() and resolve().
     */

%{C++
    static nsIDNSService::DNSFlags GetFlagsFromTRRMode(nsIRequest::TRRMode aMode) {
        return static_cast<nsIDNSService::DNSFlags>(static_cast<uint32_t>(aMode) << 11);
    }

    static nsIRequest::TRRMode GetTRRModeFromFlags(nsIDNSService::DNSFlags aFlags) {
        return static_cast<nsIRequest::TRRMode>((aFlags & RESOLVE_TRR_MODE_MASK) >> 11);
    }
%}

};

%{C++

/**
 * An observer notification for this topic is sent whenever the URI that the
 * TRR service is using has changed.
 */
#define NS_NETWORK_TRR_URI_CHANGED_TOPIC "network:trr-uri-changed"

/**
 * An observer notification for this topic is sent whenever the mode that the
 * TRR service is using has changed.
 */
#define NS_NETWORK_TRR_MODE_CHANGED_TOPIC "network:trr-mode-changed"

MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(nsIDNSService::DNSFlags)

%}