Implement review suggestions

This commit is contained in:
Daniel 2021-09-27 12:52:36 +02:00
parent 7a04eea8e6
commit 48e9a35a07
6 changed files with 20 additions and 21 deletions

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -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.

View file

@ -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):

View file

@ -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