File tree Expand file tree Collapse file tree 3 files changed +12
-10
lines changed
Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change 44 "sync"
55
66 "github.com/Luzilla/dnsbl_exporter/pkg/dns"
7+ "github.com/Luzilla/dnsbl_exporter/pkg/rbl"
78 x "github.com/miekg/dns"
89 "github.com/prometheus/client_golang/prometheus"
910 log "github.com/sirupsen/logrus"
@@ -85,10 +86,10 @@ func (c *RblCollector) Collect(ch chan<- prometheus.Metric) {
8586
8687 log .Debugln ("Checking ..." , host )
8788
88- rbl := NewRbl (dns .New (new (x.Client ), c .resolver ))
89- rbl .Update (host , c .rbls )
89+ r := rbl . New (dns .New (new (x.Client ), c .resolver ))
90+ r .Update (host , c .rbls )
9091
91- for _ , result := range rbl .Results {
92+ for _ , result := range r .Results {
9293 // this is an "error" from the RBL
9394 if result .Error {
9495 log .Errorln (result .Text )
Original file line number Diff line number Diff line change 1- package collector
1+ package rbl
22
33import (
44 "fmt"
@@ -28,7 +28,7 @@ type Rbl struct {
2828}
2929
3030// NewRbl ... factory
31- func NewRbl (util * dns.DNSUtil ) Rbl {
31+ func New (util * dns.DNSUtil ) Rbl {
3232 var results []Rblresult
3333
3434 rbl := Rbl {
Original file line number Diff line number Diff line change 1- package collector
1+ package rbl_test
22
33import (
44 "os"
55 "testing"
66
77 "github.com/Luzilla/dnsbl_exporter/pkg/dns"
8+ "github.com/Luzilla/dnsbl_exporter/pkg/rbl"
89 x "github.com/miekg/dns"
910 log "github.com/sirupsen/logrus"
1011)
@@ -15,10 +16,10 @@ func TestUpdate(t *testing.T) {
1516
1617 d := dns .New (new (x.Client ), "0.0.0.0:53" )
1718
18- rbl := NewRbl (d )
19- rbl .Update ("this.is.not.an.ip" , []string {"cbl.abuseat.org" })
19+ r := rbl . New (d )
20+ r .Update ("this.is.not.an.ip" , []string {"cbl.abuseat.org" })
2021
21- if len (rbl .Results ) > 0 {
22- t .Errorf ("Got a result, but shouldn't have: %v" , rbl .Results )
22+ if len (r .Results ) > 0 {
23+ t .Errorf ("Got a result, but shouldn't have: %v" , r .Results )
2324 }
2425}
You can’t perform that action at this time.
0 commit comments