Implement review suggestions

This commit is contained in:
Daniel 2021-01-28 16:44:40 +01:00
parent ee9ee3dc68
commit 6233c76778
6 changed files with 9 additions and 9 deletions

View file

@ -59,8 +59,7 @@ func addActiveProfile(profile *Profile) {
defer activeProfilesLock.Unlock()
// Mark any previous profile as outdated.
previous, ok := activeProfiles[profile.ScopedID()]
if ok {
if previous, ok := activeProfiles[profile.ScopedID()]; ok {
previous.outdated.Set()
}

View file

@ -30,7 +30,9 @@ var getProfileSingleInflight singleflight.Group
// GetProfile fetches a profile. This function ensures that the loaded profile
// is shared among all callers. You must always supply both the scopedID and
// linkedPath parameters whenever available.
// linkedPath parameters whenever available. The linkedPath is used as the key
// for locking concurrent requests, so it must be supplied if available.
// If linkedPath is not supplied, source and id make up the key instead.
func GetProfile(source profileSource, id, linkedPath string) ( //nolint:gocognit
profile *Profile,
err error,

View file

@ -37,9 +37,9 @@ func exportDNSResolvers(*api.Request) (interface{}, error) {
resolversLock.RLock()
defer resolversLock.RUnlock()
export := make([]*resolverExport, 0, len(globalResolvers))
export := make([]resolverExport, 0, len(globalResolvers))
for _, r := range globalResolvers {
export = append(export, &resolverExport{
export = append(export, resolverExport{
Resolver: r,
Failing: r.Conn.IsFailing(),
})

View file

@ -86,8 +86,8 @@ func GetNameRecord(domain, question string) (*NameRecord, error) {
return new, nil
}
// DeleteNameRecord deletes a NameRecord from the database.
func DeleteNameRecord(domain, question string) error {
// ResetCachedRecord deletes a NameRecord from the cache database.
func ResetCachedRecord(domain, question string) error {
// In order to properly delete an entry, we must also clear the caches.
recordDatabase.FlushCache()
recordDatabase.ClearCache()

View file

@ -190,7 +190,7 @@ func checkCache(ctx context.Context, q *Query) *RRCache {
// Check if we want to reset the cache for this entry.
if shouldResetCache(q) {
err := DeleteNameRecord(q.FQDN, q.QType.String())
err := ResetCachedRecord(q.FQDN, q.QType.String())
switch {
case err == nil:
log.Tracer(ctx).Tracef("resolver: cache for %s%s was reset", q.FQDN, q.QType)

View file

@ -179,7 +179,6 @@ var (
errInsecureProtocol = errors.New("insecure protocols disabled")
errAssignedServer = errors.New("assigned (dhcp) nameservers disabled")
errMulticastDNS = errors.New("multicast DNS disabled")
errSkip = errors.New("this fqdn cannot resolved by this resolver")
)
func (q *Query) checkCompliance() error {