happier golangci-lint

This commit is contained in:
s3lph 2022-04-08 21:28:31 +02:00
parent eddafb699b
commit ded845ed46

18
main.go
View file

@ -193,15 +193,13 @@ func (c *MetricsCollector) signatureOk(zone string) (bool, int, error) {
if err != nil { if err != nil {
return false, rsoa.MsgHdr.Rcode, err return false, rsoa.MsgHdr.Rcode, err
} }
level.Debug(c.Log).Log(fmt.Sprintf("SOA header: %+v\n", rsoa.MsgHdr)) _ = level.Debug(c.Log).Log(fmt.Sprintf("SOA header: %+v\n", rsoa.MsgHdr))
return rsoa.MsgHdr.AuthenticatedData && rsoa.MsgHdr.Rcode == dns.RcodeSuccess, rsoa.MsgHdr.Rcode, nil return rsoa.MsgHdr.AuthenticatedData && rsoa.MsgHdr.Rcode == dns.RcodeSuccess, rsoa.MsgHdr.Rcode, nil
} }
func (c *MetricsCollector) cdsDsMatches(zone string) (int, int, int, int, bool, error) { func (c *MetricsCollector) cdsDsMatches(zone string) (int, int, int, int, bool, error) {
dsCount := 0 dsCount := 0
dsRcode := -1
cdsCount := 0 cdsCount := 0
cdsRcode := -1
match := false match := false
var dsdata []DsData var dsdata []DsData
var cdsdata []DsData var cdsdata []DsData
@ -209,11 +207,11 @@ func (c *MetricsCollector) cdsDsMatches(zone string) (int, int, int, int, bool,
qcds := new(dns.Msg) qcds := new(dns.Msg)
qcds.SetQuestion(dns.Fqdn(zone), dns.TypeCDS) qcds.SetQuestion(dns.Fqdn(zone), dns.TypeCDS)
rcds, _, err1 := c.DNS.Exchange(qcds, c.Resolver) rcds, _, err1 := c.DNS.Exchange(qcds, c.Resolver)
cdsRcode = rcds.MsgHdr.Rcode cdsRcode := rcds.MsgHdr.Rcode
if err1 == nil { if err1 == nil {
cdsCount = len(rcds.Answer) cdsCount = len(rcds.Answer)
cdsdata = make([]DsData, len(rcds.Answer)) cdsdata = make([]DsData, len(rcds.Answer))
level.Debug(c.Log).Log(fmt.Sprintf("CDS data: %+v\n", rcds.Answer)) _ = level.Debug(c.Log).Log(fmt.Sprintf("CDS data: %+v\n", rcds.Answer))
for i, a := range rcds.Answer { for i, a := range rcds.Answer {
ds := a.(*dns.CDS).DS ds := a.(*dns.CDS).DS
cdsdata[i] = DsData{ cdsdata[i] = DsData{
@ -229,11 +227,11 @@ func (c *MetricsCollector) cdsDsMatches(zone string) (int, int, int, int, bool,
qds := new(dns.Msg) qds := new(dns.Msg)
qds.SetQuestion(dns.Fqdn(zone), dns.TypeDS) qds.SetQuestion(dns.Fqdn(zone), dns.TypeDS)
rds, _, err2 := c.DNS.Exchange(qds, c.Resolver) rds, _, err2 := c.DNS.Exchange(qds, c.Resolver)
dsRcode = rds.MsgHdr.Rcode dsRcode := rds.MsgHdr.Rcode
if err2 == nil { if err2 == nil {
dsCount = len(rds.Answer) dsCount = len(rds.Answer)
dsdata = make([]DsData, len(rds.Answer)) dsdata = make([]DsData, len(rds.Answer))
level.Debug(c.Log).Log(fmt.Sprintf("DS data: %+v\n", rds.Answer)) _ = level.Debug(c.Log).Log(fmt.Sprintf("DS data: %+v\n", rds.Answer))
for i, a := range rds.Answer { for i, a := range rds.Answer {
ds := a.(*dns.DS) ds := a.(*dns.DS)
dsdata[i] = DsData{ dsdata[i] = DsData{
@ -295,12 +293,12 @@ func main() {
if configFile != nil { if configFile != nil {
content, err := ioutil.ReadFile(*configFile) content, err := ioutil.ReadFile(*configFile)
if err != nil { if err != nil {
level.Error(logger).Log(err.Error()) _ = level.Error(logger).Log(err.Error())
os.Exit(1) os.Exit(1)
} }
err = yaml.Unmarshal(content, &config) err = yaml.Unmarshal(content, &config)
if err != nil { if err != nil {
level.Error(logger).Log(err.Error()) _ = level.Error(logger).Log(err.Error())
os.Exit(1) os.Exit(1)
} }
} }
@ -315,5 +313,5 @@ func main() {
prom.MustRegister(metricsCollector) prom.MustRegister(metricsCollector)
http.Handle(*metricsPath, promhttp.Handler()) http.Handle(*metricsPath, promhttp.Handler())
server := &http.Server{Addr: *listenAddress} server := &http.Server{Addr: *listenAddress}
logger.Log(web.ListenAndServe(server, *webConfigFile, logger)) _ = logger.Log(web.ListenAndServe(server, *webConfigFile, logger))
} }