diff --git a/collector/collector.go b/collector/collector.go index 6090877..5195dd9 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -4,6 +4,7 @@ import ( "sync" "github.com/Luzilla/dnsbl_exporter/pkg/dns" + "github.com/Luzilla/dnsbl_exporter/pkg/rbl" x "github.com/miekg/dns" "github.com/prometheus/client_golang/prometheus" log "github.com/sirupsen/logrus" @@ -85,10 +86,10 @@ func (c *RblCollector) Collect(ch chan<- prometheus.Metric) { log.Debugln("Checking ...", host) - rbl := NewRbl(dns.New(new(x.Client), c.resolver)) - rbl.Update(host, c.rbls) + r := rbl.New(dns.New(new(x.Client), c.resolver)) + r.Update(host, c.rbls) - for _, result := range rbl.Results { + for _, result := range r.Results { // this is an "error" from the RBL if result.Error { log.Errorln(result.Text) diff --git a/collector/rbl.go b/pkg/rbl/rbl.go similarity index 97% rename from collector/rbl.go rename to pkg/rbl/rbl.go index 2f8ce06..f44c34c 100644 --- a/collector/rbl.go +++ b/pkg/rbl/rbl.go @@ -1,4 +1,4 @@ -package collector +package rbl import ( "fmt" @@ -28,7 +28,7 @@ type Rbl struct { } // NewRbl ... factory -func NewRbl(util *dns.DNSUtil) Rbl { +func New(util *dns.DNSUtil) Rbl { var results []Rblresult rbl := Rbl{ diff --git a/collector/rbl_test.go b/pkg/rbl/rbl_test.go similarity index 54% rename from collector/rbl_test.go rename to pkg/rbl/rbl_test.go index 1c153ae..ad48f29 100644 --- a/collector/rbl_test.go +++ b/pkg/rbl/rbl_test.go @@ -1,10 +1,11 @@ -package collector +package rbl_test import ( "os" "testing" "github.com/Luzilla/dnsbl_exporter/pkg/dns" + "github.com/Luzilla/dnsbl_exporter/pkg/rbl" x "github.com/miekg/dns" log "github.com/sirupsen/logrus" ) @@ -15,10 +16,10 @@ func TestUpdate(t *testing.T) { d := dns.New(new(x.Client), "0.0.0.0:53") - rbl := NewRbl(d) - rbl.Update("this.is.not.an.ip", []string{"cbl.abuseat.org"}) + r := rbl.New(d) + r.Update("this.is.not.an.ip", []string{"cbl.abuseat.org"}) - if len(rbl.Results) > 0 { - t.Errorf("Got a result, but shouldn't have: %v", rbl.Results) + if len(r.Results) > 0 { + t.Errorf("Got a result, but shouldn't have: %v", r.Results) } }