Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(228)

Delta Between Two Patch Sets: src/pkg/net/dnsclient.go

Issue 4244055: code review 4244055: net: drop laddr from Dial, cname from LookupHost; new f... (Closed)
Left Patch Set: diff -r 5ccb9b6f8cd1 https://go.googlecode.com/hg Created 13 years ago
Right Patch Set: diff -r 8b9c0b903333 https://go.googlecode.com/hg/ Created 13 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/net/dialgoogle_test.go ('k') | src/pkg/net/dnsmsg.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // DNS client: see RFC 1035. 5 // DNS client: see RFC 1035.
6 // Has to be linked into package net for Dial. 6 // Has to be linked into package net for Dial.
7 7
8 // TODO(rsc): 8 // TODO(rsc):
9 // Check periodically whether /etc/resolv.conf has changed. 9 // Check periodically whether /etc/resolv.conf has changed.
10 // Could potentially handle many outstanding lookups faster. 10 // Could potentially handle many outstanding lookups faster.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return "", nil, &DNSError{Error: "no DNS servers", Name: name} 152 return "", nil, &DNSError{Error: "no DNS servers", Name: name}
153 } 153 }
154 for i := 0; i < len(cfg.servers); i++ { 154 for i := 0; i < len(cfg.servers); i++ {
155 // Calling Dial here is scary -- we have to be sure 155 // Calling Dial here is scary -- we have to be sure
156 // not to dial a name that will require a DNS lookup, 156 // not to dial a name that will require a DNS lookup,
157 // or Dial will call back here to translate it. 157 // or Dial will call back here to translate it.
158 // The DNS config parser has already checked that 158 // The DNS config parser has already checked that
159 // all the cfg.servers[i] are IP addresses, which 159 // all the cfg.servers[i] are IP addresses, which
160 // Dial will use without a DNS lookup. 160 // Dial will use without a DNS lookup.
161 server := cfg.servers[i] + ":53" 161 server := cfg.servers[i] + ":53"
162 » » c, cerr := Dial("udp", "", server) 162 » » c, cerr := Dial("udp", server)
163 if cerr != nil { 163 if cerr != nil {
164 err = cerr 164 err = cerr
165 continue 165 continue
166 } 166 }
167 msg, merr := exchange(cfg, c, name, qtype) 167 msg, merr := exchange(cfg, c, name, qtype)
168 c.Close() 168 c.Close()
169 if merr != nil { 169 if merr != nil {
170 err = merr 170 err = merr
171 continue 171 continue
172 } 172 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // LookupCNAME returns the canonical DNS host for the given name. 360 // LookupCNAME returns the canonical DNS host for the given name.
361 // Callers that do not care about the canonical name can call 361 // Callers that do not care about the canonical name can call
362 // LookupHost or LookupIP directly; both take care of resolving 362 // LookupHost or LookupIP directly; both take care of resolving
363 // the canonical name as part of the lookup. 363 // the canonical name as part of the lookup.
364 func LookupCNAME(name string) (cname string, err os.Error) { 364 func LookupCNAME(name string) (cname string, err os.Error) {
365 onceLoadConfig.Do(loadConfig) 365 onceLoadConfig.Do(loadConfig)
366 if dnserr != nil || cfg == nil { 366 if dnserr != nil || cfg == nil {
367 err = dnserr 367 err = dnserr
368 return 368 return
369 } 369 }
370 » cname, _, err = lookup(name, dnsTypeCNAME) 370 » _, rr, err := lookup(name, dnsTypeCNAME)
371 » if err != nil {
372 » » return
373 » }
374 » if len(rr) >= 0 {
375 » » cname = rr[0].(*dnsRR_CNAME).Cname
376 » }
371 return 377 return
372 } 378 }
373 379
374 // An SRV represents a single DNS SRV record. 380 // An SRV represents a single DNS SRV record.
375 type SRV struct { 381 type SRV struct {
376 Target string 382 Target string
377 Port uint16 383 Port uint16
378 Priority uint16 384 Priority uint16
379 Weight uint16 385 Weight uint16
380 } 386 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 if err != nil { 467 if err != nil {
462 return 468 return
463 } 469 }
464 name = make([]string, len(records)) 470 name = make([]string, len(records))
465 for i := range records { 471 for i := range records {
466 r := records[i].(*dnsRR_PTR) 472 r := records[i].(*dnsRR_PTR)
467 name[i] = r.Ptr 473 name[i] = r.Ptr
468 } 474 }
469 return 475 return
470 } 476 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b