EDNS impl.
Needs more work, especially in the handling of the RR.Hdr which is diff. for EDNS rrs
This commit is contained in:
parent
63c4d10ed0
commit
e650aae18b
1
Makefile
1
Makefile
|
@ -10,6 +10,7 @@ GOFILES=\
|
|||
msg.go\
|
||||
resolver.go \
|
||||
types.go\
|
||||
edns.go \
|
||||
|
||||
include $(GOROOT)/src/Make.pkg
|
||||
|
||||
|
|
11
edns
11
edns
|
@ -1,11 +0,0 @@
|
|||
EDNS
|
||||
|
||||
edns is just an rr in the additional section. So define it like that.
|
||||
However you can set all kind of stuff in the RR, which are not allowed
|
||||
for other RR's.
|
||||
|
||||
Create some helper function that use it. udp size, stuff like that
|
||||
version is always 0
|
||||
|
||||
set_nsid rfc
|
||||
set_do rfc3225.txt
|
|
@ -0,0 +1,51 @@
|
|||
package dns
|
||||
|
||||
// This is the base layer for ENDS, in practise
|
||||
// You'll only need to set updsize, do bit
|
||||
|
||||
|
||||
const (
|
||||
OptionCodeLLQ = 1
|
||||
OptionCodeUL = 2
|
||||
OptionCodeNSID = 3
|
||||
// EDNS flag bits (put in Z section)
|
||||
_DO = 1 << 15 // dnssec ok
|
||||
)
|
||||
|
||||
// Need PackOption I guess?? TODO
|
||||
type Edns0Option struct {
|
||||
Code uint16
|
||||
// Length uint16
|
||||
Data string "hex" // len(data) is must be encode in packet
|
||||
}
|
||||
|
||||
// EDNS extended RR.
|
||||
type EDNS0_Header struct {
|
||||
Name string "extended-name"
|
||||
Opt uint16 // was type
|
||||
UDPSize uint16 // was class
|
||||
ExtendedRcode uint8 // was TTL
|
||||
Version uint8 // was TTL
|
||||
Z uint16 // was TTL (all flags should be put here
|
||||
Rdlength uint16 // length of data after the header
|
||||
}
|
||||
|
||||
type RR_EDNS0 struct {
|
||||
Hdr RR_Header // this must become a EDNS0_Header
|
||||
Option []Edns0Option
|
||||
}
|
||||
|
||||
func (rr *RR_EDNS0) Header() *RR_Header {
|
||||
return &rr.Hdr
|
||||
}
|
||||
|
||||
func (rr *RR_EDNS0) String() string {
|
||||
var s string
|
||||
for _, o := range rr.Option {
|
||||
switch o.Code {
|
||||
case OptionCodeNSID:
|
||||
s += "NSID: " + o.Data
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
34
types.go
34
types.go
|
@ -69,10 +69,6 @@ const (
|
|||
RcodeNameError = 3
|
||||
RcodeNotImplemented = 4
|
||||
RcodeRefused = 5
|
||||
|
||||
// Edns0 options
|
||||
EdnsNsidCode = 3
|
||||
EdnsNsidLength = 1
|
||||
)
|
||||
|
||||
// The wire format for the DNS packet header.
|
||||
|
@ -92,8 +88,6 @@ const (
|
|||
_Z = 1 << 6 // Z
|
||||
_AD = 1 << 5 // authticated data
|
||||
_CD = 1 << 4 // checking disabled
|
||||
// EDNS flag bits
|
||||
_DO = 1 << 15 // dnssec ok
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -123,21 +117,6 @@ func (q *Question) String() string {
|
|||
return s
|
||||
}
|
||||
|
||||
/*
|
||||
// EDNS extended RR.
|
||||
type EDNS0_Header struct {
|
||||
Name string "extended-name"
|
||||
Opt uint16 // was type
|
||||
UDPSize uint16 // was class
|
||||
ExtendedRcode uint8 // was TTL
|
||||
Version uint8 // was TTL
|
||||
// Flags uint16 // was TTL
|
||||
Dnssec_ok bool
|
||||
Rdlength uint16
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// DNS responses (resource records).
|
||||
// There are many types of messages,
|
||||
// but they all share the same header.
|
||||
|
@ -179,19 +158,6 @@ type RR interface {
|
|||
String() string
|
||||
}
|
||||
|
||||
type RR_EDNS0 struct {
|
||||
Hdr RR_Header "edns"
|
||||
// Option []Edns "edns" TODO
|
||||
}
|
||||
|
||||
func (rr *RR_EDNS0) Header() *RR_Header {
|
||||
return &rr.Hdr
|
||||
}
|
||||
|
||||
func (rr *RR_EDNS0) String() string {
|
||||
return "BOE"
|
||||
}
|
||||
|
||||
type RR_CNAME struct {
|
||||
Hdr RR_Header
|
||||
Cname string "domain-name"
|
||||
|
|
Loading…
Reference in New Issue