Skip to content

Commit ceb8740

Browse files
committed
dns: rename domain to hostname
A follow-up commit will save the domain name on the request object but we can't call that property 'domain' because that gets intercepted by src/node.cc and lib/domain.js to implement the node.js feature of the same name. To avoid confusion, rename all variables called 'domain' to 'hostname'.
1 parent 4234bcc commit ceb8740

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

doc/api/dns.markdown

+21-22
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ resolves the IP addresses which are returned.
2121
console.log('addresses: ' + JSON.stringify(addresses));
2222

2323
addresses.forEach(function (a) {
24-
dns.reverse(a, function (err, domains) {
24+
dns.reverse(a, function (err, hostnames) {
2525
if (err) {
2626
throw err;
2727
}
2828

29-
console.log('reverse for ' + a + ': ' + JSON.stringify(domains));
29+
console.log('reverse for ' + a + ': ' + JSON.stringify(hostnames));
3030
});
3131
});
3232
});
3333

34-
## dns.lookup(domain, [family], callback)
34+
## dns.lookup(hostname, [family], callback)
3535

36-
Resolves a domain (e.g. `'google.com'`) into the first found A (IPv4) or
36+
Resolves a hostname (e.g. `'google.com'`) into the first found A (IPv4) or
3737
AAAA (IPv6) record.
3838
The `family` can be the integer `4` or `6`. Defaults to `null` that indicates
3939
both Ip v4 and v6 address family.
@@ -45,13 +45,13 @@ necessarily the value initially passed to `lookup`).
4545

4646
On error, `err` is an `Error` object, where `err.code` is the error code.
4747
Keep in mind that `err.code` will be set to `'ENOENT'` not only when
48-
the domain does not exist but also when the lookup fails in other ways
48+
the hostname does not exist but also when the lookup fails in other ways
4949
such as no available file descriptors.
5050

5151

52-
## dns.resolve(domain, [rrtype], callback)
52+
## dns.resolve(hostname, [rrtype], callback)
5353

54-
Resolves a domain (e.g. `'google.com'`) into an array of the record types
54+
Resolves a hostname (e.g. `'google.com'`) into an array of the record types
5555
specified by rrtype. Valid rrtypes are `'A'` (IPV4 addresses, default),
5656
`'AAAA'` (IPV6 addresses), `'MX'` (mail exchange records), `'TXT'` (text
5757
records), `'SRV'` (SRV records), `'PTR'` (used for reverse IP lookups),
@@ -65,54 +65,54 @@ On error, `err` is an `Error` object, where `err.code` is
6565
one of the error codes listed below.
6666

6767

68-
## dns.resolve4(domain, callback)
68+
## dns.resolve4(hostname, callback)
6969

7070
The same as `dns.resolve()`, but only for IPv4 queries (`A` records).
7171
`addresses` is an array of IPv4 addresses (e.g.
7272
`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
7373

74-
## dns.resolve6(domain, callback)
74+
## dns.resolve6(hostname, callback)
7575

7676
The same as `dns.resolve4()` except for IPv6 queries (an `AAAA` query).
7777

7878

79-
## dns.resolveMx(domain, callback)
79+
## dns.resolveMx(hostname, callback)
8080

8181
The same as `dns.resolve()`, but only for mail exchange queries (`MX` records).
8282

8383
`addresses` is an array of MX records, each with a priority and an exchange
8484
attribute (e.g. `[{'priority': 10, 'exchange': 'mx.example.com'},...]`).
8585

86-
## dns.resolveTxt(domain, callback)
86+
## dns.resolveTxt(hostname, callback)
8787

8888
The same as `dns.resolve()`, but only for text queries (`TXT` records).
89-
`addresses` is an array of the text records available for `domain` (e.g.,
89+
`addresses` is an array of the text records available for `hostname` (e.g.,
9090
`['v=spf1 ip4:0.0.0.0 ~all']`).
9191

92-
## dns.resolveSrv(domain, callback)
92+
## dns.resolveSrv(hostname, callback)
9393

9494
The same as `dns.resolve()`, but only for service records (`SRV` records).
95-
`addresses` is an array of the SRV records available for `domain`. Properties
95+
`addresses` is an array of the SRV records available for `hostname`. Properties
9696
of SRV records are priority, weight, port, and name (e.g.,
9797
`[{'priority': 10, {'weight': 5, 'port': 21223, 'name': 'service.example.com'}, ...]`).
9898

99-
## dns.resolveNs(domain, callback)
99+
## dns.resolveNs(hostname, callback)
100100

101101
The same as `dns.resolve()`, but only for name server records (`NS` records).
102-
`addresses` is an array of the name server records available for `domain`
102+
`addresses` is an array of the name server records available for `hostname`
103103
(e.g., `['ns1.example.com', 'ns2.example.com']`).
104104

105-
## dns.resolveCname(domain, callback)
105+
## dns.resolveCname(hostname, callback)
106106

107107
The same as `dns.resolve()`, but only for canonical name records (`CNAME`
108108
records). `addresses` is an array of the canonical name records available for
109-
`domain` (e.g., `['bar.example.com']`).
109+
`hostname` (e.g., `['bar.example.com']`).
110110

111111
## dns.reverse(ip, callback)
112112

113-
Reverse resolves an ip address to an array of domain names.
113+
Reverse resolves an ip address to an array of hostnames.
114114

115-
The callback has arguments `(err, domains)`.
115+
The callback has arguments `(err, hostnames)`.
116116

117117
On error, `err` is an `Error` object, where `err.code` is
118118
one of the error codes listed below.
@@ -143,7 +143,7 @@ Each DNS query can return one of the following error codes:
143143
- `dns.NOTIMP`: DNS server does not implement requested operation.
144144
- `dns.REFUSED`: DNS server refused query.
145145
- `dns.BADQUERY`: Misformatted DNS query.
146-
- `dns.BADNAME`: Misformatted domain name.
146+
- `dns.BADNAME`: Misformatted hostname.
147147
- `dns.BADFAMILY`: Unsupported address family.
148148
- `dns.BADRESP`: Misformatted DNS reply.
149149
- `dns.CONNREFUSED`: Could not contact DNS servers.
@@ -160,4 +160,3 @@ Each DNS query can return one of the following error codes:
160160
- `dns.LOADIPHLPAPI`: Error loading iphlpapi.dll.
161161
- `dns.ADDRGETNETWORKPARAMS`: Could not find GetNetworkParams function.
162162
- `dns.CANCELLED`: DNS query cancelled.
163-

lib/dns.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ function onlookup(err, addresses) {
9494

9595

9696
// Easy DNS A/AAAA look up
97-
// lookup(domain, [family,] callback)
98-
exports.lookup = function(domain, family, callback) {
97+
// lookup(hostname, [family,] callback)
98+
exports.lookup = function(hostname, family, callback) {
9999
// parse arguments
100100
if (arguments.length === 2) {
101101
callback = family;
@@ -110,7 +110,7 @@ exports.lookup = function(domain, family, callback) {
110110
}
111111
callback = makeAsync(callback);
112112

113-
if (!domain) {
113+
if (!hostname) {
114114
callback(null, null, family === 6 ? 6 : 4);
115115
return {};
116116
}
@@ -119,14 +119,14 @@ exports.lookup = function(domain, family, callback) {
119119
// localhost entry from c:\WINDOWS\system32\drivers\etc\hosts
120120
// See http://daniel.haxx.se/blog/2011/02/21/localhost-hack-on-windows/
121121
// TODO Remove this once c-ares handles this problem.
122-
if (process.platform == 'win32' && domain == 'localhost') {
122+
if (process.platform == 'win32' && hostname == 'localhost') {
123123
callback(null, '127.0.0.1', 4);
124124
return {};
125125
}
126126

127-
var matchedFamily = net.isIP(domain);
127+
var matchedFamily = net.isIP(hostname);
128128
if (matchedFamily) {
129-
callback(null, domain, matchedFamily);
129+
callback(null, hostname, matchedFamily);
130130
return {};
131131
}
132132

@@ -135,7 +135,7 @@ exports.lookup = function(domain, family, callback) {
135135
family: family,
136136
oncomplete: onlookup
137137
};
138-
var err = cares.getaddrinfo(req, domain, family);
138+
var err = cares.getaddrinfo(req, hostname, family);
139139
if (err) throw errnoException(err, 'getaddrinfo');
140140

141141
callback.immediately = true;
@@ -181,7 +181,7 @@ exports.resolveNaptr = resolveMap.NAPTR = resolver('queryNaptr');
181181
exports.reverse = resolveMap.PTR = resolver('getHostByAddr');
182182

183183

184-
exports.resolve = function(domain, type_, callback_) {
184+
exports.resolve = function(hostname, type_, callback_) {
185185
var resolver, callback;
186186
if (util.isString(type_)) {
187187
resolver = resolveMap[type_];
@@ -192,7 +192,7 @@ exports.resolve = function(domain, type_, callback_) {
192192
}
193193

194194
if (util.isFunction(resolver)) {
195-
return resolver(domain, callback);
195+
return resolver(hostname, callback);
196196
} else {
197197
throw new Error('Unknown type "' + type_ + '"');
198198
}

0 commit comments

Comments
 (0)