mirror of
https://github.com/coredns/coredns.git
synced 2025-12-07 10:55:17 -05:00
middleware/proxy: multiple enhancements (#145)
Add port 53 in the proxy host if not specified. Check if the host is actually an IP address (v4 or v6) Remove the http headers and other TODOs
This commit is contained in:
@@ -8,8 +8,9 @@ import (
|
||||
)
|
||||
|
||||
type ReverseProxy struct {
|
||||
Host string
|
||||
Client Client
|
||||
Host string
|
||||
Client Client
|
||||
Options Options
|
||||
}
|
||||
|
||||
func (p ReverseProxy) ServeDNS(w dns.ResponseWriter, r *dns.Msg, extra []dns.RR) error {
|
||||
@@ -17,12 +18,11 @@ func (p ReverseProxy) ServeDNS(w dns.ResponseWriter, r *dns.Msg, extra []dns.RR)
|
||||
reply *dns.Msg
|
||||
err error
|
||||
)
|
||||
state := middleware.State{W: w, Req: r}
|
||||
|
||||
// We forward the original request, no need to fiddle with EDNS0 opt sizes.
|
||||
if state.Proto() == "tcp" {
|
||||
switch {
|
||||
case middleware.Proto(w) == "tcp":
|
||||
reply, err = middleware.Exchange(p.Client.TCP, r, p.Host)
|
||||
} else {
|
||||
default:
|
||||
reply, err = middleware.Exchange(p.Client.UDP, r, p.Host)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user