plugin/forward: Allow Proxy to be used outside of forward plugin. (#5951)

* plugin/forward: Move Proxy into pkg/plugin/proxy, to allow forward.Proxy to be used outside of forward plugin.

Signed-off-by: Patrick Downey <patrick.downey@dioadconsulting.com>
This commit is contained in:
Pat Downey
2023-03-24 12:55:51 +00:00
committed by GitHub
parent 47dceabfc6
commit f823825f8a
19 changed files with 529 additions and 210 deletions

View File

@@ -6,6 +6,7 @@ import (
"time"
"github.com/coredns/coredns/plugin/dnstap/msg"
"github.com/coredns/coredns/plugin/pkg/proxy"
"github.com/coredns/coredns/request"
tap "github.com/dnstap/golang-dnstap"
@@ -13,7 +14,7 @@ import (
)
// toDnstap will send the forward and received message to the dnstap plugin.
func toDnstap(f *Forward, host string, state request.Request, opts options, reply *dns.Msg, start time.Time) {
func toDnstap(f *Forward, host string, state request.Request, opts proxy.Options, reply *dns.Msg, start time.Time) {
h, p, _ := net.SplitHostPort(host) // this is preparsed and can't err here
port, _ := strconv.ParseUint(p, 10, 32) // same here
ip := net.ParseIP(h)
@@ -21,9 +22,9 @@ func toDnstap(f *Forward, host string, state request.Request, opts options, repl
var ta net.Addr = &net.UDPAddr{IP: ip, Port: int(port)}
t := state.Proto()
switch {
case opts.forceTCP:
case opts.ForceTCP:
t = "tcp"
case opts.preferUDP:
case opts.PreferUDP:
t = "udp"
}