Cleanup: gofmt -w -s *.go (#548)
Some renames of internal names to make go lint happier.
This commit is contained in:
parent
348c84f37e
commit
b38dc3dcb7
|
@ -78,6 +78,7 @@ func (c *Client) writeTimeout() time.Duration {
|
||||||
return dnsTimeout
|
return dnsTimeout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dial connects to the address on the named network.
|
||||||
func (c *Client) Dial(address string) (conn *Conn, err error) {
|
func (c *Client) Dial(address string) (conn *Conn, err error) {
|
||||||
// create a new dialer with the appropriate timeout
|
// create a new dialer with the appropriate timeout
|
||||||
var d net.Dialer
|
var d net.Dialer
|
||||||
|
|
9
dns.go
9
dns.go
|
@ -6,9 +6,12 @@ const (
|
||||||
year68 = 1 << 31 // For RFC1982 (Serial Arithmetic) calculations in 32 bits.
|
year68 = 1 << 31 // For RFC1982 (Serial Arithmetic) calculations in 32 bits.
|
||||||
defaultTtl = 3600 // Default internal TTL.
|
defaultTtl = 3600 // Default internal TTL.
|
||||||
|
|
||||||
DefaultMsgSize = 4096 // DefaultMsgSize is the standard default for messages larger than 512 bytes.
|
// DefaultMsgSize is the standard default for messages larger than 512 bytes.
|
||||||
MinMsgSize = 512 // MinMsgSize is the minimal size of a DNS packet.
|
DefaultMsgSize = 4096
|
||||||
MaxMsgSize = 65535 // MaxMsgSize is the largest possible DNS packet.
|
// MinMsgSize is the minimal size of a DNS packet.
|
||||||
|
MinMsgSize = 512
|
||||||
|
// MaxMsgSize is the largest possible DNS packet.
|
||||||
|
MaxMsgSize = 65535
|
||||||
)
|
)
|
||||||
|
|
||||||
// Error represents a DNS error.
|
// Error represents a DNS error.
|
||||||
|
|
|
@ -85,19 +85,19 @@ func TestPrevLabel(t *testing.T) {
|
||||||
int
|
int
|
||||||
}
|
}
|
||||||
prever := map[prev]int{
|
prever := map[prev]int{
|
||||||
prev{"www.miek.nl.", 0}: 12,
|
{"www.miek.nl.", 0}: 12,
|
||||||
prev{"www.miek.nl.", 1}: 9,
|
{"www.miek.nl.", 1}: 9,
|
||||||
prev{"www.miek.nl.", 2}: 4,
|
{"www.miek.nl.", 2}: 4,
|
||||||
|
|
||||||
prev{"www.miek.nl", 0}: 11,
|
{"www.miek.nl", 0}: 11,
|
||||||
prev{"www.miek.nl", 1}: 9,
|
{"www.miek.nl", 1}: 9,
|
||||||
prev{"www.miek.nl", 2}: 4,
|
{"www.miek.nl", 2}: 4,
|
||||||
|
|
||||||
prev{"www.miek.nl.", 5}: 0,
|
{"www.miek.nl.", 5}: 0,
|
||||||
prev{"www.miek.nl", 5}: 0,
|
{"www.miek.nl", 5}: 0,
|
||||||
|
|
||||||
prev{"www.miek.nl.", 3}: 0,
|
{"www.miek.nl.", 3}: 0,
|
||||||
prev{"www.miek.nl", 3}: 0,
|
{"www.miek.nl", 3}: 0,
|
||||||
}
|
}
|
||||||
for s, i := range prever {
|
for s, i := range prever {
|
||||||
x, ok := PrevLabel(s.string, s.int)
|
x, ok := PrevLabel(s.string, s.int)
|
||||||
|
|
5
msg.go
5
msg.go
|
@ -26,6 +26,7 @@ const (
|
||||||
maxDomainNameWireOctets = 255 // See RFC 1035 section 2.3.4
|
maxDomainNameWireOctets = 255 // See RFC 1035 section 2.3.4
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Errors defined in this package.
|
||||||
var (
|
var (
|
||||||
ErrAlg error = &Error{err: "bad algorithm"} // ErrAlg indicates an error with the (DNSSEC) algorithm.
|
ErrAlg error = &Error{err: "bad algorithm"} // ErrAlg indicates an error with the (DNSSEC) algorithm.
|
||||||
ErrAuth error = &Error{err: "bad authentication"} // ErrAuth indicates an error in the TSIG authentication.
|
ErrAuth error = &Error{err: "bad authentication"} // ErrAuth indicates an error in the TSIG authentication.
|
||||||
|
@ -57,7 +58,7 @@ var (
|
||||||
// For instance, to make it return a static value:
|
// For instance, to make it return a static value:
|
||||||
//
|
//
|
||||||
// dns.Id = func() uint16 { return 3 }
|
// dns.Id = func() uint16 { return 3 }
|
||||||
var Id func() uint16 = id
|
var Id = id
|
||||||
|
|
||||||
var (
|
var (
|
||||||
idLock sync.Mutex
|
idLock sync.Mutex
|
||||||
|
@ -360,7 +361,7 @@ Loop:
|
||||||
case '"', '\\':
|
case '"', '\\':
|
||||||
s = append(s, '\\', b)
|
s = append(s, '\\', b)
|
||||||
// presentation-format \X escapes add an extra byte
|
// presentation-format \X escapes add an extra byte
|
||||||
maxLen += 1
|
maxLen++
|
||||||
default:
|
default:
|
||||||
if b < 32 || b >= 127 { // unprintable, use \DDD
|
if b < 32 || b >= 127 { // unprintable, use \DDD
|
||||||
var buf [3]byte
|
var buf [3]byte
|
||||||
|
|
44
scan.go
44
scan.go
|
@ -38,7 +38,7 @@ const (
|
||||||
zOwner
|
zOwner
|
||||||
zClass
|
zClass
|
||||||
zDirOrigin // $ORIGIN
|
zDirOrigin // $ORIGIN
|
||||||
zDirTtl // $TTL
|
zDirTTL // $TTL
|
||||||
zDirInclude // $INCLUDE
|
zDirInclude // $INCLUDE
|
||||||
zDirGenerate // $GENERATE
|
zDirGenerate // $GENERATE
|
||||||
|
|
||||||
|
@ -51,13 +51,13 @@ const (
|
||||||
zExpectAny // Expect rrtype, ttl or class
|
zExpectAny // Expect rrtype, ttl or class
|
||||||
zExpectAnyNoClass // Expect rrtype or ttl
|
zExpectAnyNoClass // Expect rrtype or ttl
|
||||||
zExpectAnyNoClassBl // The whitespace after _EXPECT_ANY_NOCLASS
|
zExpectAnyNoClassBl // The whitespace after _EXPECT_ANY_NOCLASS
|
||||||
zExpectAnyNoTtl // Expect rrtype or class
|
zExpectAnyNoTTL // Expect rrtype or class
|
||||||
zExpectAnyNoTtlBl // Whitespace after _EXPECT_ANY_NOTTL
|
zExpectAnyNoTTLBl // Whitespace after _EXPECT_ANY_NOTTL
|
||||||
zExpectRrtype // Expect rrtype
|
zExpectRrtype // Expect rrtype
|
||||||
zExpectRrtypeBl // Whitespace BEFORE rrtype
|
zExpectRrtypeBl // Whitespace BEFORE rrtype
|
||||||
zExpectRdata // The first element of the rdata
|
zExpectRdata // The first element of the rdata
|
||||||
zExpectDirTtlBl // Space after directive $TTL
|
zExpectDirTTLBl // Space after directive $TTL
|
||||||
zExpectDirTtl // Directive $TTL
|
zExpectDirTTL // Directive $TTL
|
||||||
zExpectDirOriginBl // Space after directive $ORIGIN
|
zExpectDirOriginBl // Space after directive $ORIGIN
|
||||||
zExpectDirOrigin // Directive $ORIGIN
|
zExpectDirOrigin // Directive $ORIGIN
|
||||||
zExpectDirIncludeBl // Space after directive $INCLUDE
|
zExpectDirIncludeBl // Space after directive $INCLUDE
|
||||||
|
@ -231,8 +231,8 @@ func parseZone(r io.Reader, origin string, defttl *ttlState, f string, t chan *T
|
||||||
h.Name = name
|
h.Name = name
|
||||||
prevName = h.Name
|
prevName = h.Name
|
||||||
st = zExpectOwnerBl
|
st = zExpectOwnerBl
|
||||||
case zDirTtl:
|
case zDirTTL:
|
||||||
st = zExpectDirTtlBl
|
st = zExpectDirTTLBl
|
||||||
case zDirOrigin:
|
case zDirOrigin:
|
||||||
st = zExpectDirOriginBl
|
st = zExpectDirOriginBl
|
||||||
case zDirInclude:
|
case zDirInclude:
|
||||||
|
@ -251,7 +251,7 @@ func parseZone(r io.Reader, origin string, defttl *ttlState, f string, t chan *T
|
||||||
// Discard, can happen when there is nothing on the
|
// Discard, can happen when there is nothing on the
|
||||||
// line except the RR type
|
// line except the RR type
|
||||||
case zString:
|
case zString:
|
||||||
ttl, ok := stringToTtl(l.token)
|
ttl, ok := stringToTTL(l.token)
|
||||||
if !ok {
|
if !ok {
|
||||||
t <- &Token{Error: &ParseError{f, "not a TTL", l}}
|
t <- &Token{Error: &ParseError{f, "not a TTL", l}}
|
||||||
return
|
return
|
||||||
|
@ -260,7 +260,7 @@ func parseZone(r io.Reader, origin string, defttl *ttlState, f string, t chan *T
|
||||||
if defttl == nil || !defttl.isByDirective {
|
if defttl == nil || !defttl.isByDirective {
|
||||||
defttl = &ttlState{ttl, false}
|
defttl = &ttlState{ttl, false}
|
||||||
}
|
}
|
||||||
st = zExpectAnyNoTtlBl
|
st = zExpectAnyNoTTLBl
|
||||||
|
|
||||||
default:
|
default:
|
||||||
t <- &Token{Error: &ParseError{f, "syntax error at beginning", l}}
|
t <- &Token{Error: &ParseError{f, "syntax error at beginning", l}}
|
||||||
|
@ -307,13 +307,13 @@ func parseZone(r io.Reader, origin string, defttl *ttlState, f string, t chan *T
|
||||||
}
|
}
|
||||||
parseZone(r1, neworigin, defttl, l.token, t, include+1)
|
parseZone(r1, neworigin, defttl, l.token, t, include+1)
|
||||||
st = zExpectOwnerDir
|
st = zExpectOwnerDir
|
||||||
case zExpectDirTtlBl:
|
case zExpectDirTTLBl:
|
||||||
if l.value != zBlank {
|
if l.value != zBlank {
|
||||||
t <- &Token{Error: &ParseError{f, "no blank after $TTL-directive", l}}
|
t <- &Token{Error: &ParseError{f, "no blank after $TTL-directive", l}}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
st = zExpectDirTtl
|
st = zExpectDirTTL
|
||||||
case zExpectDirTtl:
|
case zExpectDirTTL:
|
||||||
if l.value != zString {
|
if l.value != zString {
|
||||||
t <- &Token{Error: &ParseError{f, "expecting $TTL value, not this...", l}}
|
t <- &Token{Error: &ParseError{f, "expecting $TTL value, not this...", l}}
|
||||||
return
|
return
|
||||||
|
@ -322,7 +322,7 @@ func parseZone(r io.Reader, origin string, defttl *ttlState, f string, t chan *T
|
||||||
t <- &Token{Error: e}
|
t <- &Token{Error: e}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ttl, ok := stringToTtl(l.token)
|
ttl, ok := stringToTTL(l.token)
|
||||||
if !ok {
|
if !ok {
|
||||||
t <- &Token{Error: &ParseError{f, "expecting $TTL value, not this...", l}}
|
t <- &Token{Error: &ParseError{f, "expecting $TTL value, not this...", l}}
|
||||||
return
|
return
|
||||||
|
@ -385,7 +385,7 @@ func parseZone(r io.Reader, origin string, defttl *ttlState, f string, t chan *T
|
||||||
h.Class = l.torc
|
h.Class = l.torc
|
||||||
st = zExpectAnyNoClassBl
|
st = zExpectAnyNoClassBl
|
||||||
case zString:
|
case zString:
|
||||||
ttl, ok := stringToTtl(l.token)
|
ttl, ok := stringToTTL(l.token)
|
||||||
if !ok {
|
if !ok {
|
||||||
t <- &Token{Error: &ParseError{f, "not a TTL", l}}
|
t <- &Token{Error: &ParseError{f, "not a TTL", l}}
|
||||||
return
|
return
|
||||||
|
@ -394,7 +394,7 @@ func parseZone(r io.Reader, origin string, defttl *ttlState, f string, t chan *T
|
||||||
if defttl == nil || !defttl.isByDirective {
|
if defttl == nil || !defttl.isByDirective {
|
||||||
defttl = &ttlState{ttl, false}
|
defttl = &ttlState{ttl, false}
|
||||||
}
|
}
|
||||||
st = zExpectAnyNoTtlBl
|
st = zExpectAnyNoTTLBl
|
||||||
default:
|
default:
|
||||||
t <- &Token{Error: &ParseError{f, "expecting RR type, TTL or class, not this...", l}}
|
t <- &Token{Error: &ParseError{f, "expecting RR type, TTL or class, not this...", l}}
|
||||||
return
|
return
|
||||||
|
@ -405,13 +405,13 @@ func parseZone(r io.Reader, origin string, defttl *ttlState, f string, t chan *T
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
st = zExpectAnyNoClass
|
st = zExpectAnyNoClass
|
||||||
case zExpectAnyNoTtlBl:
|
case zExpectAnyNoTTLBl:
|
||||||
if l.value != zBlank {
|
if l.value != zBlank {
|
||||||
t <- &Token{Error: &ParseError{f, "no blank before TTL", l}}
|
t <- &Token{Error: &ParseError{f, "no blank before TTL", l}}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
st = zExpectAnyNoTtl
|
st = zExpectAnyNoTTL
|
||||||
case zExpectAnyNoTtl:
|
case zExpectAnyNoTTL:
|
||||||
switch l.value {
|
switch l.value {
|
||||||
case zClass:
|
case zClass:
|
||||||
h.Class = l.torc
|
h.Class = l.torc
|
||||||
|
@ -426,7 +426,7 @@ func parseZone(r io.Reader, origin string, defttl *ttlState, f string, t chan *T
|
||||||
case zExpectAnyNoClass:
|
case zExpectAnyNoClass:
|
||||||
switch l.value {
|
switch l.value {
|
||||||
case zString:
|
case zString:
|
||||||
ttl, ok := stringToTtl(l.token)
|
ttl, ok := stringToTTL(l.token)
|
||||||
if !ok {
|
if !ok {
|
||||||
t <- &Token{Error: &ParseError{f, "not a TTL", l}}
|
t <- &Token{Error: &ParseError{f, "not a TTL", l}}
|
||||||
return
|
return
|
||||||
|
@ -539,7 +539,7 @@ func zlexer(s *scan, c chan lex) {
|
||||||
// escape $... start with a \ not a $, so this will work
|
// escape $... start with a \ not a $, so this will work
|
||||||
switch l.tokenUpper {
|
switch l.tokenUpper {
|
||||||
case "$TTL":
|
case "$TTL":
|
||||||
l.value = zDirTtl
|
l.value = zDirTTL
|
||||||
case "$ORIGIN":
|
case "$ORIGIN":
|
||||||
l.value = zDirOrigin
|
l.value = zDirOrigin
|
||||||
case "$INCLUDE":
|
case "$INCLUDE":
|
||||||
|
@ -837,8 +837,8 @@ func typeToInt(token string) (uint16, bool) {
|
||||||
return uint16(typ), true
|
return uint16(typ), true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse things like 2w, 2m, etc, Return the time in seconds.
|
// stringToTTL parses things like 2w, 2m, etc, and returns the time in seconds.
|
||||||
func stringToTtl(token string) (uint32, bool) {
|
func stringToTTL(token string) (uint32, bool) {
|
||||||
s := uint32(0)
|
s := uint32(0)
|
||||||
i := uint32(0)
|
i := uint32(0)
|
||||||
for _, c := range token {
|
for _, c := range token {
|
||||||
|
|
|
@ -590,7 +590,7 @@ func setSOA(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
||||||
return nil, &ParseError{f, "bad SOA zone parameter", l}, ""
|
return nil, &ParseError{f, "bad SOA zone parameter", l}, ""
|
||||||
}
|
}
|
||||||
// We allow other fields to be unitful duration strings
|
// We allow other fields to be unitful duration strings
|
||||||
if v, ok = stringToTtl(l.token); !ok {
|
if v, ok = stringToTTL(l.token); !ok {
|
||||||
return nil, &ParseError{f, "bad SOA zone parameter", l}, ""
|
return nil, &ParseError{f, "bad SOA zone parameter", l}, ""
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue