lint: additional linting & nolints
This commit is contained in:
parent
5209d31929
commit
0865a9015e
@ -49,7 +49,10 @@ func (l *Ldap) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
|
|||||||
case file.ServerFailure:
|
case file.ServerFailure:
|
||||||
return dns.RcodeServerFailure, nil
|
return dns.RcodeServerFailure, nil
|
||||||
}
|
}
|
||||||
w.WriteMsg(m)
|
|
||||||
|
if err := w.WriteMsg(m); err != nil {
|
||||||
|
return dns.RcodeServerFailure, nil
|
||||||
|
}
|
||||||
|
|
||||||
return dns.RcodeSuccess, nil
|
return dns.RcodeSuccess, nil
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
. "github.com/xoe-labs/ldap/v0"
|
. "github.com/xoe-labs/ldap/v0"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// nolint: gochecknoglobals
|
||||||
var ldapTestCases = []test.Case{
|
var ldapTestCases = []test.Case{
|
||||||
{
|
{
|
||||||
// Simple case
|
// Simple case
|
||||||
@ -36,14 +37,18 @@ func newTestLdap() *Ldap {
|
|||||||
|
|
||||||
func newTestLdapZones() map[string]*file.Zone {
|
func newTestLdapZones() map[string]*file.Zone {
|
||||||
Zone := file.NewZone("example.org.", "")
|
Zone := file.NewZone("example.org.", "")
|
||||||
Zone.Insert(SOA("example.org."))
|
if err := Zone.Insert(SOA("example.org.")); err != nil {
|
||||||
|
panic("omg")
|
||||||
|
}
|
||||||
|
|
||||||
for _, rr := range []string{
|
for _, rr := range []string{
|
||||||
"example.org. " + defaultA,
|
"example.org. " + defaultA,
|
||||||
"a.example.org. " + defaultA,
|
"a.example.org. " + defaultA,
|
||||||
} {
|
} {
|
||||||
r, _ := dns.NewRR(rr)
|
r, _ := dns.NewRR(rr)
|
||||||
Zone.Insert(r)
|
if err := Zone.Insert(r); err != nil {
|
||||||
|
panic("omg")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zones := make(map[string]*file.Zone)
|
zones := make(map[string]*file.Zone)
|
||||||
|
2
ldap.go
2
ldap.go
@ -27,7 +27,7 @@ type ldapRecord struct {
|
|||||||
ip net.IP
|
ip net.IP
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ldapRecord) A() (A *dns.A) {
|
func (r *ldapRecord) A() (a *dns.A) {
|
||||||
return &dns.A{Hdr: dns.RR_Header{Name: r.fqdn, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 0}, A: r.ip}
|
return &dns.A{Hdr: dns.RR_Header{Name: r.fqdn, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 0}, A: r.ip}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
setup.go
4
setup.go
@ -18,9 +18,11 @@ import (
|
|||||||
const pluginName = "ldap"
|
const pluginName = "ldap"
|
||||||
|
|
||||||
// Define log to be a logger with the plugin name in it.
|
// Define log to be a logger with the plugin name in it.
|
||||||
|
// nolint: gochecknoglobals
|
||||||
var log = clog.NewWithPlugin(pluginName)
|
var log = clog.NewWithPlugin(pluginName)
|
||||||
|
|
||||||
// init registers this plugin.
|
// init registers this plugin.
|
||||||
|
// nolint: gochecknoinits
|
||||||
func init() { plugin.Register(pluginName, setup) }
|
func init() { plugin.Register(pluginName, setup) }
|
||||||
|
|
||||||
// setup is the function that gets called when the config parser see the token "ldap". Setup is responsible
|
// setup is the function that gets called when the config parser see the token "ldap". Setup is responsible
|
||||||
@ -55,6 +57,7 @@ func setup(c *caddy.Controller) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint: gochecknoglobals
|
||||||
var once sync.Once
|
var once sync.Once
|
||||||
|
|
||||||
func ldapParse(c *caddy.Controller) (*Ldap, error) {
|
func ldapParse(c *caddy.Controller) (*Ldap, error) {
|
||||||
@ -80,6 +83,7 @@ func ldapParse(c *caddy.Controller) (*Ldap, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ParseStanza parses a ldap stanza.
|
// ParseStanza parses a ldap stanza.
|
||||||
|
// nolint: funlen, gocognit, gocyclo
|
||||||
func ParseStanza(c *caddy.Controller) (*Ldap, error) {
|
func ParseStanza(c *caddy.Controller) (*Ldap, error) {
|
||||||
zoneNames := c.RemainingArgs()
|
zoneNames := c.RemainingArgs()
|
||||||
if len(zoneNames) != 0 {
|
if len(zoneNames) != 0 {
|
||||||
|
11
sync.go
11
sync.go
@ -53,11 +53,18 @@ func (l *Ldap) updateZones() error {
|
|||||||
if zoneFileMap[zn] == nil {
|
if zoneFileMap[zn] == nil {
|
||||||
zoneFileMap[zn] = file.NewZone(zn, "")
|
zoneFileMap[zn] = file.NewZone(zn, "")
|
||||||
zoneFileMap[zn].Upstream = l.Upstream
|
zoneFileMap[zn].Upstream = l.Upstream
|
||||||
zoneFileMap[zn].Insert(SOA(zn))
|
|
||||||
|
err = zoneFileMap[zn].Insert(SOA(zn))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("updating zones: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, lr := range lrpz {
|
for _, lr := range lrpz {
|
||||||
zoneFileMap[zn].Insert(lr.A())
|
err = zoneFileMap[zn].Insert(lr.A())
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("updating zones: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user