mirror of
https://github.com/miekg/dns.git
synced 2025-10-13 19:01:01 +02:00
Merge branch 'master' of github.com:miekg/dns
This commit is contained in:
commit
2bc1cd1a2e
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
*.6
|
*.6
|
||||||
|
tags
|
||||||
test.out
|
test.out
|
||||||
a.out
|
a.out
|
||||||
|
@ -9,3 +9,4 @@
|
|||||||
moderate hardware
|
moderate hardware
|
||||||
* privatekey.Precompute() when signing?
|
* privatekey.Precompute() when signing?
|
||||||
* Last remaining RRs: APL, NIMLOC & EID, ATMA, A6, KEY, SIG and NXT
|
* Last remaining RRs: APL, NIMLOC & EID, ATMA, A6, KEY, SIG and NXT
|
||||||
|
* CAA parsing is broken
|
||||||
|
@ -223,18 +223,14 @@ func ReverseAddr(addr string) (arpa string, err error) {
|
|||||||
func (t Type) String() string {
|
func (t Type) String() string {
|
||||||
if t1, ok := TypeToString[uint16(t)]; ok {
|
if t1, ok := TypeToString[uint16(t)]; ok {
|
||||||
return t1
|
return t1
|
||||||
} else {
|
|
||||||
return "TYPE" + strconv.Itoa(int(t))
|
|
||||||
}
|
}
|
||||||
panic("dns: not reached") // go < 1.1 compat
|
return "TYPE" + strconv.Itoa(int(t))
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the string representation for the class c
|
// String returns the string representation for the class c
|
||||||
func (c Class) String() string {
|
func (c Class) String() string {
|
||||||
if c1, ok := ClassToString[uint16(c)]; ok {
|
if c1, ok := ClassToString[uint16(c)]; ok {
|
||||||
return c1
|
return c1
|
||||||
} else {
|
|
||||||
return "CLASS" + strconv.Itoa(int(c))
|
|
||||||
}
|
}
|
||||||
panic("dns: not reached")
|
return "CLASS" + strconv.Itoa(int(c))
|
||||||
}
|
}
|
||||||
|
7
dns.go
7
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 zone transfers,
|
||||||
// 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.
|
||||||
@ -61,7 +61,7 @@
|
|||||||
// c := new(Client)
|
// c := new(Client)
|
||||||
// in, rtt, err := c.Exchange(m1, "127.0.0.1:53")
|
// in, rtt, err := c.Exchange(m1, "127.0.0.1:53")
|
||||||
//
|
//
|
||||||
// For asynchronous queries it is easy to wrap Exchange() in a goroutine. Suppressing
|
// Suppressing
|
||||||
// multiple outstanding queries (with the same question, type and class) is as easy as setting:
|
// multiple outstanding queries (with the same question, type and class) is as easy as setting:
|
||||||
//
|
//
|
||||||
// c.SingleInflight = true
|
// c.SingleInflight = true
|
||||||
@ -71,7 +71,8 @@
|
|||||||
//
|
//
|
||||||
// in, err := dns.Exchange(m1, "127.0.0.1:53")
|
// in, err := dns.Exchange(m1, "127.0.0.1:53")
|
||||||
//
|
//
|
||||||
// A dns message consists out of four sections.
|
// When this functions returns you will get dns message. A dns message consists
|
||||||
|
// out of four sections.
|
||||||
// The question section: in.Question, the answer section: in.Answer,
|
// The question section: in.Question, the answer section: in.Answer,
|
||||||
// the authority section: in.Ns and the additional section: in.Extra.
|
// the authority section: in.Ns and the additional section: in.Extra.
|
||||||
//
|
//
|
||||||
|
65
edns.go
65
edns.go
@ -5,7 +5,7 @@
|
|||||||
// EDNS0
|
// EDNS0
|
||||||
//
|
//
|
||||||
// EDNS0 is an extension mechanism for the DNS defined in RFC 2671 and updated
|
// EDNS0 is an extension mechanism for the DNS defined in RFC 2671 and updated
|
||||||
// by RFC 6891. It defines a standard RR type, the OPT RR, which is then completely
|
// by RFC 6891. It defines an new RR type, the OPT RR, which is then completely
|
||||||
// abused.
|
// abused.
|
||||||
// Basic use pattern for creating an (empty) OPT RR:
|
// Basic use pattern for creating an (empty) OPT RR:
|
||||||
//
|
//
|
||||||
@ -150,10 +150,7 @@ func (rr *OPT) SetDo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EDNS0 defines an EDNS0 Option. An OPT RR can have multiple options appended to
|
// EDNS0 defines an EDNS0 Option. An OPT RR can have multiple options appended to
|
||||||
// it. Basic use pattern for adding an option to and OPT RR:
|
// it.
|
||||||
//
|
|
||||||
// // o is the OPT RR, e is the EDNS0 option
|
|
||||||
// o.Option = append(o.Option, e)
|
|
||||||
type EDNS0 interface {
|
type EDNS0 interface {
|
||||||
// Option returns the option code for the option.
|
// Option returns the option code for the option.
|
||||||
Option() uint16
|
Option() uint16
|
||||||
@ -166,8 +163,8 @@ type EDNS0 interface {
|
|||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
// The nsid EDNS0 option is used to retrieve some sort of nameserver
|
// The nsid EDNS0 option is used to retrieve a nameserver
|
||||||
// identifier. When seding a request Nsid must be set to the empty string
|
// identifier. When sending a request Nsid must be set to the empty string
|
||||||
// The identifier is an opaque string encoded as hex.
|
// The identifier is an opaque string encoded as hex.
|
||||||
// Basic use pattern for creating an nsid option:
|
// Basic use pattern for creating an nsid option:
|
||||||
//
|
//
|
||||||
@ -182,10 +179,6 @@ type EDNS0_NSID struct {
|
|||||||
Nsid string // This string needs to be hex encoded
|
Nsid string // This string needs to be hex encoded
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EDNS0_NSID) Option() uint16 {
|
|
||||||
return EDNS0NSID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EDNS0_NSID) pack() ([]byte, error) {
|
func (e *EDNS0_NSID) pack() ([]byte, error) {
|
||||||
h, err := hex.DecodeString(e.Nsid)
|
h, err := hex.DecodeString(e.Nsid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -194,13 +187,9 @@ func (e *EDNS0_NSID) pack() ([]byte, error) {
|
|||||||
return h, nil
|
return h, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EDNS0_NSID) unpack(b []byte) {
|
func (e *EDNS0_NSID) Option() uint16 { return EDNS0NSID }
|
||||||
e.Nsid = hex.EncodeToString(b)
|
func (e *EDNS0_NSID) unpack(b []byte) { e.Nsid = hex.EncodeToString(b) }
|
||||||
}
|
func (e *EDNS0_NSID) String() string { return string(e.Nsid) }
|
||||||
|
|
||||||
func (e *EDNS0_NSID) String() string {
|
|
||||||
return string(e.Nsid)
|
|
||||||
}
|
|
||||||
|
|
||||||
// The subnet EDNS0 option is used to give the remote nameserver
|
// The subnet EDNS0 option is used to give the remote nameserver
|
||||||
// an idea of where the client lives. It can then give back a different
|
// an idea of where the client lives. It can then give back a different
|
||||||
@ -344,10 +333,6 @@ type EDNS0_UL struct {
|
|||||||
Lease uint32
|
Lease uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EDNS0_UL) Option() uint16 {
|
|
||||||
return EDNS0UL
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copied: http://golang.org/src/pkg/net/dnsmsg.go
|
// Copied: http://golang.org/src/pkg/net/dnsmsg.go
|
||||||
func (e *EDNS0_UL) pack() ([]byte, error) {
|
func (e *EDNS0_UL) pack() ([]byte, error) {
|
||||||
b := make([]byte, 4)
|
b := make([]byte, 4)
|
||||||
@ -358,13 +343,11 @@ func (e *EDNS0_UL) pack() ([]byte, error) {
|
|||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *EDNS0_UL) Option() uint16 { return EDNS0UL }
|
||||||
func (e *EDNS0_UL) unpack(b []byte) {
|
func (e *EDNS0_UL) unpack(b []byte) {
|
||||||
e.Lease = uint32(b[0])<<24 | uint32(b[1])<<16 | uint32(b[2])<<8 | uint32(b[3])
|
e.Lease = uint32(b[0])<<24 | uint32(b[1])<<16 | uint32(b[2])<<8 | uint32(b[3])
|
||||||
}
|
}
|
||||||
|
func (e *EDNS0_UL) String() string { return strconv.FormatUint(uint64(e.Lease), 10) }
|
||||||
func (e *EDNS0_UL) String() string {
|
|
||||||
return strconv.FormatUint(uint64(e.Lease), 10)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Long Lived Queries: http://tools.ietf.org/html/draft-sekar-dns-llq-01
|
// Long Lived Queries: http://tools.ietf.org/html/draft-sekar-dns-llq-01
|
||||||
// Implemented for completeness, as the EDNS0 type code is assigned.
|
// Implemented for completeness, as the EDNS0 type code is assigned.
|
||||||
@ -377,9 +360,7 @@ type EDNS0_LLQ struct {
|
|||||||
LeaseLife uint32
|
LeaseLife uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EDNS0_LLQ) Option() uint16 {
|
func (e *EDNS0_LLQ) Option() uint16 { return EDNS0LLQ }
|
||||||
return EDNS0LLQ
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EDNS0_LLQ) pack() ([]byte, error) {
|
func (e *EDNS0_LLQ) pack() ([]byte, error) {
|
||||||
b := make([]byte, 18)
|
b := make([]byte, 18)
|
||||||
@ -450,16 +431,9 @@ type EDNS0_DHU struct {
|
|||||||
AlgCode []uint8
|
AlgCode []uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EDNS0_DHU) Option() uint16 {
|
func (e *EDNS0_DHU) Option() uint16 { return EDNS0DHU }
|
||||||
return EDNS0DHU
|
func (e *EDNS0_DHU) pack() ([]byte, error) { return e.AlgCode, nil }
|
||||||
}
|
func (e *EDNS0_DHU) unpack(b []byte) { e.AlgCode = b }
|
||||||
func (e *EDNS0_DHU) pack() ([]byte, error) {
|
|
||||||
return e.AlgCode, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EDNS0_DHU) unpack(b []byte) {
|
|
||||||
e.AlgCode = b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EDNS0_DHU) String() string {
|
func (e *EDNS0_DHU) String() string {
|
||||||
s := ""
|
s := ""
|
||||||
@ -478,16 +452,9 @@ type EDNS0_N3U struct {
|
|||||||
AlgCode []uint8
|
AlgCode []uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EDNS0_N3U) Option() uint16 {
|
func (e *EDNS0_N3U) Option() uint16 { return EDNS0N3U }
|
||||||
return EDNS0N3U
|
func (e *EDNS0_N3U) pack() ([]byte, error) { return e.AlgCode, nil }
|
||||||
}
|
func (e *EDNS0_N3U) unpack(b []byte) { e.AlgCode = b }
|
||||||
func (e *EDNS0_N3U) pack() ([]byte, error) {
|
|
||||||
return e.AlgCode, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EDNS0_N3U) unpack(b []byte) {
|
|
||||||
e.AlgCode = b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *EDNS0_N3U) String() string {
|
func (e *EDNS0_N3U) String() string {
|
||||||
// Re-use the hash map
|
// Re-use the hash map
|
||||||
|
7
kscan.go
7
kscan.go
@ -161,9 +161,7 @@ func readPrivateKeyECDSA(m map[string]string) (PrivateKey, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readPrivateKeyGOST(m map[string]string) (PrivateKey, error) {
|
func readPrivateKeyGOST(m map[string]string) (PrivateKey, error) {
|
||||||
// p := new(ecdsa.PrivateKey)
|
/* TODO(miek)
|
||||||
// p.D = big.NewInt(0)
|
|
||||||
// Need to check if we have everything
|
|
||||||
for k, v := range m {
|
for k, v := range m {
|
||||||
switch k {
|
switch k {
|
||||||
case "gostasn1:":
|
case "gostasn1:":
|
||||||
@ -174,9 +172,10 @@ func readPrivateKeyGOST(m map[string]string) (PrivateKey, error) {
|
|||||||
v1 = v1
|
v1 = v1
|
||||||
//p.D.SetBytes(v1)
|
//p.D.SetBytes(v1)
|
||||||
case "created:", "publish:", "activate:":
|
case "created:", "publish:", "activate:":
|
||||||
/* not used in Go (yet) */
|
// not used in Go (yet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,8 +156,6 @@ func modToPrintf(s string) (string, int, string) {
|
|||||||
return "", offset, "bad width in $GENERATE"
|
return "", offset, "bad width in $GENERATE"
|
||||||
case width == 0:
|
case width == 0:
|
||||||
return "%" + xs[1] + xs[2], offset, ""
|
return "%" + xs[1] + xs[2], offset, ""
|
||||||
default:
|
|
||||||
return "%0" + xs[1] + xs[2], offset, ""
|
|
||||||
}
|
}
|
||||||
panic("dns: not reached")
|
return "%0" + xs[1] + xs[2], offset, ""
|
||||||
}
|
}
|
||||||
|
@ -2040,4 +2040,3 @@ func setPX(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
|||||||
}
|
}
|
||||||
return rr, nil
|
return rr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user