config

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Filters []*Filter `json:"filters"`
}

func (*Config) String

func (c *Config) String() string

String converts a Config into a xdpfw config file

func (*Config) Validate

func (c *Config) Validate() error

Validate checks that the config is valid

type Filter

type Filter struct {
	MinLen           *int `json:"min_len"`   // Minimum frame length (ethernet header, IP header, L4 header, and data)
	MaxLen           *int `json:"max_len"`   // Maximum frame length (ethernet header, IP header, L4 header, and data)
	PacketsPerSecond *int `json:"pps"`       // Packets per second that a source IP can send before matching
	BytesPerSecond   *int `json:"bps"`       // Bytes per second that a source IP can send before matching
	BlockTime        *int `json:"blocktime"` // Time in seconds to block the source IP if the rule matches and the action is block (0). Default value is 1.

	// IP options
	TypeOfService *int    `json:"tos"`     // IP TOS field
	SrcIP         *string `json:"srcip"`   // Source IPv4 address
	DstIP         *string `json:"dstip"`   // Destination IPv4 address
	SrcIP6        *string `json:"srcip6"`  // Source IPv6 address
	DstIP6        *string `json:"dstip6"`  // Destination IPv6 address
	MinTTL        *int    `json:"min_ttl"` // Minimum TTL that the packet must match
	MaxTTL        *int    `json:"max_ttl"` // Maximum TTL that the packet must match

	// TCP Options
	TCPEnabled *bool `json:"tcp_enabled"` // Should TCP options be checked?
	TCPSrcPort *int  `json:"tcp_sport"`   // Source TCP port
	TCPDstPort *int  `json:"tcp_dport"`   // Destination TCP port
	TCPFlagURG *bool `json:"tcp_urg"`     // TCP URG flag
	TCPFlagACK *bool `json:"tcp_ack"`     // TCP ACK flag
	TCPFlagRST *bool `json:"tcp_rst"`     // TCP RST flag
	TCPFlagPSH *bool `json:"tcp_psh"`     // TCP PSH flag
	TCPFlagSYN *bool `json:"tcp_syn"`     // TCP SYN flag
	TCPFlagFIN *bool `json:"tcp_fin"`     // TCP FIN flag

	// UDP Options
	UDPEnabled *bool `json:"udp_enabled"` // Should UDP options be checked?
	UDPSrcPort *int  `json:"udp_sport"`   // Source UDP port
	UDPDstPort *int  `json:"udp_dport"`   // Destination UDP port

	// ICMP Options
	ICMPEnabled *bool `json:"icmp_enabled"` // Should ICMP options be checked?
	ICMPCode    *int  `json:"icmp_code"`    // ICMP code
	ICMPType    *int  `json:"icmp_type"`    // ICMP type
}

Filter represents a xdpfw filter policy

func FromJSON

func FromJSON(s string) (*Filter, error)

FromJSON converts a JSON string into a filter

func (*Filter) String

func (f *Filter) String() string

String returns a string representation of the filter in xdpfw syntax

func (*Filter) Validate

func (f *Filter) Validate() error

Validate returns an error if the filter is invalid

Jump to

Keyboard shortcuts

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