Skip to content

Commit

Permalink
Add flag to disable packet interception
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Jul 22, 2020
1 parent 96b2115 commit 0a68b81
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 18 deletions.
38 changes: 38 additions & 0 deletions firewall/interception/interception.go
Original file line number Diff line number Diff line change
@@ -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()
}
13 changes: 4 additions & 9 deletions firewall/interception/interception_linux.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package interception

import "github.com/safing/portmaster/network/packet"

// Packets channel for feeding the firewall.
var Packets = make(chan packet.Packet, 1000)

// Start starts the interception.
func Start() error {
// start starts the interception.
func start() error {
return StartNfqueueInterception()
}

// Stop starts the interception.
func Stop() error {
// stop starts the interception.
func stop() error {
return StopNfqueueInterception()
}
13 changes: 4 additions & 9 deletions firewall/interception/interception_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@ import (
"github.com/safing/portbase/notifications"
"github.com/safing/portbase/utils/osdetail"
"github.com/safing/portmaster/firewall/interception/windowskext"
"github.com/safing/portmaster/network/packet"
"github.com/safing/portmaster/updates"
)

// Packets channel for feeding the firewall.
var Packets = make(chan packet.Packet, 1000)

// Start starts the interception.
func Start() error {

// start starts the interception.
func start() error {
dllFile, err := updates.GetPlatformFile("kext/portmaster-kext.dll")
if err != nil {
return fmt.Errorf("interception: could not get kext dll: %s", err)
Expand All @@ -42,8 +37,8 @@ func Start() error {
return nil
}

// Stop starts the interception.
func Stop() error {
// stop starts the interception.
func stop() error {
return windowskext.Stop()
}

Expand Down

0 comments on commit 0a68b81

Please sign in to comment.