fix: lock value assingments & simplifications
This commit is contained in:
parent
558ebb0127
commit
5e1200ef9b
@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ServeDNS implements the plugin.Handler interface.
|
// 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{}
|
// opt := plugin.Options{}
|
||||||
state := request.Request{W: w, Req: r}
|
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.
|
// Name implements the Handler interface.
|
||||||
func (l Ldap) Name() string { return "ldap" }
|
func (l *Ldap) Name() string { return "ldap" }
|
||||||
|
|
||||||
|
2
ready.go
2
ready.go
@ -2,4 +2,4 @@ package ldap
|
|||||||
|
|
||||||
// Ready implements the ready.Readiness interface, once this flips to true CoreDNS
|
// Ready implements the ready.Readiness interface, once this flips to true CoreDNS
|
||||||
// assumes this plugin is ready for queries; it is not checked again.
|
// 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 }
|
||||||
|
7
sync.go
7
sync.go
@ -10,7 +10,6 @@ import (
|
|||||||
"github.com/coredns/coredns/plugin/file"
|
"github.com/coredns/coredns/plugin/file"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
// Run updates the zone from ldap.
|
// Run updates the zone from ldap.
|
||||||
func (l *Ldap) Run(ctx context.Context) error {
|
func (l *Ldap) Run(ctx context.Context) error {
|
||||||
if err := l.updateZones(ctx); err != nil {
|
if err := l.updateZones(ctx); err != nil {
|
||||||
@ -56,7 +55,8 @@ func (l *Ldap) updateZones(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
l.zMu.Lock()
|
l.zMu.Lock()
|
||||||
for zn, zf := range zoneFileMap {
|
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()
|
l.zMu.Unlock()
|
||||||
return nil
|
return nil
|
||||||
@ -84,7 +84,7 @@ func (l *Ldap) fetchLdapRecords() (ldapRecords []ldapRecord, err error) {
|
|||||||
return nil, fmt.Errorf("fetching data from server: %w", err)
|
return nil, fmt.Errorf("fetching data from server: %w", err)
|
||||||
}
|
}
|
||||||
ldapRecords = make([]ldapRecord, len(searchResult.Entries))
|
ldapRecords = make([]ldapRecord, len(searchResult.Entries))
|
||||||
for i, _ := range ldapRecords {
|
for i := 0; i < len(ldapRecords); i++ {
|
||||||
ldapRecords[i] = ldapRecord{
|
ldapRecords[i] = ldapRecord{
|
||||||
fqdn: searchResult.Entries[i].GetAttributeValue(l.fqdnAttr),
|
fqdn: searchResult.Entries[i].GetAttributeValue(l.fqdnAttr),
|
||||||
ip: net.ParseIP(searchResult.Entries[i].GetAttributeValue(l.ip4Attr)),
|
ip: net.ParseIP(searchResult.Entries[i].GetAttributeValue(l.ip4Attr)),
|
||||||
@ -92,4 +92,3 @@ func (l *Ldap) fetchLdapRecords() (ldapRecords []ldapRecord, err error) {
|
|||||||
}
|
}
|
||||||
return ldapRecords, nil
|
return ldapRecords, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user