mirror of
https://github.com/folbricht/routedns.git
synced 2026-01-06 09:40:03 -06:00
@@ -2,7 +2,6 @@ package rdns
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -10,6 +9,7 @@ import (
|
||||
|
||||
// DNSClient represents a simple DNS resolver for UDP or TCP.
|
||||
type DNSClient struct {
|
||||
id string
|
||||
endpoint string
|
||||
net string
|
||||
pipeline *Pipeline
|
||||
@@ -19,12 +19,13 @@ var _ Resolver = &DNSClient{}
|
||||
|
||||
// NewDNSClient returns a new instance of DNSClient which is a plain DNS resolver
|
||||
// that supports pipelining over a single connection.
|
||||
func NewDNSClient(endpoint, net string) *DNSClient {
|
||||
func NewDNSClient(id, endpoint, net string) *DNSClient {
|
||||
client := &dns.Client{
|
||||
Net: net,
|
||||
TLSConfig: &tls.Config{},
|
||||
}
|
||||
return &DNSClient{
|
||||
id: id,
|
||||
net: net,
|
||||
endpoint: endpoint,
|
||||
pipeline: NewPipeline(endpoint, client),
|
||||
@@ -34,6 +35,7 @@ func NewDNSClient(endpoint, net string) *DNSClient {
|
||||
// Resolve a DNS query.
|
||||
func (d *DNSClient) Resolve(q *dns.Msg, ci ClientInfo) (*dns.Msg, error) {
|
||||
Log.WithFields(logrus.Fields{
|
||||
"id": d.id,
|
||||
"client": ci.SourceIP,
|
||||
"qname": qName(q),
|
||||
"resolver": d.endpoint,
|
||||
@@ -46,5 +48,5 @@ func (d *DNSClient) Resolve(q *dns.Msg, ci ClientInfo) (*dns.Msg, error) {
|
||||
}
|
||||
|
||||
func (d *DNSClient) String() string {
|
||||
return fmt.Sprintf("DNS(%s)", d.endpoint)
|
||||
return d.id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user