mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
chore: Upgrade to golangci-lint v2 (#7236)
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
func (z *Zone) ClosestEncloser(qname string) (*tree.Elem, bool) {
|
||||
offset, end := dns.NextLabel(qname, 0)
|
||||
for !end {
|
||||
elem, _ := z.Tree.Search(qname)
|
||||
elem, _ := z.Search(qname)
|
||||
if elem != nil {
|
||||
return elem, true
|
||||
}
|
||||
@@ -19,5 +19,5 @@ func (z *Zone) ClosestEncloser(qname string) (*tree.Elem, bool) {
|
||||
offset, end = dns.NextLabel(qname, offset)
|
||||
}
|
||||
|
||||
return z.Tree.Search(z.origin)
|
||||
return z.Search(z.origin)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
|
||||
return plugin.NextOrFailure(f.Name(), f.Next, ctx, w, r)
|
||||
}
|
||||
|
||||
z, ok := f.Zones.Z[zone]
|
||||
z, ok := f.Z[zone]
|
||||
if !ok || z == nil {
|
||||
return dns.RcodeServerFailure, nil
|
||||
}
|
||||
|
||||
@@ -330,11 +330,11 @@ func (z *Zone) externalLookup(ctx context.Context, state request.Request, elem *
|
||||
}
|
||||
|
||||
targetName := rrs[0].(*dns.CNAME).Target
|
||||
elem, _ = z.Tree.Search(targetName)
|
||||
elem, _ = z.Search(targetName)
|
||||
if elem == nil {
|
||||
lookupRRs, result := z.doLookup(ctx, state, targetName, qtype)
|
||||
rrs = append(rrs, lookupRRs...)
|
||||
return rrs, z.Apex.ns(do), nil, result
|
||||
return rrs, z.ns(do), nil, result
|
||||
}
|
||||
|
||||
i := 0
|
||||
@@ -350,16 +350,16 @@ Redo:
|
||||
rrs = append(rrs, sigs...)
|
||||
}
|
||||
targetName := cname[0].(*dns.CNAME).Target
|
||||
elem, _ = z.Tree.Search(targetName)
|
||||
elem, _ = z.Search(targetName)
|
||||
if elem == nil {
|
||||
lookupRRs, result := z.doLookup(ctx, state, targetName, qtype)
|
||||
rrs = append(rrs, lookupRRs...)
|
||||
return rrs, z.Apex.ns(do), nil, result
|
||||
return rrs, z.ns(do), nil, result
|
||||
}
|
||||
|
||||
i++
|
||||
if i > 8 {
|
||||
return rrs, z.Apex.ns(do), nil, Success
|
||||
return rrs, z.ns(do), nil, Success
|
||||
}
|
||||
|
||||
goto Redo
|
||||
@@ -376,7 +376,7 @@ Redo:
|
||||
}
|
||||
}
|
||||
|
||||
return rrs, z.Apex.ns(do), nil, Success
|
||||
return rrs, z.ns(do), nil, Success
|
||||
}
|
||||
|
||||
func (z *Zone) doLookup(ctx context.Context, state request.Request, target string, qtype uint16) ([]dns.RR, Result) {
|
||||
@@ -414,7 +414,7 @@ func (z *Zone) additionalProcessing(answer []dns.RR, do bool) (extra []dns.RR) {
|
||||
continue
|
||||
}
|
||||
|
||||
elem, _ := z.Tree.Search(name)
|
||||
elem, _ := z.Search(name)
|
||||
if elem == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func (z *Zone) Reload(t *transfer.Transfer) error {
|
||||
z.Tree = zone.Tree
|
||||
z.Unlock()
|
||||
|
||||
log.Infof("Successfully reloaded zone %q in %q with %d SOA serial", z.origin, zFile, z.Apex.SOA.Serial)
|
||||
log.Infof("Successfully reloaded zone %q in %q with %d SOA serial", z.origin, zFile, z.SOA.Serial)
|
||||
if t != nil {
|
||||
if err := t.Notify(z.origin); err != nil {
|
||||
log.Warningf("Failed sending notifies: %s", err)
|
||||
@@ -62,8 +62,8 @@ func (z *Zone) Reload(t *transfer.Transfer) error {
|
||||
func (z *Zone) SOASerialIfDefined() int64 {
|
||||
z.RLock()
|
||||
defer z.RUnlock()
|
||||
if z.Apex.SOA != nil {
|
||||
return int64(z.Apex.SOA.Serial)
|
||||
if z.SOA != nil {
|
||||
return int64(z.SOA.Serial)
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
@@ -89,10 +89,10 @@ Transfer:
|
||||
if serial == -1 {
|
||||
return false, Err
|
||||
}
|
||||
if z.Apex.SOA == nil {
|
||||
if z.SOA == nil {
|
||||
return true, Err
|
||||
}
|
||||
return less(z.Apex.SOA.Serial, uint32(serial)), Err
|
||||
return less(z.SOA.Serial, uint32(serial)), Err
|
||||
}
|
||||
|
||||
// less returns true of a is smaller than b when taking RFC 1982 serial arithmetic into account.
|
||||
@@ -109,15 +109,15 @@ func less(a, b uint32) bool {
|
||||
// will be marked expired.
|
||||
func (z *Zone) Update() error {
|
||||
// If we don't have a SOA, we don't have a zone, wait for it to appear.
|
||||
for z.Apex.SOA == nil {
|
||||
for z.SOA == nil {
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
retryActive := false
|
||||
|
||||
Restart:
|
||||
refresh := time.Second * time.Duration(z.Apex.SOA.Refresh)
|
||||
retry := time.Second * time.Duration(z.Apex.SOA.Retry)
|
||||
expire := time.Second * time.Duration(z.Apex.SOA.Expire)
|
||||
refresh := time.Second * time.Duration(z.SOA.Refresh)
|
||||
retry := time.Second * time.Duration(z.SOA.Retry)
|
||||
expire := time.Second * time.Duration(z.SOA.Expire)
|
||||
|
||||
refreshTicker := time.NewTicker(refresh)
|
||||
retryTicker := time.NewTicker(retry)
|
||||
|
||||
@@ -84,7 +84,7 @@ func TestShouldTransfer(t *testing.T) {
|
||||
t.Fatalf("ShouldTransfer should return true for serial: %d", soa.serial)
|
||||
}
|
||||
// Serial smaller
|
||||
z.Apex.SOA = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, soa.serial-1))
|
||||
z.SOA = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, soa.serial-1))
|
||||
should, err = z.shouldTransfer()
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to run shouldTransfer: %v", err)
|
||||
@@ -93,7 +93,7 @@ func TestShouldTransfer(t *testing.T) {
|
||||
t.Fatalf("ShouldTransfer should return true for serial: %q", soa.serial-1)
|
||||
}
|
||||
// Serial equal
|
||||
z.Apex.SOA = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, soa.serial))
|
||||
z.SOA = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, soa.serial))
|
||||
should, err = z.shouldTransfer()
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to run shouldTransfer: %v", err)
|
||||
@@ -116,7 +116,7 @@ func TestTransferIn(t *testing.T) {
|
||||
if err := z.TransferIn(); err != nil {
|
||||
t.Fatalf("Unable to run TransferIn: %v", err)
|
||||
}
|
||||
if z.Apex.SOA.String() != fmt.Sprintf("%s 3600 IN SOA bla. bla. 250 0 0 0 0", testZone) {
|
||||
if z.SOA.String() != fmt.Sprintf("%s 3600 IN SOA bla. bla. 250 0 0 0 0", testZone) {
|
||||
t.Fatalf("Unknown SOA transferred")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// Transfer implements the transfer.Transfer interface.
|
||||
func (f File) Transfer(zone string, serial uint32) (<-chan []dns.RR, error) {
|
||||
z, ok := f.Zones.Z[zone]
|
||||
z, ok := f.Z[zone]
|
||||
if !ok || z == nil {
|
||||
return nil, transfer.ErrNotAuthoritative
|
||||
}
|
||||
|
||||
@@ -80,14 +80,14 @@ func (z *Zone) Insert(r dns.RR) error {
|
||||
r.(*dns.NS).Ns = strings.ToLower(r.(*dns.NS).Ns)
|
||||
|
||||
if r.Header().Name == z.origin {
|
||||
z.Apex.NS = append(z.Apex.NS, r)
|
||||
z.NS = append(z.NS, r)
|
||||
return nil
|
||||
}
|
||||
case dns.TypeSOA:
|
||||
r.(*dns.SOA).Ns = strings.ToLower(r.(*dns.SOA).Ns)
|
||||
r.(*dns.SOA).Mbox = strings.ToLower(r.(*dns.SOA).Mbox)
|
||||
|
||||
z.Apex.SOA = r.(*dns.SOA)
|
||||
z.SOA = r.(*dns.SOA)
|
||||
return nil
|
||||
case dns.TypeNSEC3, dns.TypeNSEC3PARAM:
|
||||
return fmt.Errorf("NSEC3 zone is not supported, dropping RR: %s for zone: %s", r.Header().Name, z.origin)
|
||||
@@ -95,11 +95,11 @@ func (z *Zone) Insert(r dns.RR) error {
|
||||
x := r.(*dns.RRSIG)
|
||||
switch x.TypeCovered {
|
||||
case dns.TypeSOA:
|
||||
z.Apex.SIGSOA = append(z.Apex.SIGSOA, x)
|
||||
z.SIGSOA = append(z.SIGSOA, x)
|
||||
return nil
|
||||
case dns.TypeNS:
|
||||
if r.Header().Name == z.origin {
|
||||
z.Apex.SIGNS = append(z.Apex.SIGNS, x)
|
||||
z.SIGNS = append(z.SIGNS, x)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -133,20 +133,20 @@ func (z *Zone) SetFile(path string) {
|
||||
func (z *Zone) ApexIfDefined() ([]dns.RR, error) {
|
||||
z.RLock()
|
||||
defer z.RUnlock()
|
||||
if z.Apex.SOA == nil {
|
||||
if z.SOA == nil {
|
||||
return nil, fmt.Errorf("no SOA")
|
||||
}
|
||||
|
||||
rrs := []dns.RR{z.Apex.SOA}
|
||||
rrs := []dns.RR{z.SOA}
|
||||
|
||||
if len(z.Apex.SIGSOA) > 0 {
|
||||
rrs = append(rrs, z.Apex.SIGSOA...)
|
||||
if len(z.SIGSOA) > 0 {
|
||||
rrs = append(rrs, z.SIGSOA...)
|
||||
}
|
||||
if len(z.Apex.NS) > 0 {
|
||||
rrs = append(rrs, z.Apex.NS...)
|
||||
if len(z.NS) > 0 {
|
||||
rrs = append(rrs, z.NS...)
|
||||
}
|
||||
if len(z.Apex.SIGNS) > 0 {
|
||||
rrs = append(rrs, z.Apex.SIGNS...)
|
||||
if len(z.SIGNS) > 0 {
|
||||
rrs = append(rrs, z.SIGNS...)
|
||||
}
|
||||
|
||||
return rrs, nil
|
||||
|
||||
Reference in New Issue
Block a user