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:
parent
14b84ce02b
commit
e635b4e773
7 changed files with 86 additions and 62 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue