firewall

package
v0.0.0-...-9474aff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package firewall is a library with utilities for creating an on device firewall

Index

Constants

View Source
const (
	// IptablesCleanupTimeout is the timeout to perform the iptables restore command.
	IptablesCleanupTimeout = time.Second * 5
)

Variables

This section is empty.

Functions

func CreateFirewall

func CreateFirewall(ctx context.Context, params CreateFirewallParams) error

CreateFirewall modifies the iptables to allow traffic on specified ports and interfaces and block traffic on specified ports and protocols.

func RestoreIptables

func RestoreIptables(ctx context.Context, path string) []error

RestoreIptables will restore the state of the iptables from a previously saved file in the provided path. This function does a best effort to restore both the ipv4 and ipv6 iptables.

func SaveIptables

func SaveIptables(ctx context.Context, path string) []error

SaveIptables will save the current state of the iptables to a file in the provided path. This function does a best effort to save both the ipv4 and ipv6 iptables.

Types

type CreateFirewallParams

type CreateFirewallParams struct {
	AllowPorts      []string
	AllowInterfaces []string
	AllowProtocols  []string
	BlockPorts      []string
	BlockProtocols  []string
	Timeout         time.Duration
}

CreateFirewallParams is a list of optional parameters when creating a firewall.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL