@@ -13,16 +13,7 @@ import scala.scalajs.js.|
13
13
* @see https://nodejs.org/api/dns.html
14
14
*/
15
15
@ js.native
16
- trait DNS extends js.Object {
17
-
18
- // ///////////////////////////////////////////////////////////////////////////////
19
- // Methods
20
- // ///////////////////////////////////////////////////////////////////////////////
21
-
22
- /**
23
- * Returns an array of IP address strings that are being used for name resolution.
24
- */
25
- def getServers (): js.Array [String ] = js.native
16
+ trait DNS extends IResolver {
26
17
27
18
/**
28
19
* Resolves a hostname (e.g. 'nodejs.org') into the first found A (IPv4) or AAAA (IPv6) record. options can be an
@@ -42,7 +33,7 @@ trait DNS extends js.Object {
42
33
* All properties are optional.
43
34
* @example dns.lookup(hostname[, options], callback)
44
35
*/
45
- def lookup (hostname : String , options : DnsOptions | Int , callback : DnsCallback1 [String ]): Unit = js.native
36
+ def lookup (hostname : String , options : DnsOptions | Int , callback : DnsCallback2 [String , Int ]): Unit = js.native
46
37
47
38
/**
48
39
* Resolves a hostname (e.g. 'nodejs.org') into the first found A (IPv4) or AAAA (IPv6) record. options can be an
@@ -79,156 +70,6 @@ trait DNS extends js.Object {
79
70
* @example dns.lookupService('127.0.0.1', 22, (err, hostname, service) => { ... })
80
71
*/
81
72
def lookupService (address : String , port : Int , callback : DnsCallback2 [String , String ]): Unit = js.native
82
-
83
- /**
84
- * Uses the DNS protocol to resolve a hostname (e.g. 'nodejs.org') into an array of the record types specified by rrtype.
85
- * On error, err is an Error object, where err.code is one of the error codes listed here.
86
- * @param hostname the hostname
87
- * @param rrtype the given rrtype
88
- * Valid values for rrtype are:
89
- * 'A' - IPV4 addresses, default
90
- * 'AAAA' - IPV6 addresses
91
- * 'MX' - mail exchange records
92
- * 'TXT' - text records
93
- * 'SRV' - SRV records
94
- * 'PTR' - PTR records
95
- * 'NS' - name server records
96
- * 'CNAME' - canonical name records
97
- * 'SOA' - start of authority record
98
- * 'NAPTR' - name authority pointer record
99
- * @param callback the callback function has arguments (err, addresses). When successful, addresses will be an array.
100
- * The type of each item in addresses is determined by the record type, and described in the
101
- * documentation for the corresponding lookup methods.
102
- * @example dns.resolve(hostname[, rrtype], callback)
103
- */
104
- def resolve [A ](hostname : String , rrtype : RRType , callback : DnsCallback1 [A ]): Unit = js.native
105
-
106
- /**
107
- * Uses the DNS protocol to resolve a hostname (e.g. 'nodejs.org') into an array of the record types specified by rrtype.
108
- * On error, err is an Error object, where err.code is one of the error codes listed here.
109
- * @param hostname the hostname
110
- * @param callback the callback function has arguments (err, addresses). When successful, addresses will be an array. The type of
111
- * each item in addresses is determined by the record type, and described in the documentation for the corresponding
112
- * lookup methods.
113
- * @example dns.resolve(hostname[, rrtype], callback)
114
- */
115
- def resolve (hostname : String , callback : DnsCallback1 [js.Array [String ]]): Unit = js.native
116
-
117
- /**
118
- * Uses the DNS protocol to resolve a IPv4 addresses (A records) for the hostname. The addresses argument passed to
119
- * the callback function will contain an array of IPv4 addresses (e.g. ['74.125.79.104', '74.125.79.105', '74.125.79.106']).
120
- * @example dns.resolve4(hostname, callback)
121
- */
122
- def resolve4 (hostname : String , callback : DnsCallback1 [js.Array [String ]]): Unit = js.native
123
-
124
- /**
125
- * Uses the DNS protocol to resolve a IPv6 addresses (AAAA records) for the hostname. The addresses argument passed
126
- * to the callback function will contain an array of IPv6 addresses.
127
- * @example dns.resolve6(hostname, callback)
128
- */
129
- def resolve6 (hostname : String , callback : DnsCallback1 [js.Array [String ]]): Unit = js.native
130
-
131
- /**
132
- * Uses the DNS protocol to resolve CNAME records for the hostname. The addresses argument passed to the callback
133
- * function will contain an array of canonical name records available for the hostname (e.g. ['bar.example.com']).
134
- * @example dns.resolveCname(hostname, callback)
135
- */
136
- def resolveCname (hostname : String , callback : DnsCallback1 [js.Array [String ]]): Unit = js.native
137
-
138
- /**
139
- * Uses the DNS protocol to resolve mail exchange records (MX records) for the hostname. The addresses argument
140
- * passed to the callback function will contain an array of objects containing both a priority and exchange property
141
- * (e.g. [{priority: 10, exchange: 'mx.example.com'}, ...]).
142
- * @example dns.resolveMx(hostname, callback)
143
- */
144
- def resolveMx (hostname : String , callback : DnsCallback1 [MX ]): Unit = js.native
145
-
146
- /**
147
- * Uses the DNS protocol to resolve regular expression based records (NAPTR records) for the hostname. The callback
148
- * function has arguments (err, addresses). The addresses argument passed to the callback function will contain an
149
- * array of objects with the following properties:
150
- * <ul>
151
- * <li>flags</li>
152
- * <li>service</li>
153
- * <li>regexp</li>
154
- * <li>replacement</li>
155
- * <li>order</li>
156
- * <li>preference</li>
157
- * </ul>
158
- * @example dns.resolveNaptr(hostname, callback)
159
- */
160
- def resolveNaptr (hostname : String , callback : DnsCallback1 [NAPTR ]): Unit = js.native
161
-
162
- /**
163
- * Uses the DNS protocol to resolve name server records (NS records) for the hostname. The addresses argument passed
164
- * to the callback function will contain an array of name server records available for hostname
165
- * (e.g., ['ns1.example.com', 'ns2.example.com']).
166
- * @example dns.resolveNs(hostname, callback)
167
- */
168
- def resolveNs (hostname : String , callback : DnsCallback1 [js.Array [String ]]): Unit = js.native
169
-
170
- /**
171
- * Uses the DNS protocol to resolve a start of authority record (SOA record) for the hostname. The addresses argument
172
- * passed to the callback function will be an object with the following properties:
173
- * <ul>
174
- * <li>nsname</li>
175
- * <li>hostmaster</li>
176
- * <li>serial</li>
177
- * <li>refresh</li>
178
- * <li>retry</li>
179
- * <li>expire</li>
180
- * <li>minttl</li>
181
- * </ul>
182
- * @example dns.resolveSoa(hostname, callback)
183
- */
184
- def resolveSoa (hostname : String , callback : DnsCallback1 [SOA ]): Unit = js.native
185
-
186
- /**
187
- * Uses the DNS protocol to resolve service records (SRV records) for the hostname. The addresses argument passed to
188
- * the callback function will be an array of objects with the following properties:
189
- * <ul>
190
- * <li>priority</li>
191
- * <li>weight</li>
192
- * <li>port</li>
193
- * <li>name</li>
194
- * </ul>
195
- * @example dns.resolveSrv(hostname, callback)
196
- */
197
- def resolveSrv (hostname : String , callback : DnsCallback1 [SRV ]): Unit = js.native
198
-
199
- /**
200
- * Uses the DNS protocol to resolve pointer records (PTR records) for the hostname. The addresses argument passed to
201
- * the callback function will be an array of strings containing the reply records.
202
- * @example dns.resolvePtr(hostname, callback)
203
- */
204
- def resolvePtr (hostname : String , callback : DnsCallback1 [js.Array [String ]]): Unit = js.native
205
-
206
- /**
207
- * Uses the DNS protocol to resolve text queries (TXT records) for the hostname. The addresses argument passed to the
208
- * callback function is is a two-dimentional array of the text records available for hostname
209
- * (e.g., [ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]). Each sub-array contains TXT chunks of one record. Depending on the
210
- * use case, these could be either joined together or treated separately.
211
- * @example dns.resolveTxt(hostname, callback)
212
- */
213
- def resolveTxt (hostname : String , callback : DnsCallback1 [js.Array [js.Array [String ]]]): Unit = js.native
214
-
215
- /**
216
- * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of hostnames.
217
- * The callback function has arguments (err, hostnames), where hostnames is an array of resolved hostnames for the given ip.
218
- * On error, err is an Error object, where err.code is one of the DNS error codes.
219
- * @example dns.reverse(ip, callback)
220
- */
221
- def reverse (ipAddress : String , callback : DnsCallback1 [js.Array [String ]]): Unit = js.native
222
-
223
- /**
224
- * Sets the IP addresses of the servers to be used when resolving. The servers argument is an array of IPv4 or IPv6 addresses.
225
- * If a port specified on the address it will be removed.
226
- * An error will be thrown if an invalid address is provided.
227
- * The dns.setServers() method must not be called while a DNS query is in progress.
228
- * @example dns.setServers(servers)
229
- */
230
- def setServers (servers : js.Array [String ]): Unit = js.native
231
-
232
73
}
233
74
234
75
/**
@@ -238,6 +79,11 @@ trait DNS extends js.Object {
238
79
@ JSImport (" dns" , JSImport .Namespace )
239
80
object DNS extends DNS {
240
81
82
+ @ js.native
83
+ object promises extends js.Object {
84
+ type Resolver = PromisesResolver
85
+ }
86
+
241
87
// ///////////////////////////////////////////////////////////////////////////////
242
88
// Error Codes
243
89
// ///////////////////////////////////////////////////////////////////////////////
0 commit comments