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

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

Issue 5631048: net: Export isDomainName. (Closed)
Left Patch Set: Created 12 years, 1 month ago
Right Patch Set: diff -r 756477d03441 https://go.googlecode.com/hg/ Created 12 years, 1 month 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/dnsclient_unix.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 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
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
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 }
LEFTRIGHT

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