LEFT | RIGHT |
(no file at all) | |
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 package net | 5 package net |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "fmt" | 9 "fmt" |
10 "math/rand" | 10 "math/rand" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 107 } |
108 if len(addrs) == 0 { | 108 if len(addrs) == 0 { |
109 return "", nil, &DNSError{Err: noSuchHost, Name: name, S
erver: server} | 109 return "", nil, &DNSError{Err: noSuchHost, Name: name, S
erver: server} |
110 } | 110 } |
111 return name, addrs, nil | 111 return name, addrs, nil |
112 } | 112 } |
113 | 113 |
114 return "", nil, &DNSError{Err: "too many redirects", Name: name, Server:
server} | 114 return "", nil, &DNSError{Err: "too many redirects", Name: name, Server:
server} |
115 } | 115 } |
116 | 116 |
117 func isDomainName(s string) bool { | 117 // Returns true if s is a domain name according to RFCs 1035 and 3696. |
118 » // See RFC 1035, RFC 3696. | 118 func IsDomainName(s string) bool { |
119 if len(s) == 0 { | 119 if len(s) == 0 { |
120 return false | 120 return false |
121 } | 121 } |
122 if len(s) > 255 { | 122 if len(s) > 255 { |
123 return false | 123 return false |
124 } | 124 } |
125 if s[len(s)-1] != '.' { // simplify checking loop: make name end in dot | 125 if s[len(s)-1] != '.' { // simplify checking loop: make name end in dot |
126 s += "." | 126 s += "." |
127 } | 127 } |
128 | 128 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 func (s byPref) Swap(i, j int) { s[i], s[j] = s[j], s[i] } | 237 func (s byPref) Swap(i, j int) { s[i], s[j] = s[j], s[i] } |
238 | 238 |
239 // sort reorders MX records as specified in RFC 5321. | 239 // sort reorders MX records as specified in RFC 5321. |
240 func (s byPref) sort() { | 240 func (s byPref) sort() { |
241 for i := range s { | 241 for i := range s { |
242 j := rand.Intn(i + 1) | 242 j := rand.Intn(i + 1) |
243 s[i], s[j] = s[j], s[i] | 243 s[i], s[j] = s[j], s[i] |
244 } | 244 } |
245 sort.Sort(s) | 245 sort.Sort(s) |
246 } | 246 } |
LEFT | RIGHT |