From 5e1200ef9b6426fd73ccbecd3e3eee9e5db1e5b2 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Tue, 9 Jun 2020 23:00:48 -0500 Subject: [PATCH] fix: lock value assingments & simplifications --- handler.go | 4 ++-- ready.go | 2 +- sync.go | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/handler.go b/handler.go index 9f369a5..cd731d1 100644 --- a/handler.go +++ b/handler.go @@ -11,7 +11,7 @@ import ( ) // ServeDNS implements the plugin.Handler interface. -func (l Ldap) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { +func (l *Ldap) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { // opt := plugin.Options{} state := request.Request{W: w, Req: r} @@ -50,5 +50,5 @@ func (l Ldap) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i } // Name implements the Handler interface. -func (l Ldap) Name() string { return "ldap" } +func (l *Ldap) Name() string { return "ldap" } diff --git a/ready.go b/ready.go index fab8ae6..6b82e01 100644 --- a/ready.go +++ b/ready.go @@ -2,4 +2,4 @@ package ldap // Ready implements the ready.Readiness interface, once this flips to true CoreDNS // assumes this plugin is ready for queries; it is not checked again. -func (l Ldap) Ready() bool { return true } +func (l *Ldap) Ready() bool { return true } diff --git a/sync.go b/sync.go index 5985d27..2566121 100644 --- a/sync.go +++ b/sync.go @@ -10,7 +10,6 @@ import ( "github.com/coredns/coredns/plugin/file" ) - // Run updates the zone from ldap. func (l *Ldap) Run(ctx context.Context) error { if err := l.updateZones(ctx); err != nil { @@ -56,7 +55,8 @@ func (l *Ldap) updateZones(ctx context.Context) error { } l.zMu.Lock() for zn, zf := range zoneFileMap { - (*l.Zones.Z[zn]) = *zf + // TODO: assignement copies lock value from file.Zone + (*l.Zones.Z[zn]) = *zf } l.zMu.Unlock() return nil @@ -84,7 +84,7 @@ func (l *Ldap) fetchLdapRecords() (ldapRecords []ldapRecord, err error) { return nil, fmt.Errorf("fetching data from server: %w", err) } ldapRecords = make([]ldapRecord, len(searchResult.Entries)) - for i, _ := range ldapRecords { + for i := 0; i < len(ldapRecords); i++ { ldapRecords[i] = ldapRecord{ fqdn: searchResult.Entries[i].GetAttributeValue(l.fqdnAttr), ip: net.ParseIP(searchResult.Entries[i].GetAttributeValue(l.ip4Attr)), @@ -92,4 +92,3 @@ func (l *Ldap) fetchLdapRecords() (ldapRecords []ldapRecord, err error) { } return ldapRecords, nil } -