Skip to content

Commit

Permalink
minor refacto
Browse files Browse the repository at this point in the history
  • Loading branch information
dmachard committed May 7, 2024
1 parent 95b7e59 commit dd11478
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion collectors/dnstap_relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"
"time"

"github.com/dmachard/go-dnscollector/dnsutils"
"github.com/dmachard/go-dnscollector/netutils"
"github.com/dmachard/go-dnscollector/pkgconfig"
"github.com/dmachard/go-dnscollector/pkgutils"
Expand Down Expand Up @@ -75,7 +76,7 @@ func Test_DnstapRelay(t *testing.T) {
frame := &framestream.Frame{}

// get fake dns question
dnsquery, err := processors.GetFakeDNS()
dnsquery, err := dnsutils.GetFakeDNS()
if err != nil {
t.Fatalf("dns question pack error")
}
Expand Down
3 changes: 2 additions & 1 deletion collectors/dnstap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"
"time"

"github.com/dmachard/go-dnscollector/dnsutils"
"github.com/dmachard/go-dnscollector/netutils"
"github.com/dmachard/go-dnscollector/pkgconfig"
"github.com/dmachard/go-dnscollector/pkgutils"
Expand Down Expand Up @@ -96,7 +97,7 @@ func Test_DnstapCollector(t *testing.T) {
subFrame := &framestream.Frame{}

// get fake dns question
dnsquery, err := processors.GetFakeDNS()
dnsquery, err := dnsutils.GetFakeDNS()
if err != nil {
t.Fatalf("dns question pack error")
}
Expand Down
6 changes: 6 additions & 0 deletions dnsutils/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ var (
ATagsDirectives = regexp.MustCompile(`^atags*`)
)

func GetFakeDNS() ([]byte, error) {
dnsmsg := new(dns.Msg)
dnsmsg.SetQuestion("dns.collector.", dns.TypeA)
return dnsmsg.Pack()
}

func GetIPPort(dm *DNSMessage) (string, int, string, int) {
srcIP, srcPort := "0.0.0.0", 53
dstIP, dstPort := "0.0.0.0", 53
Expand Down
7 changes: 0 additions & 7 deletions processors/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,8 @@ import (
"github.com/dmachard/go-dnscollector/pkgutils"
"github.com/dmachard/go-dnscollector/transformers"
"github.com/dmachard/go-logger"
"github.com/miekg/dns"
)

func GetFakeDNS() ([]byte, error) {
dnsmsg := new(dns.Msg)
dnsmsg.SetQuestion("dns.collector.", dns.TypeA)
return dnsmsg.Pack()
}

type DNSProcessor struct {
doneRun, stopRun chan bool
doneMonitor, stopMonitor chan bool
Expand Down

0 comments on commit dd11478

Please sign in to comment.