gofmt
This commit is contained in:
parent
69cecf63bd
commit
89c05b4f74
62
defaults.go
62
defaults.go
|
@ -214,10 +214,10 @@ func IsDomainName(s string) (uint8, uint8, bool) { // copied from net package.
|
||||||
l++
|
l++
|
||||||
longer = 1
|
longer = 1
|
||||||
}
|
}
|
||||||
// Preloop check for root label
|
// Preloop check for root label
|
||||||
if s == "." {
|
if s == "." {
|
||||||
return 0, 1, true
|
return 0, 1, true
|
||||||
}
|
}
|
||||||
|
|
||||||
last := byte('.')
|
last := byte('.')
|
||||||
ok := false // ok once we've seen a letter or digit
|
ok := false // ok once we've seen a letter or digit
|
||||||
|
@ -264,37 +264,37 @@ func IsDomainName(s string) (uint8, uint8, bool) { // copied from net package.
|
||||||
|
|
||||||
// IsSubDomain checks if child is indeed a child of the parent.
|
// IsSubDomain checks if child is indeed a child of the parent.
|
||||||
func IsSubDomain(parent, child string) bool {
|
func IsSubDomain(parent, child string) bool {
|
||||||
// If the number of labels both domain name have
|
// If the number of labels both domain name have
|
||||||
// in common equals the number of labels of parent,
|
// in common equals the number of labels of parent,
|
||||||
// child is a subdomain of parent.
|
// child is a subdomain of parent.
|
||||||
plabs := SplitLabels(parent)
|
plabs := SplitLabels(parent)
|
||||||
clabs := SplitLabels(child)
|
clabs := SplitLabels(child)
|
||||||
if len(clabs) < len(plabs) {
|
if len(clabs) < len(plabs) {
|
||||||
// child is smaller than parent, reversed arguments?
|
// child is smaller than parent, reversed arguments?
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// Copied from CompareLabels to prevent another SplitLabels
|
// Copied from CompareLabels to prevent another SplitLabels
|
||||||
n := 0
|
n := 0
|
||||||
p := len(plabs) - 1
|
p := len(plabs) - 1
|
||||||
c := len(clabs) - 1
|
c := len(clabs) - 1
|
||||||
for {
|
for {
|
||||||
if p < 0 || c < 0 {
|
if p < 0 || c < 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if plabs[p] == clabs[c] {
|
if plabs[p] == clabs[c] {
|
||||||
n++
|
n++
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
p--
|
p--
|
||||||
c--
|
c--
|
||||||
}
|
}
|
||||||
return n == len(plabs)
|
return n == len(plabs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsFqdn checks if a domain name is fully qualified.
|
// IsFqdn checks if a domain name is fully qualified.
|
||||||
func IsFqdn(s string) bool {
|
func IsFqdn(s string) bool {
|
||||||
l := len(s)
|
l := len(s)
|
||||||
if l == 0 {
|
if l == 0 {
|
||||||
return false // ?
|
return false // ?
|
||||||
}
|
}
|
||||||
|
|
14
dns.go
14
dns.go
|
@ -174,13 +174,13 @@ func (h *RR_Header) Len() int {
|
||||||
// Create a copy of the header
|
// Create a copy of the header
|
||||||
|
|
||||||
func (h *RR_Header) Copy() *RR_Header {
|
func (h *RR_Header) Copy() *RR_Header {
|
||||||
h1 := new(RR_Header)
|
h1 := new(RR_Header)
|
||||||
h1.Name = h.Name
|
h1.Name = h.Name
|
||||||
h1.Rrtype = h.Rrtype
|
h1.Rrtype = h.Rrtype
|
||||||
h1.Class = h.Class
|
h1.Class = h.Class
|
||||||
h1.Ttl = h.Ttl
|
h1.Ttl = h.Ttl
|
||||||
h1.Rdlength = h.Rdlength
|
h1.Rdlength = h.Rdlength
|
||||||
return h1
|
return h1
|
||||||
}
|
}
|
||||||
|
|
||||||
func zoneMatch(pattern, zone string) (ok bool) {
|
func zoneMatch(pattern, zone string) (ok bool) {
|
||||||
|
|
40
dns_test.go
40
dns_test.go
|
@ -80,24 +80,24 @@ func TestEDNS_RR(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBailiwick(t *testing.T) {
|
func TestBailiwick(t *testing.T) {
|
||||||
yes := map[string]string{
|
yes := map[string]string{
|
||||||
"miek.nl": "ns.miek.nl",
|
"miek.nl": "ns.miek.nl",
|
||||||
".": "miek.nl",
|
".": "miek.nl",
|
||||||
}
|
}
|
||||||
for parent, child := range yes {
|
for parent, child := range yes {
|
||||||
if !IsSubDomain(parent, child) {
|
if !IsSubDomain(parent, child) {
|
||||||
t.Logf("%s should be child of %s\n", child, parent)
|
t.Logf("%s should be child of %s\n", child, parent)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
no := map[string]string{
|
no := map[string]string{
|
||||||
"www.miek.nl": "ns.miek.nl",
|
"www.miek.nl": "ns.miek.nl",
|
||||||
"miek.nl": ".",
|
"miek.nl": ".",
|
||||||
}
|
}
|
||||||
for parent, child := range no {
|
for parent, child := range no {
|
||||||
if IsSubDomain(parent, child) {
|
if IsSubDomain(parent, child) {
|
||||||
t.Logf("%s should not be child of %s\n", child, parent)
|
t.Logf("%s should not be child of %s\n", child, parent)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -498,8 +498,8 @@ func (p wireSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||||
func rawSignatureData(rrset []RR, s *RR_RRSIG) (buf []byte) {
|
func rawSignatureData(rrset []RR, s *RR_RRSIG) (buf []byte) {
|
||||||
wires := make(wireSlice, len(rrset))
|
wires := make(wireSlice, len(rrset))
|
||||||
for i, r := range rrset {
|
for i, r := range rrset {
|
||||||
r1 := r
|
r1 := r
|
||||||
h1 := r1.Header()
|
h1 := r1.Header()
|
||||||
labels := SplitLabels(h1.Name)
|
labels := SplitLabels(h1.Name)
|
||||||
// 6.2. Canonical RR Form. (4) - wildcards
|
// 6.2. Canonical RR Form. (4) - wildcards
|
||||||
if len(labels) > int(s.Labels) {
|
if len(labels) > int(s.Labels) {
|
||||||
|
@ -512,7 +512,7 @@ func rawSignatureData(rrset []RR, s *RR_RRSIG) (buf []byte) {
|
||||||
// NS, MD, MF, CNAME, SOA, MB, MG, MR, PTR,
|
// NS, MD, MF, CNAME, SOA, MB, MG, MR, PTR,
|
||||||
// HINFO, MINFO, MX, RP, AFSDB, RT, SIG, PX, NXT, NAPTR, KX,
|
// HINFO, MINFO, MX, RP, AFSDB, RT, SIG, PX, NXT, NAPTR, KX,
|
||||||
// SRV, DNAME, A6
|
// SRV, DNAME, A6
|
||||||
switch x := r1.(type) {
|
switch x := r1.(type) {
|
||||||
case *RR_NS:
|
case *RR_NS:
|
||||||
x.Ns = strings.ToLower(x.Ns)
|
x.Ns = strings.ToLower(x.Ns)
|
||||||
case *RR_CNAME:
|
case *RR_CNAME:
|
||||||
|
|
4
kscan.go
4
kscan.go
|
@ -91,7 +91,7 @@ func readPrivateKeyECDSA(m map[string]string) (PrivateKey, error) {
|
||||||
// parseKey reads a private key from r. It returns a map[string]string,
|
// parseKey reads a private key from r. It returns a map[string]string,
|
||||||
// with the key-value pairs, or an error when the file is not correct.
|
// with the key-value pairs, or an error when the file is not correct.
|
||||||
func parseKey(r io.Reader, file string) (map[string]string, error) {
|
func parseKey(r io.Reader, file string) (map[string]string, error) {
|
||||||
s := scanInit(r)
|
s := scanInit(r)
|
||||||
m := make(map[string]string)
|
m := make(map[string]string)
|
||||||
c := make(chan lex)
|
c := make(chan lex)
|
||||||
k := ""
|
k := ""
|
||||||
|
@ -160,7 +160,7 @@ func klexer(s *scan, c chan lex) {
|
||||||
}
|
}
|
||||||
str += string(x)
|
str += string(x)
|
||||||
}
|
}
|
||||||
x, err = s.tokenText()
|
x, err = s.tokenText()
|
||||||
}
|
}
|
||||||
if len(str) > 0 {
|
if len(str) > 0 {
|
||||||
// Send remainder
|
// Send remainder
|
||||||
|
|
|
@ -6,9 +6,9 @@ package dns
|
||||||
// www.miek.nl. returns []string{"www", "miek", "nl"}
|
// www.miek.nl. returns []string{"www", "miek", "nl"}
|
||||||
// The root label (.) returns nil.
|
// The root label (.) returns nil.
|
||||||
func SplitLabels(s string) []string {
|
func SplitLabels(s string) []string {
|
||||||
if (s == ".") {
|
if s == "." {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
k := 0
|
k := 0
|
||||||
labels := make([]string, 0)
|
labels := make([]string, 0)
|
||||||
|
|
|
@ -132,8 +132,8 @@ z3.miek.nl. IN NSEC miek.nl. TXT RRSIG NSEC`
|
||||||
|
|
||||||
func TestDomainName(t *testing.T) {
|
func TestDomainName(t *testing.T) {
|
||||||
tests := []string{"r\\.gieben.miek.nl.", "www\\.www.miek.nl.",
|
tests := []string{"r\\.gieben.miek.nl.", "www\\.www.miek.nl.",
|
||||||
"www.*.miek.nl.", "www.*.miek.nl.",
|
"www.*.miek.nl.", "www.*.miek.nl.",
|
||||||
}
|
}
|
||||||
dbuff := make([]byte, 40)
|
dbuff := make([]byte, 40)
|
||||||
|
|
||||||
for _, ts := range tests {
|
for _, ts := range tests {
|
||||||
|
@ -157,21 +157,19 @@ func TestDomainName(t *testing.T) {
|
||||||
|
|
||||||
func TestParseDirectiveMisc(t *testing.T) {
|
func TestParseDirectiveMisc(t *testing.T) {
|
||||||
tests := map[string]string{
|
tests := map[string]string{
|
||||||
"$ORIGIN miek.nl.\na IN NS b": "a.miek.nl.\t3600\tIN\tNS\tb.miek.nl.",
|
"$ORIGIN miek.nl.\na IN NS b": "a.miek.nl.\t3600\tIN\tNS\tb.miek.nl.",
|
||||||
"$TTL 2H\nmiek.nl. IN NS b.": "miek.nl.\t7200\tIN\tNS\tb.",
|
"$TTL 2H\nmiek.nl. IN NS b.": "miek.nl.\t7200\tIN\tNS\tb.",
|
||||||
"miek.nl. 1D IN NS b.": "miek.nl.\t86400\tIN\tNS\tb.",
|
"miek.nl. 1D IN NS b.": "miek.nl.\t86400\tIN\tNS\tb.",
|
||||||
`name. IN SOA a6.nstld.com. hostmaster.nic.name. (
|
`name. IN SOA a6.nstld.com. hostmaster.nic.name. (
|
||||||
203362132 ; serial
|
203362132 ; serial
|
||||||
5m ; refresh (5 minutes)
|
5m ; refresh (5 minutes)
|
||||||
5m ; retry (5 minutes)
|
5m ; retry (5 minutes)
|
||||||
2w ; expire (2 weeks)
|
2w ; expire (2 weeks)
|
||||||
300 ; minimum (5 minutes)
|
300 ; minimum (5 minutes)
|
||||||
)`: "name.\t3600\tIN\tSOA\ta6.nstld.com. hostmaster.nic.name. 203362132 300 300 1209600 300",
|
)`: "name.\t3600\tIN\tSOA\ta6.nstld.com. hostmaster.nic.name. 203362132 300 300 1209600 300",
|
||||||
". 3600000 IN NS ONE.MY-ROOTS.NET.":
|
". 3600000 IN NS ONE.MY-ROOTS.NET.": ".\t3600000\tIN\tNS\tONE.MY-ROOTS.NET.",
|
||||||
".\t3600000\tIN\tNS\tONE.MY-ROOTS.NET.",
|
"ONE.MY-ROOTS.NET. 3600000 IN A 192.168.1.1": "ONE.MY-ROOTS.NET.\t3600000\tIN\tA\t192.168.1.1",
|
||||||
"ONE.MY-ROOTS.NET. 3600000 IN A 192.168.1.1":
|
}
|
||||||
"ONE.MY-ROOTS.NET.\t3600000\tIN\tA\t192.168.1.1",
|
|
||||||
}
|
|
||||||
for i, o := range tests {
|
for i, o := range tests {
|
||||||
rr, e := NewRR(i)
|
rr, e := NewRR(i)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
@ -191,11 +189,10 @@ func TestParseDirectiveMisc(t *testing.T) {
|
||||||
// Another one hear, geared to NSECx
|
// Another one hear, geared to NSECx
|
||||||
func TestParseNSEC(t *testing.T) {
|
func TestParseNSEC(t *testing.T) {
|
||||||
nsectests := map[string]string{
|
nsectests := map[string]string{
|
||||||
"nl. IN NSEC3PARAM 1 0 5 30923C44C6CBBB8F": "nl.\t3600\tIN\tNSEC3PARAM\t1 0 5 30923C44C6CBBB8F",
|
"nl. IN NSEC3PARAM 1 0 5 30923C44C6CBBB8F": "nl.\t3600\tIN\tNSEC3PARAM\t1 0 5 30923C44C6CBBB8F",
|
||||||
"p2209hipbpnm681knjnu0m1febshlv4e.nl. IN NSEC3 1 1 5 30923C44C6CBBB8F P90DG1KE8QEAN0B01613LHQDG0SOJ0TA NS SOA TXT RRSIG DNSKEY NSEC3PARAM":
|
"p2209hipbpnm681knjnu0m1febshlv4e.nl. IN NSEC3 1 1 5 30923C44C6CBBB8F P90DG1KE8QEAN0B01613LHQDG0SOJ0TA NS SOA TXT RRSIG DNSKEY NSEC3PARAM": "p2209hipbpnm681knjnu0m1febshlv4e.nl.\t3600\tIN\tNSEC3\t1 1 5 30923C44C6CBBB8F P90DG1KE8QEAN0B01613LHQDG0SOJ0TA NS SOA TXT RRSIG DNSKEY NSEC3PARAM",
|
||||||
"p2209hipbpnm681knjnu0m1febshlv4e.nl.\t3600\tIN\tNSEC3\t1 1 5 30923C44C6CBBB8F P90DG1KE8QEAN0B01613LHQDG0SOJ0TA NS SOA TXT RRSIG DNSKEY NSEC3PARAM",
|
"localhost.dnssex.nl. IN NSEC www.dnssex.nl. A RRSIG NSEC": "localhost.dnssex.nl.\t3600\tIN\tNSEC\twww.dnssex.nl. A RRSIG NSEC",
|
||||||
"localhost.dnssex.nl. IN NSEC www.dnssex.nl. A RRSIG NSEC": "localhost.dnssex.nl.\t3600\tIN\tNSEC\twww.dnssex.nl. A RRSIG NSEC",
|
}
|
||||||
}
|
|
||||||
for i, o := range nsectests {
|
for i, o := range nsectests {
|
||||||
rr, e := NewRR(i)
|
rr, e := NewRR(i)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
@ -214,27 +211,23 @@ func TestParseNSEC(t *testing.T) {
|
||||||
|
|
||||||
func TestQuotes(t *testing.T) {
|
func TestQuotes(t *testing.T) {
|
||||||
tests := map[string]string{
|
tests := map[string]string{
|
||||||
`t.example.com. IN TXT "a bc"`: "t.example.com.\t3600\tIN\tTXT\t\"a bc\"",
|
`t.example.com. IN TXT "a bc"`: "t.example.com.\t3600\tIN\tTXT\t\"a bc\"",
|
||||||
`t.example.com. IN TXT "a
|
`t.example.com. IN TXT "a
|
||||||
bc"`: "t.example.com.\t3600\tIN\tTXT\t\"a\\n bc\"",
|
bc"`: "t.example.com.\t3600\tIN\tTXT\t\"a\\n bc\"",
|
||||||
`t.example.com. IN TXT "a"`: "t.example.com.\t3600\tIN\tTXT\t\"a\"",
|
`t.example.com. IN TXT "a"`: "t.example.com.\t3600\tIN\tTXT\t\"a\"",
|
||||||
`t.example.com. IN TXT "aa"`: "t.example.com.\t3600\tIN\tTXT\t\"aa\"",
|
`t.example.com. IN TXT "aa"`: "t.example.com.\t3600\tIN\tTXT\t\"aa\"",
|
||||||
`t.example.com. IN TXT "aaa" ;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa\"",
|
`t.example.com. IN TXT "aaa" ;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa\"",
|
||||||
`t.example.com. IN TXT "abc" "DEF"`: "t.example.com.\t3600\tIN\tTXT\t\"abc\" \"DEF\"",
|
`t.example.com. IN TXT "abc" "DEF"`: "t.example.com.\t3600\tIN\tTXT\t\"abc\" \"DEF\"",
|
||||||
`t.example.com. IN TXT "abc" ( "DEF" )`: "t.example.com.\t3600\tIN\tTXT\t\"abc\" \"DEF\"",
|
`t.example.com. IN TXT "abc" ( "DEF" )`: "t.example.com.\t3600\tIN\tTXT\t\"abc\" \"DEF\"",
|
||||||
`t.example.com. IN TXT aaa ;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa \"",
|
`t.example.com. IN TXT aaa ;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa \"",
|
||||||
`t.example.com. IN TXT aaa aaa;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa aaa\"",
|
`t.example.com. IN TXT aaa aaa;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa aaa\"",
|
||||||
`t.example.com. IN TXT aaa aaa`: "t.example.com.\t3600\tIN\tTXT\t\"aaa aaa\"",
|
`t.example.com. IN TXT aaa aaa`: "t.example.com.\t3600\tIN\tTXT\t\"aaa aaa\"",
|
||||||
`t.example.com. IN TXT aaa`: "t.example.com.\t3600\tIN\tTXT\t\"aaa\"",
|
`t.example.com. IN TXT aaa`: "t.example.com.\t3600\tIN\tTXT\t\"aaa\"",
|
||||||
"cid.urn.arpa. NAPTR 100 50 \"s\" \"z3950+I2L+I2C\" \"\" _z3950._tcp.gatech.edu.":
|
"cid.urn.arpa. NAPTR 100 50 \"s\" \"z3950+I2L+I2C\" \"\" _z3950._tcp.gatech.edu.": "cid.urn.arpa.\t3600\tIN\tNAPTR\t100 50 \"s\" \"z3950+I2L+I2C\" \"\" _z3950._tcp.gatech.edu.",
|
||||||
"cid.urn.arpa.\t3600\tIN\tNAPTR\t100 50 \"s\" \"z3950+I2L+I2C\" \"\" _z3950._tcp.gatech.edu.",
|
"cid.urn.arpa. NAPTR 100 50 \"s\" \"rcds+I2C\" \"\" _rcds._udp.gatech.edu.": "cid.urn.arpa.\t3600\tIN\tNAPTR\t100 50 \"s\" \"rcds+I2C\" \"\" _rcds._udp.gatech.edu.",
|
||||||
"cid.urn.arpa. NAPTR 100 50 \"s\" \"rcds+I2C\" \"\" _rcds._udp.gatech.edu.":
|
"cid.urn.arpa. NAPTR 100 50 \"s\" \"http+I2L+I2C+I2R\" \"\" _http._tcp.gatech.edu.": "cid.urn.arpa.\t3600\tIN\tNAPTR\t100 50 \"s\" \"http+I2L+I2C+I2R\" \"\" _http._tcp.gatech.edu.",
|
||||||
"cid.urn.arpa.\t3600\tIN\tNAPTR\t100 50 \"s\" \"rcds+I2C\" \"\" _rcds._udp.gatech.edu.",
|
"cid.urn.arpa. NAPTR 100 10 \"\" \"\" \"/urn:cid:.+@([^\\.]+\\.)(.*)$/\\2/i\" .": "cid.urn.arpa.\t3600\tIN\tNAPTR\t100 10 \"\" \"\" \"/urn:cid:.+@([^\\.]+\\.)(.*)$/\\2/i\" .",
|
||||||
"cid.urn.arpa. NAPTR 100 50 \"s\" \"http+I2L+I2C+I2R\" \"\" _http._tcp.gatech.edu.":
|
}
|
||||||
"cid.urn.arpa.\t3600\tIN\tNAPTR\t100 50 \"s\" \"http+I2L+I2C+I2R\" \"\" _http._tcp.gatech.edu.",
|
|
||||||
"cid.urn.arpa. NAPTR 100 10 \"\" \"\" \"/urn:cid:.+@([^\\.]+\\.)(.*)$/\\2/i\" .":
|
|
||||||
"cid.urn.arpa.\t3600\tIN\tNAPTR\t100 10 \"\" \"\" \"/urn:cid:.+@([^\\.]+\\.)(.*)$/\\2/i\" .",
|
|
||||||
}
|
|
||||||
for i, o := range tests {
|
for i, o := range tests {
|
||||||
rr, e := NewRR(i)
|
rr, e := NewRR(i)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
@ -257,11 +250,10 @@ func TestParseBrace(t *testing.T) {
|
||||||
"miek.nl. (3600) IN MX (10) elektron.atoom.net.": "miek.nl.\t3600\tIN\tMX\t10 elektron.atoom.net.",
|
"miek.nl. (3600) IN MX (10) elektron.atoom.net.": "miek.nl.\t3600\tIN\tMX\t10 elektron.atoom.net.",
|
||||||
`miek.nl. IN (
|
`miek.nl. IN (
|
||||||
3600 A 127.0.0.1)`: "miek.nl.\t3600\tIN\tA\t127.0.0.1",
|
3600 A 127.0.0.1)`: "miek.nl.\t3600\tIN\tA\t127.0.0.1",
|
||||||
"(miek.nl.) (A) (127.0.0.1)": "miek.nl.\t3600\tIN\tA\t127.0.0.1",
|
"(miek.nl.) (A) (127.0.0.1)": "miek.nl.\t3600\tIN\tA\t127.0.0.1",
|
||||||
"miek.nl A 127.0.0.1": "miek.nl.\t3600\tIN\tA\t127.0.0.1",
|
"miek.nl A 127.0.0.1": "miek.nl.\t3600\tIN\tA\t127.0.0.1",
|
||||||
"_ssh._tcp.local. 60 IN (PTR) stora._ssh._tcp.local.":
|
"_ssh._tcp.local. 60 IN (PTR) stora._ssh._tcp.local.": "_ssh._tcp.local.\t60\tIN\tPTR\tstora._ssh._tcp.local.",
|
||||||
"_ssh._tcp.local.\t60\tIN\tPTR\tstora._ssh._tcp.local.",
|
"miek.nl. NS ns.miek.nl": "miek.nl.\t3600\tIN\tNS\tns.miek.nl.",
|
||||||
"miek.nl. NS ns.miek.nl": "miek.nl.\t3600\tIN\tNS\tns.miek.nl.",
|
|
||||||
`(miek.nl.) (
|
`(miek.nl.) (
|
||||||
(IN)
|
(IN)
|
||||||
(AAAA)
|
(AAAA)
|
||||||
|
@ -374,7 +366,7 @@ func TestZoneParsing(t *testing.T) {
|
||||||
// moutamassey.0-g.name.name. 10800 IN NS ns01.yahoodomains.jp.
|
// moutamassey.0-g.name.name. 10800 IN NS ns01.yahoodomains.jp.
|
||||||
// moutamassey.0-g.name.name. 10800 IN NS ns02.yahoodomains.jp.
|
// moutamassey.0-g.name.name. 10800 IN NS ns02.yahoodomains.jp.
|
||||||
func ExampleZone() {
|
func ExampleZone() {
|
||||||
zone :=`$ORIGIN .
|
zone := `$ORIGIN .
|
||||||
$TTL 3600 ; 1 hour
|
$TTL 3600 ; 1 hour
|
||||||
name IN SOA a6.nstld.com. hostmaster.nic.name. (
|
name IN SOA a6.nstld.com. hostmaster.nic.name. (
|
||||||
203362132 ; serial
|
203362132 ; serial
|
||||||
|
@ -414,20 +406,20 @@ moutamassey NS ns01.yahoodomains.jp.
|
||||||
|
|
||||||
// www.example.com. 3600 IN HIP 2 200100107B1A74DF365639CC39F1D578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs.example.com.
|
// www.example.com. 3600 IN HIP 2 200100107B1A74DF365639CC39F1D578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs.example.com.
|
||||||
func ExampleHIP() {
|
func ExampleHIP() {
|
||||||
h := `www.example.com IN HIP ( 2 200100107B1A74DF365639CC39F1D578
|
h := `www.example.com IN HIP ( 2 200100107B1A74DF365639CC39F1D578
|
||||||
AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p
|
AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p
|
||||||
9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQ
|
9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQ
|
||||||
b1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D
|
b1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D
|
||||||
rvs.example.com. )`
|
rvs.example.com. )`
|
||||||
if hip, err := NewRR(h); err == nil {
|
if hip, err := NewRR(h); err == nil {
|
||||||
fmt.Printf("%s\n", hip.String())
|
fmt.Printf("%s\n", hip.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// example.com. 1000 IN SOA master.example.com. admin.example.com. 1 4294967294 4294967293 4294967295 100
|
// example.com. 1000 IN SOA master.example.com. admin.example.com. 1 4294967294 4294967293 4294967295 100
|
||||||
func ExampleSOA() {
|
func ExampleSOA() {
|
||||||
s := "example.com. 1000 SOA master.example.com. admin.example.com. 1 4294967294 4294967293 4294967295 100"
|
s := "example.com. 1000 SOA master.example.com. admin.example.com. 1 4294967294 4294967293 4294967295 100"
|
||||||
if soa, err := NewRR(s); err == nil {
|
if soa, err := NewRR(s); err == nil {
|
||||||
fmt.Printf("%s\n", soa.String())
|
fmt.Printf("%s\n", soa.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
zscan_rr.go
10
zscan_rr.go
|
@ -1,10 +1,10 @@
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"encoding/base64"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Parse the rdata of each rrtype.
|
// Parse the rdata of each rrtype.
|
||||||
|
@ -49,7 +49,7 @@ func setRR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
case TypeNAPTR:
|
case TypeNAPTR:
|
||||||
r, e = setNAPTR(h, c, o, f)
|
r, e = setNAPTR(h, c, o, f)
|
||||||
goto Slurp
|
goto Slurp
|
||||||
case TypeTALINK:
|
case TypeTALINK:
|
||||||
r, e = setTALINK(h, c, o, f)
|
r, e = setTALINK(h, c, o, f)
|
||||||
goto Slurp
|
goto Slurp
|
||||||
case TypeLOC:
|
case TypeLOC:
|
||||||
|
@ -410,7 +410,7 @@ func setTALINK(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
if rr.PreviousName[ld-1] != '.' {
|
if rr.PreviousName[ld-1] != '.' {
|
||||||
rr.PreviousName = appendOrigin(rr.PreviousName, o)
|
rr.PreviousName = appendOrigin(rr.PreviousName, o)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
rr.NextName = l.token
|
rr.NextName = l.token
|
||||||
_, ld, ok = IsDomainName(l.token)
|
_, ld, ok = IsDomainName(l.token)
|
||||||
|
@ -437,12 +437,12 @@ func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c // _STRING
|
l = <-c // _STRING
|
||||||
rr.Hit = l.token // This can not contain spaces, see RFC 5205 Section 6.
|
rr.Hit = l.token // This can not contain spaces, see RFC 5205 Section 6.
|
||||||
rr.HitLength = uint8(len(rr.Hit))/2
|
rr.HitLength = uint8(len(rr.Hit)) / 2
|
||||||
|
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c // _STRING
|
l = <-c // _STRING
|
||||||
rr.PublicKey = l.token // This cannot contain spaces
|
rr.PublicKey = l.token // This cannot contain spaces
|
||||||
rr.PublicKeyLength = uint16(base64.StdEncoding.DecodedLen(len(rr.PublicKey)))
|
rr.PublicKeyLength = uint16(base64.StdEncoding.DecodedLen(len(rr.PublicKey)))
|
||||||
|
|
||||||
// RendezvousServers (if any)
|
// RendezvousServers (if any)
|
||||||
l = <-c
|
l = <-c
|
||||||
|
|
Loading…
Reference in New Issue