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

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

Issue 5320041: code review 5320041: net: Plan 9 fixes (Closed)
Left Patch Set: Created 13 years, 5 months ago
Right Patch Set: diff -r 60d08510dc91 https://go.googlecode.com/hg/ Created 13 years, 5 months 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:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/net/lookup_test.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
(no file at all)
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 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 package net 5 package net
6 6
7 import ( 7 import (
8 "os" 8 "os"
9 ) 9 )
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 net = "udp" 42 net = "udp"
43 } 43 }
44 if host == "" { 44 if host == "" {
45 host = "*" 45 host = "*"
46 } 46 }
47 return query("/net/cs", net+"!"+host+"!"+service, 128) 47 return query("/net/cs", net+"!"+host+"!"+service, 128)
48 } 48 }
49 49
50 func queryCS1(net string, ip IP, port int) (clone, dest string, err os.Error) { 50 func queryCS1(net string, ip IP, port int) (clone, dest string, err os.Error) {
51 ips := "*" 51 ips := "*"
52 » if !ip.IsUnspecified() { 52 » if len(ip) != 0 && !ip.IsUnspecified() {
53 ips = ip.String() 53 ips = ip.String()
54 } 54 }
55 lines, err := queryCS(net, ips, itoa(port)) 55 lines, err := queryCS(net, ips, itoa(port))
56 if err != nil { 56 if err != nil {
57 return 57 return
58 } 58 }
59 f := getFields(lines[0]) 59 f := getFields(lines[0])
60 if len(f) < 2 { 60 if len(f) < 2 {
61 return "", "", os.NewError("net: bad response from ndb/cs") 61 return "", "", os.NewError("net: bad response from ndb/cs")
62 } 62 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 if pref, _, ok := dtoi(f[2], 0); ok { 208 if pref, _, ok := dtoi(f[2], 0); ok {
209 mx = append(mx, &MX{f[3], uint16(pref)}) 209 mx = append(mx, &MX{f[3], uint16(pref)})
210 } 210 }
211 } 211 }
212 byPref(mx).sort() 212 byPref(mx).sort()
213 return 213 return
214 } 214 }
215 215
216 // LookupTXT returns the DNS TXT records for the given domain name. 216 // LookupTXT returns the DNS TXT records for the given domain name.
217 func LookupTXT(name string) (txt []string, err os.Error) { 217 func LookupTXT(name string) (txt []string, err os.Error) {
218 » return nil, os.NewError("net.LookupTXT is not implemented on Plan 9") 218 » lines, err := queryDNS(name, "txt")
219 » if err != nil {
220 » » return
221 » }
222 » for _, line := range lines {
223 » » if i := byteIndex(line, '\t'); i >= 0 {
224 » » » txt = append(txt, line[i+1:])
225 » » }
226 » }
227 » return
219 } 228 }
220 229
221 // LookupAddr performs a reverse lookup for the given address, returning a list 230 // LookupAddr performs a reverse lookup for the given address, returning a list
222 // of names mapping to that address. 231 // of names mapping to that address.
223 func LookupAddr(addr string) (name []string, err os.Error) { 232 func LookupAddr(addr string) (name []string, err os.Error) {
224 arpa, err := reverseaddr(addr) 233 arpa, err := reverseaddr(addr)
225 if err != nil { 234 if err != nil {
226 return 235 return
227 } 236 }
228 lines, err := queryDNS(arpa, "ptr") 237 lines, err := queryDNS(arpa, "ptr")
229 if err != nil { 238 if err != nil {
230 return 239 return
231 } 240 }
232 for _, line := range lines { 241 for _, line := range lines {
233 f := getFields(line) 242 f := getFields(line)
234 if len(f) < 3 { 243 if len(f) < 3 {
235 continue 244 continue
236 } 245 }
237 name = append(name, f[2]) 246 name = append(name, f[2])
238 } 247 }
239 return 248 return
240 } 249 }
LEFTRIGHT

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