@@ -101,13 +101,6 @@ type Resolver struct {
101
101
// TODO(bradfitz): Timeout time.Duration?
102
102
}
103
103
104
- func (r * Resolver ) lookupIPFunc () func (context.Context , string ) ([]IPAddr , error ) {
105
- if r != nil && r .PreferGo {
106
- return goLookupIP
107
- }
108
- return lookupIP
109
- }
110
-
111
104
// LookupHost looks up the given host using the local resolver.
112
105
// It returns a slice of that host's addresses.
113
106
func LookupHost (host string ) (addrs []string , err error ) {
@@ -125,7 +118,7 @@ func (r *Resolver) LookupHost(ctx context.Context, host string) (addrs []string,
125
118
if ip := ParseIP (host ); ip != nil {
126
119
return []string {host }, nil
127
120
}
128
- return lookupHost (ctx , host )
121
+ return r . lookupHost (ctx , host )
129
122
}
130
123
131
124
// LookupIP looks up host using the local resolver.
@@ -160,7 +153,7 @@ func (r *Resolver) LookupIPAddr(ctx context.Context, host string) ([]IPAddr, err
160
153
// The underlying resolver func is lookupIP by default but it
161
154
// can be overridden by tests. This is needed by net/http, so it
162
155
// uses a context key instead of unexported variables.
163
- resolverFunc := r .lookupIPFunc ()
156
+ resolverFunc := r .lookupIP
164
157
if alt , _ := ctx .Value (nettrace.LookupIPAltResolverKey {}).(func (context.Context , string ) ([]IPAddr , error )); alt != nil {
165
158
resolverFunc = alt
166
159
}
@@ -229,7 +222,7 @@ func LookupPort(network, service string) (port int, err error) {
229
222
func (r * Resolver ) LookupPort (ctx context.Context , network , service string ) (port int , err error ) {
230
223
port , needsLookup := parsePort (service )
231
224
if needsLookup {
232
- port , err = lookupPort (ctx , network , service )
225
+ port , err = r . lookupPort (ctx , network , service )
233
226
if err != nil {
234
227
return 0 , err
235
228
}
@@ -245,15 +238,15 @@ func (r *Resolver) LookupPort(ctx context.Context, network, service string) (por
245
238
// LookupHost or LookupIP directly; both take care of resolving
246
239
// the canonical name as part of the lookup.
247
240
func LookupCNAME (name string ) (cname string , err error ) {
248
- return lookupCNAME (context .Background (), name )
241
+ return DefaultResolver . lookupCNAME (context .Background (), name )
249
242
}
250
243
251
244
// LookupCNAME returns the canonical DNS host for the given name.
252
245
// Callers that do not care about the canonical name can call
253
246
// LookupHost or LookupIP directly; both take care of resolving
254
247
// the canonical name as part of the lookup.
255
248
func (r * Resolver ) LookupCNAME (ctx context.Context , name string ) (cname string , err error ) {
256
- return lookupCNAME (ctx , name )
249
+ return r . lookupCNAME (ctx , name )
257
250
}
258
251
259
252
// LookupSRV tries to resolve an SRV query of the given service,
@@ -266,7 +259,7 @@ func (r *Resolver) LookupCNAME(ctx context.Context, name string) (cname string,
266
259
// publishing SRV records under non-standard names, if both service
267
260
// and proto are empty strings, LookupSRV looks up name directly.
268
261
func LookupSRV (service , proto , name string ) (cname string , addrs []* SRV , err error ) {
269
- return lookupSRV (context .Background (), service , proto , name )
262
+ return DefaultResolver . lookupSRV (context .Background (), service , proto , name )
270
263
}
271
264
272
265
// LookupSRV tries to resolve an SRV query of the given service,
@@ -279,47 +272,47 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
279
272
// publishing SRV records under non-standard names, if both service
280
273
// and proto are empty strings, LookupSRV looks up name directly.
281
274
func (r * Resolver ) LookupSRV (ctx context.Context , service , proto , name string ) (cname string , addrs []* SRV , err error ) {
282
- return lookupSRV (ctx , service , proto , name )
275
+ return r . lookupSRV (ctx , service , proto , name )
283
276
}
284
277
285
278
// LookupMX returns the DNS MX records for the given domain name sorted by preference.
286
279
func LookupMX (name string ) ([]* MX , error ) {
287
- return lookupMX (context .Background (), name )
280
+ return DefaultResolver . lookupMX (context .Background (), name )
288
281
}
289
282
290
283
// LookupMX returns the DNS MX records for the given domain name sorted by preference.
291
284
func (r * Resolver ) LookupMX (ctx context.Context , name string ) ([]* MX , error ) {
292
- return lookupMX (ctx , name )
285
+ return r . lookupMX (ctx , name )
293
286
}
294
287
295
288
// LookupNS returns the DNS NS records for the given domain name.
296
289
func LookupNS (name string ) ([]* NS , error ) {
297
- return lookupNS (context .Background (), name )
290
+ return DefaultResolver . lookupNS (context .Background (), name )
298
291
}
299
292
300
293
// LookupNS returns the DNS NS records for the given domain name.
301
294
func (r * Resolver ) LookupNS (ctx context.Context , name string ) ([]* NS , error ) {
302
- return lookupNS (ctx , name )
295
+ return r . lookupNS (ctx , name )
303
296
}
304
297
305
298
// LookupTXT returns the DNS TXT records for the given domain name.
306
299
func LookupTXT (name string ) ([]string , error ) {
307
- return lookupTXT (context .Background (), name )
300
+ return DefaultResolver . lookupTXT (context .Background (), name )
308
301
}
309
302
310
303
// LookupTXT returns the DNS TXT records for the given domain name.
311
304
func (r * Resolver ) LookupTXT (ctx context.Context , name string ) ([]string , error ) {
312
- return lookupTXT (ctx , name )
305
+ return r . lookupTXT (ctx , name )
313
306
}
314
307
315
308
// LookupAddr performs a reverse lookup for the given address, returning a list
316
309
// of names mapping to that address.
317
310
func LookupAddr (addr string ) (names []string , err error ) {
318
- return lookupAddr (context .Background (), addr )
311
+ return DefaultResolver . lookupAddr (context .Background (), addr )
319
312
}
320
313
321
314
// LookupAddr performs a reverse lookup for the given address, returning a list
322
315
// of names mapping to that address.
323
316
func (r * Resolver ) LookupAddr (ctx context.Context , addr string ) (names []string , err error ) {
324
- return lookupAddr (ctx , addr )
317
+ return r . lookupAddr (ctx , addr )
325
318
}
0 commit comments