badguardhome/internal/aghtest/exchanger.go

21 lines
437 B
Go

package aghtest
import (
"github.com/AdguardTeam/dnsproxy/upstream"
"github.com/miekg/dns"
)
// Exchanger is a mock aghnet.Exchanger implementation for tests.
type Exchanger struct {
Ups upstream.Upstream
}
// Exchange implements aghnet.Exchanger interface for *Exchanger.
func (lr *Exchanger) Exchange(req *dns.Msg) (resp *dns.Msg, err error) {
if lr.Ups == nil {
lr.Ups = &TestErrUpstream{}
}
return lr.Ups.Exchange(req)
}