mirror of
https://github.com/safing/portmaster
synced 2025-09-02 02:29:12 +00:00
Merge pull request #106 from safing/feature/disable-interception-flag
Add flag to disable interception
This commit is contained in:
commit
3b6cd55d51
4 changed files with 64 additions and 18 deletions
38
firewall/interception/interception.go
Normal file
38
firewall/interception/interception.go
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package interception
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
|
||||||
|
"github.com/safing/portbase/log"
|
||||||
|
"github.com/safing/portmaster/network/packet"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Packets channel for feeding the firewall.
|
||||||
|
Packets = make(chan packet.Packet, 1000)
|
||||||
|
|
||||||
|
disableInterception bool
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flag.BoolVar(&disableInterception, "disable-interception", false, "disable packet interception - this breaks a lot of functionality")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start starts the interception.
|
||||||
|
func Start() error {
|
||||||
|
if disableInterception {
|
||||||
|
log.Warning("interception: packet interception is disabled via flag - this breaks a lot of functionality")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return start()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop starts the interception.
|
||||||
|
func Stop() error {
|
||||||
|
if disableInterception {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return stop()
|
||||||
|
}
|
18
firewall/interception/interception_default.go
Normal file
18
firewall/interception/interception_default.go
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
//+build !windows,!linux
|
||||||
|
|
||||||
|
package interception
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/safing/portbase/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
// start starts the interception.
|
||||||
|
func start() error {
|
||||||
|
log.Info("interception: this platform has no support for packet interception - a lot of functionality will be broken")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop starts the interception.
|
||||||
|
func stop() error {
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -1,16 +1,11 @@
|
||||||
package interception
|
package interception
|
||||||
|
|
||||||
import "github.com/safing/portmaster/network/packet"
|
// start starts the interception.
|
||||||
|
func start() error {
|
||||||
// Packets channel for feeding the firewall.
|
|
||||||
var Packets = make(chan packet.Packet, 1000)
|
|
||||||
|
|
||||||
// Start starts the interception.
|
|
||||||
func Start() error {
|
|
||||||
return StartNfqueueInterception()
|
return StartNfqueueInterception()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop starts the interception.
|
// stop starts the interception.
|
||||||
func Stop() error {
|
func stop() error {
|
||||||
return StopNfqueueInterception()
|
return StopNfqueueInterception()
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,16 +7,11 @@ import (
|
||||||
"github.com/safing/portbase/notifications"
|
"github.com/safing/portbase/notifications"
|
||||||
"github.com/safing/portbase/utils/osdetail"
|
"github.com/safing/portbase/utils/osdetail"
|
||||||
"github.com/safing/portmaster/firewall/interception/windowskext"
|
"github.com/safing/portmaster/firewall/interception/windowskext"
|
||||||
"github.com/safing/portmaster/network/packet"
|
|
||||||
"github.com/safing/portmaster/updates"
|
"github.com/safing/portmaster/updates"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Packets channel for feeding the firewall.
|
// start starts the interception.
|
||||||
var Packets = make(chan packet.Packet, 1000)
|
func start() error {
|
||||||
|
|
||||||
// Start starts the interception.
|
|
||||||
func Start() error {
|
|
||||||
|
|
||||||
dllFile, err := updates.GetPlatformFile("kext/portmaster-kext.dll")
|
dllFile, err := updates.GetPlatformFile("kext/portmaster-kext.dll")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("interception: could not get kext dll: %s", err)
|
return fmt.Errorf("interception: could not get kext dll: %s", err)
|
||||||
|
@ -42,8 +37,8 @@ func Start() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop starts the interception.
|
// stop starts the interception.
|
||||||
func Stop() error {
|
func stop() error {
|
||||||
return windowskext.Stop()
|
return windowskext.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue