Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions iptables/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,15 @@ func formatComment(text string) string {
func addOutgoingTrafficRules(commands []*exec.Cmd, firewallConfiguration FirewallConfiguration) []*exec.Cmd {
outputChainName := "PROXY_INIT_OUTPUT"
redirectChainName := "PROXY_INIT_REDIRECT"
executeCommand(firewallConfiguration, makeFlushChain(outputChainName))
executeCommand(firewallConfiguration, makeDeleteChain(outputChainName))
err := executeCommand(firewallConfiguration, makeFlushChain(outputChainName))
if err != nil {
log.Printf("An error occurred while FLUSHING the chain in addOutgoingTrafficRules. Startup will continue, but there may be additional errors\n [error]: %v", err)
}

err = executeCommand(firewallConfiguration, makeDeleteChain(outputChainName))
if err != nil {
log.Printf("An error occurred while DELETING the chain in addOutgoingTrafficRules. Startup will continue, but there may be additional errors\n [error]: %v", err)
}

commands = append(commands, makeCreateNewChain(outputChainName, "redirect-common-chain"))

Expand Down Expand Up @@ -121,8 +128,15 @@ func addOutgoingTrafficRules(commands []*exec.Cmd, firewallConfiguration Firewal

func addIncomingTrafficRules(commands []*exec.Cmd, firewallConfiguration FirewallConfiguration) []*exec.Cmd {
redirectChainName := "PROXY_INIT_REDIRECT"
executeCommand(firewallConfiguration, makeFlushChain(redirectChainName))
executeCommand(firewallConfiguration, makeDeleteChain(redirectChainName))
err := executeCommand(firewallConfiguration, makeFlushChain(redirectChainName))
if err != nil {
log.Printf("An error occurred while FLUSHING the chain in addIncomingTrafficRules. Startup will continue, but there may be additional errors\n [error]: %v", err)
}

err = executeCommand(firewallConfiguration, makeDeleteChain(redirectChainName))
if err != nil {
log.Printf("An error occurred while DELETING the chain in addIncomingTrafficRules. Startup will continue, but there may be additional errors\n [error]: %v", err)
}

commands = append(commands, makeCreateNewChain(redirectChainName, "redirect-common-chain"))
commands = addRulesForIgnoredPorts(firewallConfiguration.InboundPortsToIgnore, redirectChainName, commands)
Expand Down