gofmt
This commit is contained in:
parent
ba747fd510
commit
d53d9eab81
18
defaults.go
18
defaults.go
|
@ -102,7 +102,7 @@ func (dns *Msg) SetAxfr(z string) *Msg {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTsig appends a TSIG RR to the message.
|
// SetTsig appends a TSIG RR to the message.
|
||||||
// This is only a skeleton TSIG RR that is added as the last RR in the
|
// This is only a skeleton TSIG RR that is added as the last RR in the
|
||||||
// additional section. The Tsig is calculated when the message is being send.
|
// additional section. The Tsig is calculated when the message is being send.
|
||||||
func (dns *Msg) SetTsig(z, algo string, fudge, timesigned int64) *Msg {
|
func (dns *Msg) SetTsig(z, algo string, fudge, timesigned int64) *Msg {
|
||||||
t := new(TSIG)
|
t := new(TSIG)
|
||||||
|
@ -115,7 +115,7 @@ func (dns *Msg) SetTsig(z, algo string, fudge, timesigned int64) *Msg {
|
||||||
return dns
|
return dns
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetEdns0 appends a EDNS0 OPT RR to the message.
|
// SetEdns0 appends a EDNS0 OPT RR to the message.
|
||||||
// TSIG should always the last RR in a message.
|
// TSIG should always the last RR in a message.
|
||||||
func (dns *Msg) SetEdns0(udpsize uint16, do bool) *Msg {
|
func (dns *Msg) SetEdns0(udpsize uint16, do bool) *Msg {
|
||||||
e := new(OPT)
|
e := new(OPT)
|
||||||
|
@ -153,7 +153,7 @@ func (dns *Msg) IsEdns0() *OPT {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsDomainName checks if s is a valid domainname, it returns
|
// IsDomainName checks if s is a valid domainname, it returns
|
||||||
// the number of labels, total length and true, when a domain name is valid.
|
// the number of labels, total length and true, when a domain name is valid.
|
||||||
// When false is returned the labelcount and length are not defined.
|
// When false is returned the labelcount and length are not defined.
|
||||||
func IsDomainName(s string) (uint8, uint8, bool) { // copied from net package.
|
func IsDomainName(s string) (uint8, uint8, bool) { // copied from net package.
|
||||||
// TODO(mg): check for \DDD
|
// TODO(mg): check for \DDD
|
||||||
|
@ -250,9 +250,9 @@ func Fqdn(s string) string {
|
||||||
|
|
||||||
// Copied from the official Go code
|
// Copied from the official Go code
|
||||||
|
|
||||||
// ReverseAddr returns the in-addr.arpa. or ip6.arpa. hostname of the IP
|
// ReverseAddr returns the in-addr.arpa. or ip6.arpa. hostname of the IP
|
||||||
// address addr suitable for rDNS (PTR) record lookup or an error if it fails
|
// address addr suitable for rDNS (PTR) record lookup or an error if it fails
|
||||||
// to parse the IP address.
|
// to parse the IP address.
|
||||||
func ReverseAddr(addr string) (arpa string, err error) {
|
func ReverseAddr(addr string) (arpa string, err error) {
|
||||||
ip := net.ParseIP(addr)
|
ip := net.ParseIP(addr)
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
|
@ -262,9 +262,9 @@ func ReverseAddr(addr string) (arpa string, err error) {
|
||||||
return strconv.Itoa(int(ip[15])) + "." + strconv.Itoa(int(ip[14])) + "." + strconv.Itoa(int(ip[13])) + "." +
|
return strconv.Itoa(int(ip[15])) + "." + strconv.Itoa(int(ip[14])) + "." + strconv.Itoa(int(ip[13])) + "." +
|
||||||
strconv.Itoa(int(ip[12])) + ".in-addr.arpa.", nil
|
strconv.Itoa(int(ip[12])) + ".in-addr.arpa.", nil
|
||||||
}
|
}
|
||||||
// Must be IPv6
|
// Must be IPv6
|
||||||
buf := make([]byte, 0, len(ip)*4+len("ip6.arpa."))
|
buf := make([]byte, 0, len(ip)*4+len("ip6.arpa."))
|
||||||
// Add it, in reverse, to the buffer
|
// Add it, in reverse, to the buffer
|
||||||
for i := len(ip) - 1; i >= 0; i-- {
|
for i := len(ip) - 1; i >= 0; i-- {
|
||||||
v := ip[i]
|
v := ip[i]
|
||||||
buf = append(buf, hexDigit[v&0xF])
|
buf = append(buf, hexDigit[v&0xF])
|
||||||
|
@ -272,7 +272,7 @@ func ReverseAddr(addr string) (arpa string, err error) {
|
||||||
buf = append(buf, hexDigit[v>>4])
|
buf = append(buf, hexDigit[v>>4])
|
||||||
buf = append(buf, '.')
|
buf = append(buf, '.')
|
||||||
}
|
}
|
||||||
// Append "ip6.arpa." and return (buf already has the final .)
|
// Append "ip6.arpa." and return (buf already has the final .)
|
||||||
buf = append(buf, "ip6.arpa."...)
|
buf = append(buf, "ip6.arpa."...)
|
||||||
return string(buf), nil
|
return string(buf), nil
|
||||||
}
|
}
|
||||||
|
|
4
dns.go
4
dns.go
|
@ -8,7 +8,7 @@
|
||||||
// The package allows complete control over what is send out to the DNS. The package
|
// The package allows complete control over what is send out to the DNS. The package
|
||||||
// API follows the less-is-more principle, by presenting a small, clean interface.
|
// API follows the less-is-more principle, by presenting a small, clean interface.
|
||||||
//
|
//
|
||||||
// The package dns supports (asynchronous) querying/replying, incoming/outgoing AXFR/IXFR,
|
// The package dns supports (asynchronous) querying/replying, incoming/outgoing AXFR/IXFR,
|
||||||
// TSIG, EDNS0, dynamic updates, notifies and DNSSEC validation/signing.
|
// TSIG, EDNS0, dynamic updates, notifies and DNSSEC validation/signing.
|
||||||
// Note that domain names MUST be fully qualified, before sending them, unqualified
|
// Note that domain names MUST be fully qualified, before sending them, unqualified
|
||||||
// names in a message will result in a packing failure.
|
// names in a message will result in a packing failure.
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
// the authority section: in.Ns and the additional section: in.Extra.
|
// the authority section: in.Ns and the additional section: in.Extra.
|
||||||
//
|
//
|
||||||
// Each of these sections (except the Question section) contain a []RR. Basic
|
// Each of these sections (except the Question section) contain a []RR. Basic
|
||||||
// use pattern for accessing the rdata of a TXT RR as the first RR in
|
// use pattern for accessing the rdata of a TXT RR as the first RR in
|
||||||
// the Answer section:
|
// the Answer section:
|
||||||
//
|
//
|
||||||
// if t, ok := in.Answer[0].(*TXT); ok {
|
// if t, ok := in.Answer[0].(*TXT); ok {
|
||||||
|
|
14
dnssec.go
14
dnssec.go
|
@ -8,7 +8,7 @@
|
||||||
//
|
//
|
||||||
// Requesting DNSSEC information for a zone is done by adding the DO (DNSSEC OK) bit
|
// Requesting DNSSEC information for a zone is done by adding the DO (DNSSEC OK) bit
|
||||||
// to an request.
|
// to an request.
|
||||||
//
|
//
|
||||||
// m := new(dns.Msg)
|
// m := new(dns.Msg)
|
||||||
// m.SetEdns0(4096, true)
|
// m.SetEdns0(4096, true)
|
||||||
//
|
//
|
||||||
|
@ -61,7 +61,7 @@ const (
|
||||||
const (
|
const (
|
||||||
_ = iota
|
_ = iota
|
||||||
SHA1 // RFC 4034
|
SHA1 // RFC 4034
|
||||||
SHA256 // RFC 4509
|
SHA256 // RFC 4509
|
||||||
GOST94 // RFC 5933
|
GOST94 // RFC 5933
|
||||||
SHA384 // Experimental
|
SHA384 // Experimental
|
||||||
SHA512 // Experimental
|
SHA512 // Experimental
|
||||||
|
@ -309,7 +309,7 @@ func (rr *RRSIG) Sign(k PrivateKey, rrset []RR) error {
|
||||||
|
|
||||||
// Verify validates an RRSet with the signature and key. This is only the
|
// Verify validates an RRSet with the signature and key. This is only the
|
||||||
// cryptographic test, the signature validity period must be checked separately.
|
// cryptographic test, the signature validity period must be checked separately.
|
||||||
// This function copies the rdata of some RRs (to lowercase domain names) for the validation to work.
|
// This function copies the rdata of some RRs (to lowercase domain names) for the validation to work.
|
||||||
func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error {
|
func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error {
|
||||||
// First the easy checks
|
// First the easy checks
|
||||||
if len(rrset) == 0 {
|
if len(rrset) == 0 {
|
||||||
|
@ -423,7 +423,7 @@ func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error {
|
||||||
return ErrAlg
|
return ErrAlg
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidityPeriod uses RFC1982 serial arithmetic to calculate
|
// ValidityPeriod uses RFC1982 serial arithmetic to calculate
|
||||||
// if a signature period is valid.
|
// if a signature period is valid.
|
||||||
func (rr *RRSIG) ValidityPeriod() bool {
|
func (rr *RRSIG) ValidityPeriod() bool {
|
||||||
utc := time.Now().UTC().Unix()
|
utc := time.Now().UTC().Unix()
|
||||||
|
@ -443,7 +443,7 @@ func (s *RRSIG) sigBuf() []byte {
|
||||||
return sigbuf
|
return sigbuf
|
||||||
}
|
}
|
||||||
|
|
||||||
// setPublicKeyInPrivate sets the public key in the private key.
|
// setPublicKeyInPrivate sets the public key in the private key.
|
||||||
func (k *DNSKEY) setPublicKeyInPrivate(p PrivateKey) bool {
|
func (k *DNSKEY) setPublicKeyInPrivate(p PrivateKey) bool {
|
||||||
switch t := p.(type) {
|
switch t := p.(type) {
|
||||||
case *dsa.PrivateKey:
|
case *dsa.PrivateKey:
|
||||||
|
@ -606,7 +606,7 @@ func exponentToBuf(_E int) []byte {
|
||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the public key for X and Y for Curve. The two
|
// Set the public key for X and Y for Curve. The two
|
||||||
// values are just concatenated.
|
// values are just concatenated.
|
||||||
func curveToBuf(_X, _Y *big.Int) []byte {
|
func curveToBuf(_X, _Y *big.Int) []byte {
|
||||||
buf := _X.Bytes()
|
buf := _X.Bytes()
|
||||||
|
@ -614,7 +614,7 @@ func curveToBuf(_X, _Y *big.Int) []byte {
|
||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the public key for X and Y for Curve. The two
|
// Set the public key for X and Y for Curve. The two
|
||||||
// values are just concatenated.
|
// values are just concatenated.
|
||||||
func dsaToBuf(_Q, _P, _G, _Y *big.Int) []byte {
|
func dsaToBuf(_Q, _P, _G, _Y *big.Int) []byte {
|
||||||
t := byte((len(_G.Bytes()) - 64) / 8)
|
t := byte((len(_G.Bytes()) - 64) / 8)
|
||||||
|
|
|
@ -220,7 +220,7 @@ Coefficient: UuRoNqe7YHnKmQzE6iDWKTMIWTuoqqrFAmXPmKQnC+Y+BQzOVEHUo9bXdDnoI9hzXP1
|
||||||
/*
|
/*
|
||||||
return
|
return
|
||||||
// This key was generate with LDNS:
|
// This key was generate with LDNS:
|
||||||
// ldns-keygen -a RSASHA256 -r /dev/urandom -b 1024 miek.nl
|
// ldns-keygen -a RSASHA256 -r /dev/urandom -b 1024 miek.nl
|
||||||
// Show that we have al the RSA parameters and can check them
|
// Show that we have al the RSA parameters and can check them
|
||||||
// here to see what I came up with
|
// here to see what I came up with
|
||||||
key := new(RR_DNSKEY)
|
key := new(RR_DNSKEY)
|
||||||
|
|
6
edns.go
6
edns.go
|
@ -1,7 +1,7 @@
|
||||||
// EDNS0
|
// EDNS0
|
||||||
//
|
//
|
||||||
// EDNS0 is an extension mechanism for the DNS defined in RFC 2671. It defines a
|
// EDNS0 is an extension mechanism for the DNS defined in RFC 2671. It defines a
|
||||||
// standard RR type, the OPT RR, which is then completely abused.
|
// standard RR type, the OPT RR, which is then completely abused.
|
||||||
// Basic use pattern for creating an (empty) OPT RR:
|
// Basic use pattern for creating an (empty) OPT RR:
|
||||||
//
|
//
|
||||||
// o := new(dns.OPT)
|
// o := new(dns.OPT)
|
||||||
|
@ -296,7 +296,7 @@ func (e *EDNS0_SUBNET) String() (s string) {
|
||||||
// The UPDATE_LEASE EDNS0 (draft RFC) option is used to tell the server to set
|
// The UPDATE_LEASE EDNS0 (draft RFC) option is used to tell the server to set
|
||||||
// an expiration on an update RR. This is helpful for clients that cannot clean
|
// an expiration on an update RR. This is helpful for clients that cannot clean
|
||||||
// up after themselves. This is a draft RFC and more information can be found at
|
// up after themselves. This is a draft RFC and more information can be found at
|
||||||
// http://files.dns-sd.org/draft-sekar-dns-ul.txt
|
// http://files.dns-sd.org/draft-sekar-dns-ul.txt
|
||||||
//
|
//
|
||||||
// o := new(dns.OPT)
|
// o := new(dns.OPT)
|
||||||
// o.Hdr.Name = "."
|
// o.Hdr.Name = "."
|
||||||
|
|
|
@ -17,7 +17,7 @@ const _FORMAT = "Private-key-format: v1.3\n"
|
||||||
type PrivateKey interface{}
|
type PrivateKey interface{}
|
||||||
|
|
||||||
// Generate generates a DNSKEY of the given bit size.
|
// Generate generates a DNSKEY of the given bit size.
|
||||||
// The public part is put inside the DNSKEY record.
|
// The public part is put inside the DNSKEY record.
|
||||||
// The Algorithm in the key must be set as this will define
|
// The Algorithm in the key must be set as this will define
|
||||||
// what kind of DNSKEY will be generated.
|
// what kind of DNSKEY will be generated.
|
||||||
// The ECDSA algorithms imply a fixed keysize, in that case
|
// The ECDSA algorithms imply a fixed keysize, in that case
|
||||||
|
@ -88,7 +88,7 @@ func (r *DNSKEY) Generate(bits int) (PrivateKey, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrivateKeyString converts a PrivateKey to a string. This
|
// PrivateKeyString converts a PrivateKey to a string. This
|
||||||
// string has the same format as the private-key-file of BIND9 (Private-key-format: v1.3).
|
// string has the same format as the private-key-file of BIND9 (Private-key-format: v1.3).
|
||||||
// It needs some info from the key (hashing, keytag), so its a method of the DNSKEY.
|
// It needs some info from the key (hashing, keytag), so its a method of the DNSKEY.
|
||||||
func (r *DNSKEY) PrivateKeyString(p PrivateKey) (s string) {
|
func (r *DNSKEY) PrivateKeyString(p PrivateKey) (s string) {
|
||||||
switch t := p.(type) {
|
switch t := p.(type) {
|
||||||
|
|
4
kscan.go
4
kscan.go
|
@ -10,13 +10,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (k *DNSKEY) NewPrivateKey(s string) (PrivateKey, error) {
|
func (k *DNSKEY) NewPrivateKey(s string) (PrivateKey, error) {
|
||||||
if s[len(s)-1] != '\n' { // We need a closing newline
|
if s[len(s)-1] != '\n' { // We need a closing newline
|
||||||
return k.ReadPrivateKey(strings.NewReader(s+"\n"), "")
|
return k.ReadPrivateKey(strings.NewReader(s+"\n"), "")
|
||||||
}
|
}
|
||||||
return k.ReadPrivateKey(strings.NewReader(s), "")
|
return k.ReadPrivateKey(strings.NewReader(s), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPrivateKey reads a private key from the io.Reader q. The string file is
|
// NewPrivateKey reads a private key from the io.Reader q. The string file is
|
||||||
// only used in error reporting.
|
// only used in error reporting.
|
||||||
// The public key must be
|
// The public key must be
|
||||||
// known, because some cryptographics algorithms embed the public inside the privatekey.
|
// known, because some cryptographics algorithms embed the public inside the privatekey.
|
||||||
|
|
26
msg.go
26
msg.go
|
@ -129,8 +129,8 @@ var TypeToString = map[uint16]string{
|
||||||
TypeL32: "L32",
|
TypeL32: "L32",
|
||||||
TypeL64: "L64",
|
TypeL64: "L64",
|
||||||
TypeLP: "LP",
|
TypeLP: "LP",
|
||||||
TypeEUI48: "EUI48",
|
TypeEUI48: "EUI48",
|
||||||
TypeEUI64: "EUI64",
|
TypeEUI64: "EUI64",
|
||||||
TypeTKEY: "TKEY", // Meta RR
|
TypeTKEY: "TKEY", // Meta RR
|
||||||
TypeTSIG: "TSIG", // Meta RR
|
TypeTSIG: "TSIG", // Meta RR
|
||||||
TypeAXFR: "AXFR", // Meta RR
|
TypeAXFR: "AXFR", // Meta RR
|
||||||
|
@ -183,14 +183,14 @@ var RcodeToString = map[int]string{
|
||||||
RcodeNXRrset: "NXRRSET",
|
RcodeNXRrset: "NXRRSET",
|
||||||
RcodeNotAuth: "NOTAUTH",
|
RcodeNotAuth: "NOTAUTH",
|
||||||
RcodeNotZone: "NOTZONE",
|
RcodeNotZone: "NOTZONE",
|
||||||
RcodeBadSig: "BADSIG", // Also known as RcodeBadVers, see RFC 6891
|
RcodeBadSig: "BADSIG", // Also known as RcodeBadVers, see RFC 6891
|
||||||
// RcodeBadVers: "BADVERS",
|
// RcodeBadVers: "BADVERS",
|
||||||
RcodeBadKey: "BADKEY",
|
RcodeBadKey: "BADKEY",
|
||||||
RcodeBadTime: "BADTIME",
|
RcodeBadTime: "BADTIME",
|
||||||
RcodeBadMode: "BADMODE",
|
RcodeBadMode: "BADMODE",
|
||||||
RcodeBadName: "BADNAME",
|
RcodeBadName: "BADNAME",
|
||||||
RcodeBadAlg: "BADALG",
|
RcodeBadAlg: "BADALG",
|
||||||
RcodeBadTrunc: "BADTRUNC",
|
RcodeBadTrunc: "BADTRUNC",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rather than write the usual handful of routines to pack and
|
// Rather than write the usual handful of routines to pack and
|
||||||
|
@ -639,7 +639,7 @@ func packStructValue(val reflect.Value, msg []byte, off int, compression map[str
|
||||||
copy(msg[off:off+hex.DecodedLen(len(s))], h)
|
copy(msg[off:off+hex.DecodedLen(len(s))], h)
|
||||||
off += hex.DecodedLen(len(s))
|
off += hex.DecodedLen(len(s))
|
||||||
case `dns:"size"`:
|
case `dns:"size"`:
|
||||||
// the size is already encoded in the RR, we can safely use the
|
// the size is already encoded in the RR, we can safely use the
|
||||||
// length of string. String is RAW (not encoded in hex, nor base64)
|
// length of string. String is RAW (not encoded in hex, nor base64)
|
||||||
copy(msg[off:off+len(s)], s)
|
copy(msg[off:off+len(s)], s)
|
||||||
off += len(s)
|
off += len(s)
|
||||||
|
@ -1369,10 +1369,10 @@ func (dns *Msg) String() string {
|
||||||
|
|
||||||
// Len return the message length when in (un)compressed wire format.
|
// Len return the message length when in (un)compressed wire format.
|
||||||
// If dns.Compress is true compression it is taken into account, currently
|
// If dns.Compress is true compression it is taken into account, currently
|
||||||
// this only counts owner name compression. There is no check for
|
// this only counts owner name compression. There is no check for
|
||||||
// nil valued sections (allocated, but contain no RRs).
|
// nil valued sections (allocated, but contain no RRs).
|
||||||
func (dns *Msg) Len() int {
|
func (dns *Msg) Len() int {
|
||||||
// Message header is always 12 bytes
|
// Message header is always 12 bytes
|
||||||
l := 12
|
l := 12
|
||||||
var compression map[string]int
|
var compression map[string]int
|
||||||
if dns.Compress {
|
if dns.Compress {
|
||||||
|
|
|
@ -194,7 +194,7 @@ func (mux *ServeMux) match(q string, t uint16) Handler {
|
||||||
}
|
}
|
||||||
lastbyte = q[i]
|
lastbyte = q[i]
|
||||||
}
|
}
|
||||||
// Check for the root zone too, this only delays NXDOMAIN, because if we serve . it
|
// Check for the root zone too, this only delays NXDOMAIN, because if we serve . it
|
||||||
// will be catched above.
|
// will be catched above.
|
||||||
if h, ok := mux.z["."]; ok {
|
if h, ok := mux.z["."]; ok {
|
||||||
return h
|
return h
|
||||||
|
|
2
tlsa.go
2
tlsa.go
|
@ -62,7 +62,7 @@ func (r *TLSA) Sign(usage, selector, matchingType int, cert *x509.Certificate) (
|
||||||
func (r *TLSA) Verify(cert *x509.Certificate) error {
|
func (r *TLSA) Verify(cert *x509.Certificate) error {
|
||||||
c, err := CertificateToDANE(r.Selector, r.MatchingType, cert)
|
c, err := CertificateToDANE(r.Selector, r.MatchingType, cert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err // Not also ErrSig?
|
return err // Not also ErrSig?
|
||||||
}
|
}
|
||||||
if r.Certificate == c {
|
if r.Certificate == c {
|
||||||
return nil
|
return nil
|
||||||
|
|
12
tsig.go
12
tsig.go
|
@ -1,10 +1,10 @@
|
||||||
// TRANSACTION SIGNATURE (TSIG)
|
// TRANSACTION SIGNATURE (TSIG)
|
||||||
//
|
//
|
||||||
// An TSIG or transaction signature adds a HMAC TSIG record to each message sent.
|
// An TSIG or transaction signature adds a HMAC TSIG record to each message sent.
|
||||||
// The supported algorithms include: HmacMD5, HmacSHA1 and HmacSHA256.
|
// The supported algorithms include: HmacMD5, HmacSHA1 and HmacSHA256.
|
||||||
//
|
//
|
||||||
// Basic use pattern when querying with a TSIG name "axfr." (note that these key names
|
// Basic use pattern when querying with a TSIG name "axfr." (note that these key names
|
||||||
// must be fully qualified - as they are domain names) and the base64 secret
|
// must be fully qualified - as they are domain names) and the base64 secret
|
||||||
// "so6ZGir4GPAqINNh9U5c3A==":
|
// "so6ZGir4GPAqINNh9U5c3A==":
|
||||||
//
|
//
|
||||||
// c := new(dns.Client)
|
// c := new(dns.Client)
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
// c := new(dns.Client)
|
// c := new(dns.Client)
|
||||||
// c.TsigSecret = map[string]string{"axfr.": "so6ZGir4GPAqINNh9U5c3A=="}
|
// c.TsigSecret = map[string]string{"axfr.": "so6ZGir4GPAqINNh9U5c3A=="}
|
||||||
// m := new(dns.Msg)
|
// m := new(dns.Msg)
|
||||||
// m.SetAxfr("miek.nl.")
|
// m.SetAxfr("miek.nl.")
|
||||||
// m.SetTsig("axfr.", dns.HmacMD5, 300, time.Now().Unix())
|
// m.SetTsig("axfr.", dns.HmacMD5, 300, time.Now().Unix())
|
||||||
// t, err := c.TransferIn(m, "85.223.71.124:53")
|
// t, err := c.TransferIn(m, "85.223.71.124:53")
|
||||||
// for r := range t { /* ... */ }
|
// for r := range t { /* ... */ }
|
||||||
|
@ -148,12 +148,12 @@ type timerWireFmt struct {
|
||||||
|
|
||||||
// TsigGenerate fills out the TSIG record attached to the message.
|
// TsigGenerate fills out the TSIG record attached to the message.
|
||||||
// The message should contain
|
// The message should contain
|
||||||
// a "stub" TSIG RR with the algorithm, key name (owner name of the RR),
|
// a "stub" TSIG RR with the algorithm, key name (owner name of the RR),
|
||||||
// time fudge (defaults to 300 seconds) and the current time
|
// time fudge (defaults to 300 seconds) and the current time
|
||||||
// The TSIG MAC is saved in that Tsig RR.
|
// The TSIG MAC is saved in that Tsig RR.
|
||||||
// When TsigGenerate is called for the first time requestMAC is set to the empty string and
|
// When TsigGenerate is called for the first time requestMAC is set to the empty string and
|
||||||
// timersOnly is false.
|
// timersOnly is false.
|
||||||
// If something goes wrong an error is returned, otherwise it is nil.
|
// If something goes wrong an error is returned, otherwise it is nil.
|
||||||
func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) ([]byte, string, error) {
|
func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) ([]byte, string, error) {
|
||||||
if m.IsTsig() == nil {
|
if m.IsTsig() == nil {
|
||||||
panic("dns: TSIG not last RR in additional")
|
panic("dns: TSIG not last RR in additional")
|
||||||
|
@ -205,7 +205,7 @@ func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) ([]byte, s
|
||||||
return mbuf, t.MAC, nil
|
return mbuf, t.MAC, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TsigVerify verifies the TSIG on a message.
|
// TsigVerify verifies the TSIG on a message.
|
||||||
// If the signature does not validate err contains the
|
// If the signature does not validate err contains the
|
||||||
// error, otherwise it is nil.
|
// error, otherwise it is nil.
|
||||||
func TsigVerify(msg []byte, secret, requestMAC string, timersOnly bool) error {
|
func TsigVerify(msg []byte, secret, requestMAC string, timersOnly bool) error {
|
||||||
|
|
10
update.go
10
update.go
|
@ -1,12 +1,12 @@
|
||||||
// DYNAMIC UPDATES
|
// DYNAMIC UPDATES
|
||||||
//
|
//
|
||||||
// Dynamic updates reuses the DNS message format, but renames three of
|
// Dynamic updates reuses the DNS message format, but renames three of
|
||||||
// the sections. Question is Zone, Answer is Prerequisite, Authority is
|
// the sections. Question is Zone, Answer is Prerequisite, Authority is
|
||||||
// Update, only the Additional is not renamed. See RFC 2136 for the gory details.
|
// Update, only the Additional is not renamed. See RFC 2136 for the gory details.
|
||||||
//
|
//
|
||||||
// You can set a rather complex set of rules for the existence of absence of
|
// You can set a rather complex set of rules for the existence of absence of
|
||||||
// certain resource records or names in a zone to specify if resource records
|
// certain resource records or names in a zone to specify if resource records
|
||||||
// should be added or removed. The table from RFC 2136 supplemented with the Go
|
// should be added or removed. The table from RFC 2136 supplemented with the Go
|
||||||
// DNS function shows which functions exist to specify the prerequisites.
|
// DNS function shows which functions exist to specify the prerequisites.
|
||||||
//
|
//
|
||||||
// 3.2.4 - Table Of Metavalues Used In Prerequisite Section
|
// 3.2.4 - Table Of Metavalues Used In Prerequisite Section
|
||||||
|
@ -18,21 +18,21 @@
|
||||||
// NONE ANY empty Name is not in use NameNotUsed
|
// NONE ANY empty Name is not in use NameNotUsed
|
||||||
// NONE rrset empty RRset does not exist RRsetNotUsed
|
// NONE rrset empty RRset does not exist RRsetNotUsed
|
||||||
// zone rrset rr RRset exists (value dep) Used
|
// zone rrset rr RRset exists (value dep) Used
|
||||||
//
|
//
|
||||||
// The prerequisite section can also be left empty.
|
// The prerequisite section can also be left empty.
|
||||||
// If you have decided on the prerequisites you can tell what RRs should
|
// If you have decided on the prerequisites you can tell what RRs should
|
||||||
// be added or deleted. The next table shows the options you have and
|
// be added or deleted. The next table shows the options you have and
|
||||||
// what functions to call.
|
// what functions to call.
|
||||||
//
|
//
|
||||||
// 3.4.2.6 - Table Of Metavalues Used In Update Section
|
// 3.4.2.6 - Table Of Metavalues Used In Update Section
|
||||||
//
|
//
|
||||||
// CLASS TYPE RDATA Meaning Function
|
// CLASS TYPE RDATA Meaning Function
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// ANY ANY empty Delete all RRsets from name RemoveName
|
// ANY ANY empty Delete all RRsets from name RemoveName
|
||||||
// ANY rrset empty Delete an RRset RemoveRRset
|
// ANY rrset empty Delete an RRset RemoveRRset
|
||||||
// NONE rrset rr Delete an RR from RRset Remove
|
// NONE rrset rr Delete an RR from RRset Remove
|
||||||
// zone rrset rr Add to an RRset Insert
|
// zone rrset rr Add to an RRset Insert
|
||||||
//
|
//
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
// NameUsed sets the RRs in the prereq section to
|
// NameUsed sets the RRs in the prereq section to
|
||||||
|
|
4
xfr.go
4
xfr.go
|
@ -127,7 +127,7 @@ func (w *reply) ixfrIn(q *Msg, c chan *Envelope) {
|
||||||
panic("dns: not reached")
|
panic("dns: not reached")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if he SOA record exists in the Answer section of
|
// Check if he SOA record exists in the Answer section of
|
||||||
// the packet. If first is true the first RR must be a SOA
|
// the packet. If first is true the first RR must be a SOA
|
||||||
// if false, the last one should be a SOA.
|
// if false, the last one should be a SOA.
|
||||||
func checkXfrSOA(in *Msg, first bool) bool {
|
func checkXfrSOA(in *Msg, first bool) bool {
|
||||||
|
@ -147,7 +147,7 @@ func checkXfrSOA(in *Msg, first bool) bool {
|
||||||
// Errors are signaled via the error pointer, when an error occurs the function
|
// Errors are signaled via the error pointer, when an error occurs the function
|
||||||
// sets the error and returns (it does not close the channel).
|
// sets the error and returns (it does not close the channel).
|
||||||
// TSIG and enveloping is handled by TransferOut.
|
// TSIG and enveloping is handled by TransferOut.
|
||||||
//
|
//
|
||||||
// Basic use pattern for sending an AXFR:
|
// Basic use pattern for sending an AXFR:
|
||||||
//
|
//
|
||||||
// // q contains the AXFR request
|
// // q contains the AXFR request
|
||||||
|
|
20
zscan.go
20
zscan.go
|
@ -84,7 +84,7 @@ func (e *ParseError) Error() (s string) {
|
||||||
|
|
||||||
type lex struct {
|
type lex struct {
|
||||||
token string // text of the token
|
token string // text of the token
|
||||||
err bool // when true, token text has lexer error
|
err bool // when true, token text has lexer error
|
||||||
value uint8 // value: _STRING, _BLANK, etc.
|
value uint8 // value: _STRING, _BLANK, etc.
|
||||||
line int // line in the file
|
line int // line in the file
|
||||||
column int // column in the file
|
column int // column in the file
|
||||||
|
@ -119,15 +119,15 @@ func ReadRR(q io.Reader, filename string) (RR, error) {
|
||||||
return r.RR, nil
|
return r.RR, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseZone reads a RFC 1035 style one from r. It returns Tokens on the
|
// ParseZone reads a RFC 1035 style one from r. It returns Tokens on the
|
||||||
// returned channel, which consist out the parsed RR, a potential comment or an error.
|
// returned channel, which consist out the parsed RR, a potential comment or an error.
|
||||||
// If there is an error the RR is nil. The string file is only used
|
// If there is an error the RR is nil. The string file is only used
|
||||||
// in error reporting. The string origin is used as the initial origin, as
|
// in error reporting. The string origin is used as the initial origin, as
|
||||||
// if the file would start with: $ORIGIN origin .
|
// if the file would start with: $ORIGIN origin .
|
||||||
// The directives $INCLUDE, $ORIGIN, $TTL and $GENERATE are supported.
|
// The directives $INCLUDE, $ORIGIN, $TTL and $GENERATE are supported.
|
||||||
// The channel t is closed by ParseZone when the end of r is reached.
|
// The channel t is closed by ParseZone when the end of r is reached.
|
||||||
//
|
//
|
||||||
// Basic usage pattern when reading from a string (z) containing the
|
// Basic usage pattern when reading from a string (z) containing the
|
||||||
// zone data:
|
// zone data:
|
||||||
//
|
//
|
||||||
// for x := range dns.ParseZone(strings.NewReader(z), "", "") {
|
// for x := range dns.ParseZone(strings.NewReader(z), "", "") {
|
||||||
|
@ -137,10 +137,10 @@ func ReadRR(q io.Reader, filename string) (RR, error) {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Comments specified after an RR (and on the same line!) are returned too:
|
// Comments specified after an RR (and on the same line!) are returned too:
|
||||||
//
|
//
|
||||||
// foo. IN A 10.0.0.1 ; this is a comment
|
// foo. IN A 10.0.0.1 ; this is a comment
|
||||||
//
|
//
|
||||||
// The text "; this is comment" is returned in Token.comment . Comments inside the
|
// The text "; this is comment" is returned in Token.comment . Comments inside the
|
||||||
// RR are discarded. Comments on a line by themselves are discarded too.
|
// RR are discarded. Comments on a line by themselves are discarded too.
|
||||||
func ParseZone(r io.Reader, origin, file string) chan Token {
|
func ParseZone(r io.Reader, origin, file string) chan Token {
|
||||||
return parseZoneHelper(r, origin, file, 10000)
|
return parseZoneHelper(r, origin, file, 10000)
|
||||||
|
@ -776,7 +776,7 @@ func classToInt(token string) (uint16, bool) {
|
||||||
return uint16(class), true
|
return uint16(class), true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the rr number from TYPExxx
|
// Extract the rr number from TYPExxx
|
||||||
func typeToInt(token string) (uint16, bool) {
|
func typeToInt(token string) (uint16, bool) {
|
||||||
typ, ok := strconv.Atoi(token[4:])
|
typ, ok := strconv.Atoi(token[4:])
|
||||||
if ok != nil {
|
if ok != nil {
|
||||||
|
@ -816,7 +816,7 @@ func stringToTtl(token string) (uint32, bool) {
|
||||||
return s + i, true
|
return s + i, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse LOC records' <digits>[.<digits>][mM] into a
|
// Parse LOC records' <digits>[.<digits>][mM] into a
|
||||||
// mantissa exponent format. Token should contain the entire
|
// mantissa exponent format. Token should contain the entire
|
||||||
// string (i.e. no spaces allowed)
|
// string (i.e. no spaces allowed)
|
||||||
func stringToCm(token string) (e, m uint8, ok bool) {
|
func stringToCm(token string) (e, m uint8, ok bool) {
|
||||||
|
@ -866,7 +866,7 @@ func appendOrigin(name, origin string) string {
|
||||||
return name + "." + origin
|
return name + "." + origin
|
||||||
}
|
}
|
||||||
|
|
||||||
// LOC record helper function
|
// LOC record helper function
|
||||||
func locCheckNorth(token string, latitude uint32) (uint32, bool) {
|
func locCheckNorth(token string, latitude uint32) (uint32, bool) {
|
||||||
switch token {
|
switch token {
|
||||||
case "n", "N":
|
case "n", "N":
|
||||||
|
@ -877,7 +877,7 @@ func locCheckNorth(token string, latitude uint32) (uint32, bool) {
|
||||||
return latitude, false
|
return latitude, false
|
||||||
}
|
}
|
||||||
|
|
||||||
// LOC record helper function
|
// LOC record helper function
|
||||||
func locCheckEast(token string, longitude uint32) (uint32, bool) {
|
func locCheckEast(token string, longitude uint32) (uint32, bool) {
|
||||||
switch token {
|
switch token {
|
||||||
case "e", "E":
|
case "e", "E":
|
||||||
|
|
Loading…
Reference in New Issue