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:
18
.github/workflows/go.yml
vendored
18
.github/workflows/go.yml
vendored
@@ -15,23 +15,24 @@ jobs:
|
|||||||
name: Linter
|
name: Linter
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- uses: actions/setup-go@v3
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '^1.19'
|
go-version: '^1.19'
|
||||||
|
|
||||||
|
- name: Get dependencies
|
||||||
|
run: go mod download
|
||||||
|
|
||||||
- name: Run golangci-lint
|
- name: Run golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v3
|
uses: golangci/golangci-lint-action@v3
|
||||||
with:
|
with:
|
||||||
version: v1.49.0
|
version: v1.52.2
|
||||||
only-new-issues: true
|
only-new-issues: true
|
||||||
args: -c ./.golangci.yml --timeout 15m
|
args: -c ./.golangci.yml --timeout 15m
|
||||||
|
|
||||||
- name: Get dependencies
|
|
||||||
run: go mod download
|
|
||||||
|
|
||||||
- name: Run go vet
|
- name: Run go vet
|
||||||
run: go vet ./...
|
run: go vet ./...
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '^1.19'
|
go-version: '^1.19'
|
||||||
|
|
||||||
@@ -52,6 +53,3 @@ jobs:
|
|||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: ./test --test-only
|
run: ./test --test-only
|
||||||
|
|
||||||
- name: Build Portmaster Core
|
|
||||||
run: ./cmds/portmaster-core/pack
|
|
||||||
|
|||||||
@@ -2,12 +2,15 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/safing/portbase/info"
|
"github.com/safing/portbase/info"
|
||||||
"github.com/safing/portbase/log"
|
"github.com/safing/portbase/log"
|
||||||
"github.com/safing/portbase/metrics"
|
"github.com/safing/portbase/metrics"
|
||||||
"github.com/safing/portbase/run"
|
"github.com/safing/portbase/run"
|
||||||
|
"github.com/safing/portmaster/updates"
|
||||||
"github.com/safing/spn/conf"
|
"github.com/safing/spn/conf"
|
||||||
|
|
||||||
// Include packages here.
|
// Include packages here.
|
||||||
@@ -29,6 +32,9 @@ func main() {
|
|||||||
// Configure metrics.
|
// Configure metrics.
|
||||||
_ = metrics.SetNamespace("portmaster")
|
_ = metrics.SetNamespace("portmaster")
|
||||||
|
|
||||||
|
// Configure user agent.
|
||||||
|
updates.UserAgent = fmt.Sprintf("Portmaster Core (%s %s)", runtime.GOOS, runtime.GOARCH)
|
||||||
|
|
||||||
// enable SPN client mode
|
// enable SPN client mode
|
||||||
conf.EnableClient(true)
|
conf.EnableClient(true)
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ var (
|
|||||||
UpdateURLs: []string{
|
UpdateURLs: []string{
|
||||||
"https://updates.safing.io",
|
"https://updates.safing.io",
|
||||||
},
|
},
|
||||||
|
UserAgent: fmt.Sprintf("Portmaster Start (%s %s)", runtime.GOOS, runtime.GOARCH),
|
||||||
Verification: helper.VerificationConfig,
|
Verification: helper.VerificationConfig,
|
||||||
DevMode: false,
|
DevMode: false,
|
||||||
Online: true, // is disabled later based on command
|
Online: true, // is disabled later based on command
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ func InitNFCT() error {
|
|||||||
|
|
||||||
// TeardownNFCT deinitializes the network filter conntrack library.
|
// TeardownNFCT deinitializes the network filter conntrack library.
|
||||||
func TeardownNFCT() {
|
func TeardownNFCT() {
|
||||||
_ = nfct.Close()
|
if nfct != nil {
|
||||||
|
_ = nfct.Close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteAllMarkedConnection deletes all marked entries from the conntrack table.
|
// DeleteAllMarkedConnection deletes all marked entries from the conntrack table.
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
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
|
fastLookupTries = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -57,9 +57,10 @@ var (
|
|||||||
// UserAgent is an HTTP User-Agent that is used to add
|
// UserAgent is an HTTP User-Agent that is used to add
|
||||||
// more context to requests made by the registry when
|
// more context to requests made by the registry when
|
||||||
// fetching resources from the update server.
|
// 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
|
DisableSoftwareAutoUpdate = false
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -250,7 +251,7 @@ func checkForUpdates(ctx context.Context) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
// Resolve any error and and send success notification.
|
// Resolve any error and send success notification.
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Infof("updates: successfully checked for updates")
|
log.Infof("updates: successfully checked for updates")
|
||||||
notifyUpdateSuccess(forcedUpdate)
|
notifyUpdateSuccess(forcedUpdate)
|
||||||
|
|||||||
Reference in New Issue
Block a user