Skip to content

Commit

Permalink
Add recover-iptables sub-comment. Fixes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
ppacher committed Jul 16, 2020
1 parent a769660 commit 06e5f77
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
19 changes: 19 additions & 0 deletions cmds/portmaster-start/recover_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"github.com/safing/portmaster/firewall/interception"
"github.com/spf13/cobra"
)

var recoverIPTablesCmd = &cobra.Command{
Use: "recover-iptables",
Short: "Removes obsolete IP tables rules in case of an unclean shutdown",
RunE: func(*cobra.Command, []string) error {
return interception.DeactivateNfqueueFirewall()
},
SilenceUsage: true,
}

func init() {
rootCmd.AddCommand(recoverIPTablesCmd)
}
5 changes: 3 additions & 2 deletions firewall/interception/nfqueue_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ func activateNfqueueFirewall() error {
return nil
}

func deactivateNfqueueFirewall() error {
// DeactivateNfqueueFirewall drops portmaster related IP tables rules.
func DeactivateNfqueueFirewall() error {
// IPv4
ip4tables, err := iptables.NewWithProtocol(iptables.ProtocolIPv4)
if err != nil {
Expand Down Expand Up @@ -293,7 +294,7 @@ func StopNfqueueInterception() error {
in6Queue.Destroy()
}

err := deactivateNfqueueFirewall()
err := DeactivateNfqueueFirewall()
if err != nil {
return fmt.Errorf("interception: error while deactivating nfqueue: %s", err)
}
Expand Down

0 comments on commit 06e5f77

Please sign in to comment.