mirror of
https://github.com/safing/portmaster
synced 2025-09-02 18:49:14 +00:00
Merge pull request #242 from safing/fix/review
Implement review suggestions
This commit is contained in:
commit
d9c14c679b
6 changed files with 9 additions and 9 deletions
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue