chore: Upgrade to golangci-lint v2 (#7236)

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
This commit is contained in:
Manuel Rüger
2025-04-04 20:27:39 +02:00
committed by GitHub
parent e16162dd3c
commit 76ba39ffe9
50 changed files with 240 additions and 219 deletions

View File

@@ -29,19 +29,19 @@ func (s *Signer) write(z *file.Zone) error {
}
func write(w io.Writer, z *file.Zone) error {
if _, err := io.WriteString(w, z.Apex.SOA.String()); err != nil {
if _, err := io.WriteString(w, z.SOA.String()); err != nil {
return err
}
w.Write([]byte("\n")) // RR Stringer() method doesn't include newline, which ends the RR in a zone file, write that here.
for _, rr := range z.Apex.SIGSOA {
for _, rr := range z.SIGSOA {
io.WriteString(w, rr.String())
w.Write([]byte("\n"))
}
for _, rr := range z.Apex.NS {
for _, rr := range z.NS {
io.WriteString(w, rr.String())
w.Write([]byte("\n"))
}
for _, rr := range z.Apex.SIGNS {
for _, rr := range z.SIGNS {
io.WriteString(w, rr.String())
w.Write([]byte("\n"))
}

View File

@@ -41,10 +41,10 @@ func (s *Signer) Sign(now time.Time) (*file.Zone, error) {
return nil, err
}
mttl := z.Apex.SOA.Minttl
ttl := z.Apex.SOA.Header().Ttl
mttl := z.SOA.Minttl
ttl := z.SOA.Header().Ttl
inception, expiration := lifetime(now, s.jitterIncep, s.jitterExpir)
z.Apex.SOA.Serial = uint32(now.Unix())
z.SOA.Serial = uint32(now.Unix())
for _, pair := range s.keys {
pair.Public.Header().Ttl = ttl // set TTL on key so it matches the RRSIG.
@@ -58,14 +58,14 @@ func (s *Signer) Sign(now time.Time) (*file.Zone, error) {
ln := len(names)
for _, pair := range s.keys {
rrsig, err := pair.signRRs([]dns.RR{z.Apex.SOA}, s.origin, ttl, inception, expiration)
rrsig, err := pair.signRRs([]dns.RR{z.SOA}, s.origin, ttl, inception, expiration)
if err != nil {
return nil, err
}
z.Insert(rrsig)
// NS apex may not be set if RR's have been discarded because the origin doesn't match.
if len(z.Apex.NS) > 0 {
rrsig, err = pair.signRRs(z.Apex.NS, s.origin, ttl, inception, expiration)
if len(z.NS) > 0 {
rrsig, err = pair.signRRs(z.NS, s.origin, ttl, inception, expiration)
if err != nil {
return nil, err
}
@@ -178,7 +178,7 @@ func signAndLog(s *Signer, why error) {
log.Warningf("Error signing %q: failed to move zone file into place: %s", s.origin, err)
return
}
log.Infof("Successfully signed zone %q in %q with key tags %q and %d SOA serial, elapsed %f, next: %s", s.origin, filepath.Join(s.directory, s.signedfile), keyTag(s.keys), z.Apex.SOA.Serial, time.Since(now).Seconds(), now.Add(durationRefreshHours).Format(timeFmt))
log.Infof("Successfully signed zone %q in %q with key tags %q and %d SOA serial, elapsed %f, next: %s", s.origin, filepath.Join(s.directory, s.signedfile), keyTag(s.keys), z.SOA.Serial, time.Since(now).Seconds(), now.Add(durationRefreshHours).Format(timeFmt))
}
// refresh checks every val if some zones need to be resigned.

View File

@@ -170,7 +170,7 @@ func TestSignDS(t *testing.T) {
if x := nsec[0].(*dns.NSEC).NextDomain; x != "www.miek.nl." {
t.Errorf("Expected no NSEC NextDomain to be %s for %s, got %s", "www.miek.nl.", name, x)
}
minttl := z.Apex.SOA.Minttl
minttl := z.SOA.Minttl
if x := nsec[0].Header().Ttl; x != minttl {
t.Errorf("Expected no NSEC TTL to be %d for %s, got %d", minttl, "www.miek.nl.", x)
}