Merge pull request #242 from safing/fix/review

Implement review suggestions
This commit is contained in:
Patrick Pacher 2021-01-29 14:39:38 +01:00 committed by GitHub
commit d9c14c679b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 9 deletions

View file

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

View file

@ -30,7 +30,9 @@ var getProfileSingleInflight singleflight.Group
// GetProfile fetches a profile. This function ensures that the loaded profile // GetProfile fetches a profile. This function ensures that the loaded profile
// is shared among all callers. You must always supply both the scopedID and // 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 func GetProfile(source profileSource, id, linkedPath string) ( //nolint:gocognit
profile *Profile, profile *Profile,
err error, err error,

View file

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

View file

@ -86,8 +86,8 @@ func GetNameRecord(domain, question string) (*NameRecord, error) {
return new, nil return new, nil
} }
// DeleteNameRecord deletes a NameRecord from the database. // ResetCachedRecord deletes a NameRecord from the cache database.
func DeleteNameRecord(domain, question string) error { func ResetCachedRecord(domain, question string) error {
// In order to properly delete an entry, we must also clear the caches. // In order to properly delete an entry, we must also clear the caches.
recordDatabase.FlushCache() recordDatabase.FlushCache()
recordDatabase.ClearCache() 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. // Check if we want to reset the cache for this entry.
if shouldResetCache(q) { if shouldResetCache(q) {
err := DeleteNameRecord(q.FQDN, q.QType.String()) err := ResetCachedRecord(q.FQDN, q.QType.String())
switch { switch {
case err == nil: case err == nil:
log.Tracer(ctx).Tracef("resolver: cache for %s%s was reset", q.FQDN, q.QType) 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") errInsecureProtocol = errors.New("insecure protocols disabled")
errAssignedServer = errors.New("assigned (dhcp) nameservers disabled") errAssignedServer = errors.New("assigned (dhcp) nameservers disabled")
errMulticastDNS = errors.New("multicast DNS disabled") errMulticastDNS = errors.New("multicast DNS disabled")
errSkip = errors.New("this fqdn cannot resolved by this resolver")
) )
func (q *Query) checkCompliance() error { func (q *Query) checkCompliance() error {