Merge pull request #1170 from safing/fix/user-agent-and-nfq-shutdown

Fix nf conntrack shutdown and improve user agents
This commit is contained in:
Daniel Hovie
2023-04-13 16:52:20 +02:00
committed by GitHub
6 changed files with 24 additions and 15 deletions

View File

@@ -15,23 +15,24 @@ jobs:
name: Linter
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
- name: Check out code
uses: actions/checkout@v3
- uses: actions/setup-go@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '^1.19'
- name: Get dependencies
run: go mod download
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49.0
version: v1.52.2
only-new-issues: true
args: -c ./.golangci.yml --timeout 15m
- name: Get dependencies
run: go mod download
- name: Run go vet
run: go vet ./...
@@ -43,7 +44,7 @@ jobs:
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: '^1.19'
@@ -52,6 +53,3 @@ jobs:
- name: Run tests
run: ./test --test-only
- name: Build Portmaster Core
run: ./cmds/portmaster-core/pack

View File

@@ -2,12 +2,15 @@
package main
import (
"fmt"
"os"
"runtime"
"github.com/safing/portbase/info"
"github.com/safing/portbase/log"
"github.com/safing/portbase/metrics"
"github.com/safing/portbase/run"
"github.com/safing/portmaster/updates"
"github.com/safing/spn/conf"
// Include packages here.
@@ -29,6 +32,9 @@ func main() {
// Configure metrics.
_ = metrics.SetNamespace("portmaster")
// Configure user agent.
updates.UserAgent = fmt.Sprintf("Portmaster Core (%s %s)", runtime.GOOS, runtime.GOARCH)
// enable SPN client mode
conf.EnableClient(true)

View File

@@ -8,6 +8,7 @@ import (
"os"
"os/signal"
"path/filepath"
"runtime"
"strings"
"syscall"
@@ -34,6 +35,7 @@ var (
UpdateURLs: []string{
"https://updates.safing.io",
},
UserAgent: fmt.Sprintf("Portmaster Start (%s %s)", runtime.GOOS, runtime.GOARCH),
Verification: helper.VerificationConfig,
DevMode: false,
Online: true, // is disabled later based on command

View File

@@ -27,7 +27,9 @@ func InitNFCT() error {
// TeardownNFCT deinitializes the network filter conntrack library.
func TeardownNFCT() {
_ = nfct.Close()
if nfct != nil {
_ = nfct.Close()
}
}
// DeleteAllMarkedConnection deletes all marked entries from the conntrack table.

View File

@@ -29,7 +29,7 @@ var (
)
var (
lookupTries = 15 // With a max wait of 5ms, this amounts to up to 75ms.
lookupTries = 20 // With a max wait of 5ms, this amounts to up to 100ms.
fastLookupTries = 2
)

View File

@@ -57,9 +57,10 @@ var (
// UserAgent is an HTTP User-Agent that is used to add
// more context to requests made by the registry when
// fetching resources from the update server.
UserAgent = "Core"
UserAgent = fmt.Sprintf("Portmaster (%s %s)", runtime.GOOS, runtime.GOARCH)
// Explicitly disables automatic software updates. Used in android.
// DisableSoftwareAutoUpdate specifies whether software updates should be disabled.
// This is used on Android, as it will never require binary updates.
DisableSoftwareAutoUpdate = false
)
@@ -250,7 +251,7 @@ func checkForUpdates(ctx context.Context) (err error) {
}
defer func() {
// Resolve any error and and send success notification.
// Resolve any error and send success notification.
if err == nil {
log.Infof("updates: successfully checked for updates")
notifyUpdateSuccess(forcedUpdate)