aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--middleware/proxy/lookup.go6
-rw-r--r--middleware/proxy/reverseproxy.go1
-rw-r--r--middleware/state.go54
3 files changed, 31 insertions, 30 deletions
diff --git a/middleware/proxy/lookup.go b/middleware/proxy/lookup.go
index 599ecf12a..564b662c5 100644
--- a/middleware/proxy/lookup.go
+++ b/middleware/proxy/lookup.go
@@ -55,8 +55,10 @@ func New(hosts []string) Proxy {
func (p Proxy) Lookup(state middleware.State, name string, tpe uint16) (*dns.Msg, error) {
req := new(dns.Msg)
req.SetQuestion(name, tpe)
- // TODO(miek):
- // USE STATE FOR DNSSEC ETCD BUFSIZE BLA BLA
+
+ opt := state.SizeAndDo()
+ req.Extra = []dns.RR{opt}
+
return p.lookup(state, req)
}
diff --git a/middleware/proxy/reverseproxy.go b/middleware/proxy/reverseproxy.go
index 460b294a8..efe6f47d2 100644
--- a/middleware/proxy/reverseproxy.go
+++ b/middleware/proxy/reverseproxy.go
@@ -12,7 +12,6 @@ type ReverseProxy struct {
}
func (p ReverseProxy) ServeDNS(w dns.ResponseWriter, r *dns.Msg, extra []dns.RR) error {
- // TODO(miek): use extra to EDNS0.
var (
reply *dns.Msg
err error
diff --git a/middleware/state.go b/middleware/state.go
index fa8ef74a9..f4cd43542 100644
--- a/middleware/state.go
+++ b/middleware/state.go
@@ -19,17 +19,12 @@ type State struct {
}
// Now returns the current timestamp in the specified format.
-func (s State) Now(format string) string {
- return time.Now().Format(format)
-}
+func (s State) Now(format string) string { return time.Now().Format(format) }
-// NowDate returns the current date/time that can be used
-// in other time functions.
-func (s State) NowDate() time.Time {
- return time.Now()
-}
+// NowDate returns the current date/time that can be used in other time functions.
+func (s State) NowDate() time.Time { return time.Now() }
-// Header gets the value of a header.
+// Header gets the heaser of the request in State.
func (s State) Header() *dns.RR_Header {
// TODO(miek)
return nil
@@ -107,36 +102,41 @@ func (s State) Size() int {
return dns.MinMsgSize
}
-// Type returns the type of the question as a string.
-func (s State) Type() string {
- return dns.Type(s.Req.Question[0].Qtype).String()
+// SizeAndDo returns a ready made OPT record that the reflects the intent
+// from the state. This can be added to upstream requests that will then
+// hopefully return a message that is understandable by the original client.
+func (s State) SizeAndDo() *dns.OPT {
+ size := s.Size()
+ Do := s.Do()
+
+ o := new(dns.OPT)
+ o.Hdr.Name = "."
+ o.Hdr.Rrtype = dns.TypeOPT
+ o.SetUDPSize(uint16(size))
+ if Do {
+ o.SetDo()
+ }
+ return o
}
+// Type returns the type of the question as a string.
+func (s State) Type() string { return dns.Type(s.Req.Question[0].Qtype).String() }
+
// QType returns the type of the question as a uint16.
-func (s State) QType() uint16 {
- return s.Req.Question[0].Qtype
-}
+func (s State) QType() uint16 { return s.Req.Question[0].Qtype }
// Name returns the name of the question in the request. Note
// this name will always have a closing dot and will be lower cased.
-func (s State) Name() string {
- return strings.ToLower(dns.Name(s.Req.Question[0].Name).String())
-}
+func (s State) Name() string { return strings.ToLower(dns.Name(s.Req.Question[0].Name).String()) }
// QName returns the name of the question in the request.
-func (s State) QName() string {
- return dns.Name(s.Req.Question[0].Name).String()
-}
+func (s State) QName() string { return dns.Name(s.Req.Question[0].Name).String() }
// Class returns the class of the question in the request.
-func (s State) Class() string {
- return dns.Class(s.Req.Question[0].Qclass).String()
-}
+func (s State) Class() string { return dns.Class(s.Req.Question[0].Qclass).String() }
// QClass returns the class of the question in the request.
-func (s State) QClass() uint16 {
- return s.Req.Question[0].Qclass
-}
+func (s State) QClass() uint16 { return s.Req.Question[0].Qclass }
// ErrorMessage returns an error message suitable for sending
// back to the client.