diff --git a/cmds/portmaster-core/pack b/cmds/portmaster-core/pack index b2f6f217..5bbc1443 100755 --- a/cmds/portmaster-core/pack +++ b/cmds/portmaster-core/pack @@ -50,7 +50,7 @@ function build { fi # build - ./build main.go + ./build if [[ $? -ne 0 ]]; then echo -e "\n${COL_BOLD}[core] $platform v$version: ${COL_RED}BUILD FAILED.${COL_OFF}" exit 1 diff --git a/compat/notify.go b/compat/notify.go index b483ead5..5cf6fccc 100644 --- a/compat/notify.go +++ b/compat/notify.go @@ -39,13 +39,13 @@ var ( systemIntegrationIssue = &systemIssue{ id: "compat:system-integration-issue", title: "Detected System Integration Issue", - message: "Portmaster detected a problem with its system integration. You can try to restart or reinstall the Portmaster. If that does not help, please report the issue via [GitHub](https://github.com/safing/portmaster/issues) or send a mail to [support@safing.io](mailto:support@safing.io) so we can help you out.", + message: "Portmaster detected a problem with its system integration. You can try to restart or reinstall the Portmaster. If that does not help, [get support here](https://safing.io/support/).", level: notifications.Error, } systemCompatibilityIssue = &systemIssue{ id: "compat:compatibility-issue", title: "Detected Compatibility Issue", - message: "Portmaster detected that something is interfering with its operation. This could be a VPN, an Anti-Virus or another network protection software. Please check if you are running an incompatible [VPN client](https://docs.safing.io/portmaster/install/status/vpn-compatibility) or [software](https://docs.safing.io/portmaster/install/status/software-compatibility). Otherwise, please report the issue via [GitHub](https://github.com/safing/portmaster/issues) or send a mail to [support@safing.io](mailto:support@safing.io) so we can help you out.", + message: "Portmaster detected that something is interfering with its operation. This could be a VPN, an Anti-Virus or another network protection software. Please check if you are running an incompatible [VPN client](https://docs.safing.io/portmaster/install/status/vpn-compatibility) or [software](https://docs.safing.io/portmaster/install/status/software-compatibility) and disable it. If that does not help, [get support here](https://safing.io/support/).", level: notifications.Error, } // manualDNSSetupRequired is additionally initialized in startNotify(). diff --git a/network/state/lookup.go b/network/state/lookup.go index 03188e8e..2aad2d73 100644 --- a/network/state/lookup.go +++ b/network/state/lookup.go @@ -28,11 +28,6 @@ var ( ErrPIDNotFound = errors.New("could not find pid for socket inode") ) -var ( - lookupTries = 20 // With a max wait of 5ms, this amounts to up to 100ms. - fastLookupTries = 2 -) - // Lookup looks for the given connection in the system state tables and returns the PID of the associated process and whether the connection is inbound. func Lookup(pktInfo *packet.Info, fast bool) (pid int, inbound bool, err error) { // auto-detect version diff --git a/network/state/system_default.go b/network/state/system_default.go index 4b798996..973951c0 100644 --- a/network/state/system_default.go +++ b/network/state/system_default.go @@ -10,6 +10,11 @@ import ( "github.com/safing/portmaster/network/socket" ) +var ( + lookupTries = 20 // With a max wait of 5ms, this amounts to up to 100ms. + fastLookupTries = 2 +) + func init() { // This increases performance on unsupported system. // It's not critical at all and does not break anything if it fails. diff --git a/network/state/system_linux.go b/network/state/system_linux.go index f0fe5382..51954264 100644 --- a/network/state/system_linux.go +++ b/network/state/system_linux.go @@ -12,9 +12,12 @@ var ( getTCP6Table = proc.GetTCP6Table getUDP4Table = proc.GetUDP4Table getUDP6Table = proc.GetUDP6Table -) -var baseWaitTime = 3 * time.Millisecond + lookupTries = 20 // With a max wait of 5ms, this amounts to up to 100ms. + fastLookupTries = 2 + + baseWaitTime = 3 * time.Millisecond +) // CheckPID checks the if socket info already has a PID and if not, tries to find it. // Depending on the OS, this might be a no-op. diff --git a/network/state/system_windows.go b/network/state/system_windows.go index 2a95a01e..a72d9195 100644 --- a/network/state/system_windows.go +++ b/network/state/system_windows.go @@ -10,6 +10,13 @@ var ( getTCP6Table = iphelper.GetTCP6Table getUDP4Table = iphelper.GetUDP4Table getUDP6Table = iphelper.GetUDP6Table + + // With a max wait of 5ms, this amounts to up to 25ms, + // excluding potential data fetching time. + // Measured on Windows: ~150ms + lookupTries = 5 + + fastLookupTries = 2 ) // CheckPID checks the if socket info already has a PID and if not, tries to find it. diff --git a/resolver/metrics.go b/resolver/metrics.go index 6d59a289..8d531107 100644 --- a/resolver/metrics.go +++ b/resolver/metrics.go @@ -31,13 +31,15 @@ func reportRequestDuration(started time.Time, resolver *Resolver) { // getSlowQueriesSensorValue returns the current avg query time recorded by the // slow queries sensor. func getSlowQueriesSensorValue() (avgQueryTime time.Duration) { - return time.Duration( - slowQueriesSensorSum.Load() / slowQueriesSensorCnt.Load(), - ) -} + // Get values and check them. + sum := slowQueriesSensorSum.Load() + cnt := slowQueriesSensorCnt.Load() + if cnt < 1 { + cnt = 1 + } -// getAndResetSlowQueriesSensorValue returns the current avg query time -// recorded by the slow queries sensor and reset the sensor values. + return time.Duration(sum / cnt) +} // resetSlowQueriesSensorValue reset the slow queries sensor values. func resetSlowQueriesSensorValue() { diff --git a/test b/test index 4caccbc9..71a65921 100755 --- a/test +++ b/test @@ -131,6 +131,29 @@ if [[ $testonly -eq 0 ]]; then fi fi +# build portmaster-core for for all supported platforms +echo "building portmaster-core for all platforms" +cd ./cmds/portmaster-core +run env GOOS=linux GOARCH=amd64 ./build +run env GOOS=windows GOARCH=amd64 ./build +run env GOOS=darwin GOARCH=amd64 ./build +run env GOOS=linux GOARCH=arm64 ./build +run env GOOS=windows GOARCH=arm64 ./build +run env GOOS=darwin GOARCH=arm64 ./build +cd "$baseDir" + +# build portmaster-start for for all supported platforms +echo "" +echo "building portmaster-start for all platforms" +cd ./cmds/portmaster-start +run env GOOS=linux GOARCH=amd64 ./build +# run env GOOS=windows GOARCH=amd64 ./build # TODO: Fix for GitHub CI +run env GOOS=darwin GOARCH=amd64 ./build +run env GOOS=linux GOARCH=arm64 ./build +# run env GOOS=windows GOARCH=arm64 ./build # TODO: Fix for GitHub CI +run env GOOS=darwin GOARCH=arm64 ./build +cd "$baseDir" + # target selection if [[ "$1" == "" ]]; then # get all packages @@ -138,10 +161,12 @@ if [[ "$1" == "" ]]; then else # single package testing packages=$(go list -e)/$1 + echo "" echo "note: only running tests for package $packages" fi # platform info +echo "" platformInfo=$(go env GOOS GOARCH) echo "running tests for ${platformInfo//$'\n'/ }:"