mirror of
https://github.com/safing/portmaster
synced 2025-09-02 02:29:12 +00:00
Skip self-check if device is offline
This commit is contained in:
parent
e9940d77a0
commit
162ebffe48
2 changed files with 13 additions and 0 deletions
|
@ -2,6 +2,7 @@ package compat
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/tevino/abool"
|
||||
|
@ -92,6 +93,9 @@ func selfcheckTaskFunc(ctx context.Context, task *modules.Task) error {
|
|||
case err == nil:
|
||||
// Successful.
|
||||
tracer.Debugf("compat: self-check successful")
|
||||
case errors.Is(err, errSelfcheckSkipped):
|
||||
// Skipped.
|
||||
tracer.Debugf("compat: %s", err)
|
||||
case issue == nil:
|
||||
// Internal error.
|
||||
tracer.Warningf("compat: %s", err)
|
||||
|
|
|
@ -3,6 +3,7 @@ package compat
|
|||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
@ -11,6 +12,7 @@ import (
|
|||
|
||||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portbase/rng"
|
||||
"github.com/safing/portmaster/netenv"
|
||||
"github.com/safing/portmaster/network/packet"
|
||||
"github.com/safing/portmaster/resolver"
|
||||
)
|
||||
|
@ -36,12 +38,19 @@ var (
|
|||
dnsCheckWaitDuration = 45 * time.Second
|
||||
dnsCheckAnswerLock sync.Mutex
|
||||
dnsCheckAnswer net.IP
|
||||
|
||||
errSelfcheckSkipped = errors.New("self-check skipped")
|
||||
)
|
||||
|
||||
func selfcheck(ctx context.Context) (issue *systemIssue, err error) {
|
||||
selfcheckLock.Lock()
|
||||
defer selfcheckLock.Unlock()
|
||||
|
||||
// Step 0: Check if self-check makes sense.
|
||||
if !netenv.Online() {
|
||||
return nil, fmt.Errorf("%w: device is offline or in limited network", errSelfcheckSkipped)
|
||||
}
|
||||
|
||||
// Step 1: Check if the system integration sees a packet.
|
||||
|
||||
// Empty recv channel.
|
||||
|
|
Loading…
Add table
Reference in a new issue