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

Side by Side Diff: src/pkg/net/dnsconfig_unix.go

Issue 132560043: code review 132560043: net: fix parsing literal IPv6 address with zone identif... (Closed)
Patch Set: diff -r 23e48d4f30661630cff46dd356ca9ea3916365c5 https://code.google.com/p/go Created 9 years, 6 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:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/net/dnsconfig_unix_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris 5 // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
6 6
7 // Read system DNS config from /etc/resolv.conf 7 // Read system DNS config from /etc/resolv.conf
8 8
9 package net 9 package net
10 10
(...skipping 24 matching lines...) Expand all
35 f := getFields(line) 35 f := getFields(line)
36 if len(f) < 1 { 36 if len(f) < 1 {
37 continue 37 continue
38 } 38 }
39 switch f[0] { 39 switch f[0] {
40 case "nameserver": // add one name server 40 case "nameserver": // add one name server
41 if len(f) > 1 && len(conf.servers) < 3 { // small, but t he standard limit 41 if len(f) > 1 && len(conf.servers) < 3 { // small, but t he standard limit
42 // One more check: make sure server name is 42 // One more check: make sure server name is
43 // just an IP address. Otherwise we need DNS 43 // just an IP address. Otherwise we need DNS
44 // to look it up. 44 // to look it up.
45 » » » » if ParseIP(f[1]) != nil { 45 » » » » if parseIPv4(f[1]) != nil {
46 » » » » » conf.servers = append(conf.servers, f[1] )
47 » » » » } else if ip, _ := parseIPv6(f[1], true); ip != nil {
46 conf.servers = append(conf.servers, f[1] ) 48 conf.servers = append(conf.servers, f[1] )
47 } 49 }
48 } 50 }
49 51
50 case "domain": // set search path to just this domain 52 case "domain": // set search path to just this domain
51 if len(f) > 1 { 53 if len(f) > 1 {
52 conf.search = []string{f[1]} 54 conf.search = []string{f[1]}
53 } 55 }
54 56
55 case "search": // set search path to given servers 57 case "search": // set search path to given servers
(...skipping 29 matching lines...) Expand all
85 } 87 }
86 } 88 }
87 } 89 }
88 } 90 }
89 return conf, nil 91 return conf, nil
90 } 92 }
91 93
92 func hasPrefix(s, prefix string) bool { 94 func hasPrefix(s, prefix string) bool {
93 return len(s) >= len(prefix) && s[:len(prefix)] == prefix 95 return len(s) >= len(prefix) && s[:len(prefix)] == prefix
94 } 96 }
OLDNEW
« no previous file with comments | « no previous file | src/pkg/net/dnsconfig_unix_test.go » ('j') | no next file with comments »

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