mirror of
https://github.com/safing/portmaster
synced 2025-09-02 18:49:14 +00:00
Implement review suggestions
This commit is contained in:
parent
7a04eea8e6
commit
48e9a35a07
6 changed files with 20 additions and 21 deletions
|
@ -112,14 +112,10 @@ func (dl *DeviceLocation) IsMoreAccurateThan(other *DeviceLocation) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dl *DeviceLocation) LocationOrNil() *geoip.Location {
|
func (dl *DeviceLocation) LocationOrNil() *geoip.Location {
|
||||||
switch {
|
if dl == nil {
|
||||||
case dl == nil:
|
|
||||||
return nil
|
return nil
|
||||||
case dl.Location == nil:
|
|
||||||
return nil
|
|
||||||
default:
|
|
||||||
return dl.Location
|
|
||||||
}
|
}
|
||||||
|
return dl.Location
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dl *DeviceLocation) String() string {
|
func (dl *DeviceLocation) String() string {
|
||||||
|
|
|
@ -502,13 +502,14 @@ func (conn *Connection) SetVerdict(newVerdict Verdict, reason, reasonOptionKey s
|
||||||
conn.Verdict = newVerdict
|
conn.Verdict = newVerdict
|
||||||
conn.Reason.Msg = reason
|
conn.Reason.Msg = reason
|
||||||
conn.Reason.Context = reasonCtx
|
conn.Reason.Context = reasonCtx
|
||||||
|
|
||||||
|
conn.Reason.Profile = ""
|
||||||
|
conn.Reason.OptionKey = ""
|
||||||
if reasonOptionKey != "" && conn.Process() != nil {
|
if reasonOptionKey != "" && conn.Process() != nil {
|
||||||
conn.Reason.OptionKey = reasonOptionKey
|
|
||||||
conn.Reason.Profile = conn.Process().Profile().GetProfileSource(conn.Reason.OptionKey)
|
conn.Reason.Profile = conn.Process().Profile().GetProfileSource(conn.Reason.OptionKey)
|
||||||
} else {
|
conn.Reason.OptionKey = reasonOptionKey
|
||||||
conn.Reason.OptionKey = ""
|
|
||||||
conn.Reason.Profile = ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -32,8 +32,6 @@ var (
|
||||||
ErrFailure = errors.New("query failed")
|
ErrFailure = errors.New("query failed")
|
||||||
// ErrContinue is returned when the resolver has no answer, and the next resolver should be asked
|
// ErrContinue is returned when the resolver has no answer, and the next resolver should be asked
|
||||||
ErrContinue = errors.New("resolver has no answer")
|
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 is returned when the resolver is shutting down.
|
||||||
ErrShuttingDown = errors.New("resolver is shutting down")
|
ErrShuttingDown = errors.New("resolver is shutting down")
|
||||||
|
|
||||||
|
@ -370,7 +368,9 @@ resolveLoop:
|
||||||
resolver.Conn.ReportFailure()
|
resolver.Conn.ReportFailure()
|
||||||
log.Tracer(ctx).Debugf("resolver: query to %s timed out", resolver.Info.ID())
|
log.Tracer(ctx).Debugf("resolver: query to %s timed out", resolver.Info.ID())
|
||||||
continue
|
continue
|
||||||
case errors.Is(err, ErrCancelled):
|
case errors.Is(err, context.Canceled):
|
||||||
|
return nil, err
|
||||||
|
case errors.Is(err, context.DeadlineExceeded):
|
||||||
return nil, err
|
return nil, err
|
||||||
case errors.Is(err, ErrShuttingDown):
|
case errors.Is(err, ErrShuttingDown):
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -419,7 +419,7 @@ func queryMulticastDNS(ctx context.Context, q *Query) (*RRCache, error) {
|
||||||
return rrCache, nil
|
return rrCache, nil
|
||||||
}
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil, ErrCancelled
|
return nil, ctx.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Respond with NXDomain.
|
// Respond with NXDomain.
|
||||||
|
|
|
@ -118,7 +118,7 @@ func (tr *TCPResolver) getOrCreateResolverConn(ctx context.Context) (*tcpResolve
|
||||||
case <-time.After(heartbeatTimeout):
|
case <-time.After(heartbeatTimeout):
|
||||||
log.Warningf("resolver: heartbeat for dns client %s failed", tr.resolver.Info.DescriptiveName())
|
log.Warningf("resolver: heartbeat for dns client %s failed", tr.resolver.Info.DescriptiveName())
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil, ErrCancelled
|
return nil, ctx.Err()
|
||||||
case <-module.Stopping():
|
case <-module.Stopping():
|
||||||
return nil, ErrShuttingDown
|
return nil, ErrShuttingDown
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ func (tr *TCPResolver) Query(ctx context.Context, q *Query) (*RRCache, error) {
|
||||||
select {
|
select {
|
||||||
case resolverConn.queries <- tq:
|
case resolverConn.queries <- tq:
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil, ErrCancelled
|
return nil, ctx.Err()
|
||||||
case <-module.Stopping():
|
case <-module.Stopping():
|
||||||
return nil, ErrShuttingDown
|
return nil, ErrShuttingDown
|
||||||
case <-time.After(defaultRequestTimeout):
|
case <-time.After(defaultRequestTimeout):
|
||||||
|
@ -201,7 +201,7 @@ func (tr *TCPResolver) Query(ctx context.Context, q *Query) (*RRCache, error) {
|
||||||
select {
|
select {
|
||||||
case reply = <-tq.Response:
|
case reply = <-tq.Response:
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil, ErrCancelled
|
return nil, ctx.Err()
|
||||||
case <-module.Stopping():
|
case <-module.Stopping():
|
||||||
return nil, ErrShuttingDown
|
return nil, ErrShuttingDown
|
||||||
case <-time.After(defaultRequestTimeout):
|
case <-time.After(defaultRequestTimeout):
|
||||||
|
|
|
@ -49,20 +49,22 @@ func MandatoryUpdates() (identifiers []string) {
|
||||||
|
|
||||||
// Binaries
|
// Binaries
|
||||||
if onWindows {
|
if onWindows {
|
||||||
identifiers = []string{
|
identifiers = append(
|
||||||
|
identifiers,
|
||||||
PlatformIdentifier("core/portmaster-core.exe"),
|
PlatformIdentifier("core/portmaster-core.exe"),
|
||||||
PlatformIdentifier("kext/portmaster-kext.dll"),
|
PlatformIdentifier("kext/portmaster-kext.dll"),
|
||||||
PlatformIdentifier("kext/portmaster-kext.sys"),
|
PlatformIdentifier("kext/portmaster-kext.sys"),
|
||||||
PlatformIdentifier("start/portmaster-start.exe"),
|
PlatformIdentifier("start/portmaster-start.exe"),
|
||||||
PlatformIdentifier("notifier/portmaster-notifier.exe"),
|
PlatformIdentifier("notifier/portmaster-notifier.exe"),
|
||||||
PlatformIdentifier("notifier/portmaster-snoretoast.exe"),
|
PlatformIdentifier("notifier/portmaster-snoretoast.exe"),
|
||||||
}
|
)
|
||||||
} else {
|
} else {
|
||||||
identifiers = []string{
|
identifiers = append(
|
||||||
|
identifiers,
|
||||||
PlatformIdentifier("core/portmaster-core"),
|
PlatformIdentifier("core/portmaster-core"),
|
||||||
PlatformIdentifier("start/portmaster-start"),
|
PlatformIdentifier("start/portmaster-start"),
|
||||||
PlatformIdentifier("notifier/portmaster-notifier"),
|
PlatformIdentifier("notifier/portmaster-notifier"),
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Components, Assets and Data
|
// Components, Assets and Data
|
||||||
|
|
Loading…
Add table
Reference in a new issue