diff --git a/netenv/location.go b/netenv/location.go index cf1149d7..f2e895b4 100644 --- a/netenv/location.go +++ b/netenv/location.go @@ -112,14 +112,10 @@ func (dl *DeviceLocation) IsMoreAccurateThan(other *DeviceLocation) bool { } func (dl *DeviceLocation) LocationOrNil() *geoip.Location { - switch { - case dl == nil: + if dl == nil { return nil - case dl.Location == nil: - return nil - default: - return dl.Location } + return dl.Location } func (dl *DeviceLocation) String() string { diff --git a/network/connection.go b/network/connection.go index 93012a15..e628578f 100644 --- a/network/connection.go +++ b/network/connection.go @@ -502,13 +502,14 @@ func (conn *Connection) SetVerdict(newVerdict Verdict, reason, reasonOptionKey s conn.Verdict = newVerdict conn.Reason.Msg = reason conn.Reason.Context = reasonCtx + + conn.Reason.Profile = "" + conn.Reason.OptionKey = "" if reasonOptionKey != "" && conn.Process() != nil { - conn.Reason.OptionKey = reasonOptionKey conn.Reason.Profile = conn.Process().Profile().GetProfileSource(conn.Reason.OptionKey) - } else { - conn.Reason.OptionKey = "" - conn.Reason.Profile = "" + conn.Reason.OptionKey = reasonOptionKey } + return true } return false diff --git a/resolver/resolve.go b/resolver/resolve.go index ee9d5044..d4a123bd 100644 --- a/resolver/resolve.go +++ b/resolver/resolve.go @@ -32,8 +32,6 @@ var ( ErrFailure = errors.New("query failed") // ErrContinue is returned when the resolver has no answer, and the next resolver should be asked ErrContinue = errors.New("resolver has no answer") - // ErrCancelled is returned when the request was cancelled. - ErrCancelled = errors.New("request cancelled") // ErrShuttingDown is returned when the resolver is shutting down. ErrShuttingDown = errors.New("resolver is shutting down") @@ -370,7 +368,9 @@ resolveLoop: resolver.Conn.ReportFailure() log.Tracer(ctx).Debugf("resolver: query to %s timed out", resolver.Info.ID()) continue - case errors.Is(err, ErrCancelled): + case errors.Is(err, context.Canceled): + return nil, err + case errors.Is(err, context.DeadlineExceeded): return nil, err case errors.Is(err, ErrShuttingDown): return nil, err diff --git a/resolver/resolver-mdns.go b/resolver/resolver-mdns.go index b5fdb479..59f20884 100644 --- a/resolver/resolver-mdns.go +++ b/resolver/resolver-mdns.go @@ -419,7 +419,7 @@ func queryMulticastDNS(ctx context.Context, q *Query) (*RRCache, error) { return rrCache, nil } case <-ctx.Done(): - return nil, ErrCancelled + return nil, ctx.Err() } // Respond with NXDomain. diff --git a/resolver/resolver-tcp.go b/resolver/resolver-tcp.go index 8e3ac42c..418b0bad 100644 --- a/resolver/resolver-tcp.go +++ b/resolver/resolver-tcp.go @@ -118,7 +118,7 @@ func (tr *TCPResolver) getOrCreateResolverConn(ctx context.Context) (*tcpResolve case <-time.After(heartbeatTimeout): log.Warningf("resolver: heartbeat for dns client %s failed", tr.resolver.Info.DescriptiveName()) case <-ctx.Done(): - return nil, ErrCancelled + return nil, ctx.Err() case <-module.Stopping(): return nil, ErrShuttingDown } @@ -189,7 +189,7 @@ func (tr *TCPResolver) Query(ctx context.Context, q *Query) (*RRCache, error) { select { case resolverConn.queries <- tq: case <-ctx.Done(): - return nil, ErrCancelled + return nil, ctx.Err() case <-module.Stopping(): return nil, ErrShuttingDown case <-time.After(defaultRequestTimeout): @@ -201,7 +201,7 @@ func (tr *TCPResolver) Query(ctx context.Context, q *Query) (*RRCache, error) { select { case reply = <-tq.Response: case <-ctx.Done(): - return nil, ErrCancelled + return nil, ctx.Err() case <-module.Stopping(): return nil, ErrShuttingDown case <-time.After(defaultRequestTimeout): diff --git a/updates/helper/updates.go b/updates/helper/updates.go index c8140e3a..7477c51c 100644 --- a/updates/helper/updates.go +++ b/updates/helper/updates.go @@ -49,20 +49,22 @@ func MandatoryUpdates() (identifiers []string) { // Binaries if onWindows { - identifiers = []string{ + identifiers = append( + identifiers, PlatformIdentifier("core/portmaster-core.exe"), PlatformIdentifier("kext/portmaster-kext.dll"), PlatformIdentifier("kext/portmaster-kext.sys"), PlatformIdentifier("start/portmaster-start.exe"), PlatformIdentifier("notifier/portmaster-notifier.exe"), PlatformIdentifier("notifier/portmaster-snoretoast.exe"), - } + ) } else { - identifiers = []string{ + identifiers = append( + identifiers, PlatformIdentifier("core/portmaster-core"), PlatformIdentifier("start/portmaster-start"), PlatformIdentifier("notifier/portmaster-notifier"), - } + ) } // Components, Assets and Data