firewall

package
v0.20.3 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action int

Action is the action to be taken on a rule

const (
	// ActionAccept is the action to accept a packet
	ActionAccept Action = iota
	// ActionDrop is the action to drop a packet
	ActionDrop
)

type Direction

type Direction int

Direction is the direction of the traffic

const (
	// DirectionSrc is the direction of the traffic from the source
	DirectionSrc Direction = iota
	// DirectionDst is the direction of the traffic from the destination
	DirectionDst
)

type Manager

type Manager interface {
	// AddFiltering rule to the firewall
	AddFiltering(
		ip net.IP,
		port *Port,
		direction Direction,
		action Action,
		comment string,
	) (Rule, error)

	// DeleteRule from the firewall by rule definition
	DeleteRule(rule Rule) error

	// Reset firewall to the default state
	Reset() error
}

Manager is the high level abstraction of a firewall manager

It declares methods which handle actions required by the Netbird client for ACL and routing functionality

type Port

type Port struct {
	// IsRange is true Values contains two values, the first is the start port, the second is the end port
	IsRange bool

	// Values contains one value for single port, multiple values for the list of ports, or two values for the range of ports
	Values []int

	// Proto is the protocol of the port
	Proto PortProtocol
}

Port of the address for firewall rule

type PortProtocol

type PortProtocol string

PortProtocol is the protocol of the port

const (
	// PortProtocolTCP is the TCP protocol
	PortProtocolTCP PortProtocol = "tcp"

	// PortProtocolUDP is the UDP protocol
	PortProtocolUDP PortProtocol = "udp"
)

type Rule

type Rule interface {
	// GetRuleID returns the rule id
	GetRuleID() string
}

Rule abstraction should be implemented by each firewall manager

Each firewall type for different OS can use different type of the properties to hold data of the created rule

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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