add this example too
This commit is contained in:
parent
f933c60b23
commit
bc4d7ed748
|
@ -0,0 +1,8 @@
|
|||
# Copyright 2009 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
include $(GOROOT)/src/Make.inc
|
||||
TARG=key2ds
|
||||
GOFILES=key2ds.go
|
||||
DEPS=../../
|
||||
include $(GOROOT)/src/Make.cmd
|
|
@ -0,0 +1,43 @@
|
|||
package main
|
||||
|
||||
// Print the MX records of a domain
|
||||
// (c) Miek Gieben - 2011
|
||||
import (
|
||||
"dns"
|
||||
"os"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := new(dns.Resolver)
|
||||
r.FromFile("/etc/resolv.conf")
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Printf("%s DOMAIN\n", os.Args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
m := new(dns.Msg)
|
||||
m.MsgHdr.RecursionDesired = true //only set this bit
|
||||
m.Question = make([]dns.Question, 1)
|
||||
m.Question[0] = dns.Question{os.Args[1], dns.TypeDNSKEY, dns.ClassINET}
|
||||
|
||||
in, err := r.Query(m)
|
||||
if in != nil {
|
||||
if in.Rcode != dns.RcodeSuccess {
|
||||
fmt.Printf(" *** invalid answer name %s after DNSKEY query for %s\n", os.Args[1], os.Args[1])
|
||||
os.Exit(1)
|
||||
}
|
||||
// Stuff must be in the answer section
|
||||
for _, k := range in.Answer {
|
||||
// Foreach key would need to provide a DS records, both sha1 and sha256
|
||||
if key, ok := k.(*dns.RR_DNSKEY); ok {
|
||||
fmt.Printf("%v\n", key)
|
||||
ds := key.ToDS(dns.HashSHA1)
|
||||
fmt.Printf("\t%v\n", ds)
|
||||
ds = key.ToDS(dns.HashSHA256)
|
||||
fmt.Printf("\t%v\n", ds)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("*** error: %s\n", err.String())
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ func reply(c *dns.Conn, in *dns.Msg) []byte {
|
|||
// Copy the question.
|
||||
m.Question[0] = in.Question[0]
|
||||
|
||||
// Some foo to check if we are called trough ip6 or ip4.
|
||||
// Some foo to check if we are called through ip6 or ip4.
|
||||
// We add the correct reply RR.
|
||||
var ad net.IP
|
||||
if c.UDP != nil {
|
||||
|
|
|
@ -32,7 +32,8 @@ const (
|
|||
|
||||
// DNSSEC hashing codes.
|
||||
const (
|
||||
HashSHA1 = iota
|
||||
_ = iota
|
||||
HashSHA1
|
||||
HashSHA256
|
||||
HashGOST94
|
||||
)
|
||||
|
@ -104,6 +105,7 @@ func (k *RR_DNSKEY) ToDS(h int) *RR_DS {
|
|||
ds := new(RR_DS)
|
||||
ds.Hdr.Name = k.Hdr.Name
|
||||
ds.Hdr.Class = k.Hdr.Class
|
||||
ds.Hdr.Rrtype = TypeDS
|
||||
ds.Hdr.Ttl = k.Hdr.Ttl
|
||||
ds.Algorithm = k.Algorithm
|
||||
ds.DigestType = uint8(h)
|
||||
|
|
Loading…
Reference in New Issue