config

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalCommands

func MarshalCommands(v any) (out []byte, err error)

Types

type Config

type Config struct {
	Firewall Firewall `json:"firewall"`
}

type EnableDisable

type EnableDisable bool

func (EnableDisable) MarshalText

func (e EnableDisable) MarshalText() ([]byte, error)

func (EnableDisable) String

func (e EnableDisable) String() string

type Firewall

type Firewall struct {
	AllPing              *EnableDisable               `yaml:"allPing" json:"allPing"`
	BroadcastPing        *EnableDisable               `yaml:"broadcastPing" json:"broadcastPing"`
	ConfigTrap           *EnableDisable               `yaml:"configTrap" json:"configTrap"`
	Groups               FirewallGroups               `vyos:"group" json:"groups"`
	Interfaces           map[string]FirewallInterface `vyos:"interface" json:"interfaces"`
	SrcRouteV4           *EnableDisable               `vyos:"ip-src-route" yaml:"srcRouteV4" json:"srcRouteV4"`
	SrcRouteV6           *EnableDisable               `vyos:"ipv6-src-route" yaml:"srcRouteV6" json:"srcRouteV6"`
	LogMartians          *EnableDisable               `yaml:"logMartians" json:"logMartians"`
	NamesV4              map[string]FirewallRuleSet   `vyos:"name" yaml:"namesV4" json:"namesV4"`
	NamesV6              map[string]FirewallRuleSet   `vyos:"ipv6-name" yaml:"namesV6" json:"namesV6"`
	ReceiveRedirects     *EnableDisable               `yaml:"receiveRedirects" json:"receiveRedirects"`
	ResolverCache        bool                         `yaml:"resolverCache" json:"resolverCache"`
	ResolverInterval     *uint16                      `yaml:"resolverInterval" json:"resolverInterval"`
	SendRedirects        *EnableDisable               `yaml:"sendRedirects" json:"sendRedirects"`
	SourceValidation     *string                      `yaml:"sourceValidation" json:"sourceValidation"`
	StatePolicy          FirewallStatePolicies        `yaml:"statePolicy" json:"statePolicy"`
	SynCookies           *EnableDisable               `yaml:"synCookies" json:"synCookies"`
	TwaHazardsProtection *EnableDisable               `yaml:"twaHazardsProtection" json:"twaHazardsProtection"`
	Zone                 map[string]FirewallZone      `json:"zone"`
}

TODO jsonschema: valid options from other objects?

type FirewallAppliedRuleSets

type FirewallAppliedRuleSets struct {
	NameV4 *string `vyos:"name" yaml:"nameV4" json:"nameV4"`
	NameV6 *string `vyos:"ipv6-name" yaml:"nameV6" json:"nameV6"`
}

type FirewallGroups

type FirewallGroups struct {
	AddressGroupsV4 map[string]FirewallGroupsAddressGroup `vyos:"address-group" yaml:"addressGroupsV4" json:"addressGroupsV4"`
	AddressGroupsV6 map[string]FirewallGroupsAddressGroup `vyos:"ipv6-address-group" yaml:"addressGroupsV6" json:"addressGroupsV6"`

	NetworkGroupsV4 map[string]FirewallGroupsNetworkGroup `vyos:"network-group" yaml:"networkGroupsV4" json:"networkGroupsV4"`
	NetworkGroupsV6 map[string]FirewallGroupsNetworkGroup `vyos:"ipv6-network-group" yaml:"networkGroupsV6" json:"networkGroupsV6"`

	PortGroups      map[string]FirewallGroupsPortGroup      `vyos:"port-group" yaml:"portGroups" json:"portGroups"`
	MacGroups       map[string]FirewallGroupsMacGroup       `vyos:"mac-group" yaml:"macGroups" json:"macGroups"`
	DomainGroups    map[string]FirewallGroupsDomainGroup    `vyos:"domain-group" yaml:"domainGroups" json:"domainGroups"`
	InterfaceGroups map[string]FirewallGroupsInterfaceGroup `vyos:"interface-group" yaml:"interfaceGroups" json:"interfaceGroups"`
}

type FirewallGroupsAddressGroup

type FirewallGroupsAddressGroup struct {
	Description *string                `json:"description"`
	Addresses   []ValueOrRange[IPAddr] `vyos:"address" json:"addresses"`
	Includes    []string               `vyos:"include" json:"includes"`
}

type FirewallGroupsDomainGroup

type FirewallGroupsDomainGroup struct {
	Description *string  `json:"description"`
	Domains     []string `vyos:"domain" json:"domains"`
}

type FirewallGroupsInterfaceGroup

type FirewallGroupsInterfaceGroup struct {
	Description *string  `json:"description"`
	Interfaces  []string `vyos:"interface" json:"interfaces"`
	Includes    []string `vyos:"include" json:"includes"`
}

type FirewallGroupsMacGroup

type FirewallGroupsMacGroup struct {
	Description  *string            `json:"description"`
	MacAddresses []net.HardwareAddr `vyos:"mac-address" yaml:"macAddresses" json:"macAddresses"`
	Includes     []string           `vyos:"include" json:"includes"`
}

type FirewallGroupsNetworkGroup

type FirewallGroupsNetworkGroup struct {
	Description *string    `json:"description"`
	Networks    []IPPrefix `vyos:"network" json:"networks"`
	Includes    []string   `vyos:"include" json:"includes"`
}

type FirewallGroupsPortGroup

type FirewallGroupsPortGroup struct {
	Description *string                `json:"description"`
	Ports       []ValueOrRange[string] `vyos:"port" json:"ports"`
	Includes    []string               `vyos:"include" json:"includes"`
}

type FirewallInterface

type FirewallInterface struct {
	In    FirewallAppliedRuleSets `json:"in"`
	Out   FirewallAppliedRuleSets `json:"out"`
	Local FirewallAppliedRuleSets `json:"local"`
}

type FirewallRuleSet

type FirewallRuleSet struct {
	Description       *string                      `json:"description"`
	DefaultAction     *string                      `yaml:"defaultAction" json:"defaultAction"`
	DefaultJumpTarget *string                      `yaml:"defaultJumpTarget" json:"defaultJumpTarget"`
	EnableDefaultLog  bool                         `yaml:"enableDefaultLog" json:"enableDefaultLog"`
	Rules             map[uint]FirewallRuleSetRule `vyos:"rule" json:"rules"`
}

type FirewallRuleSetRule

type FirewallRuleSetRule struct {
	Description          *string                             `json:"description"`
	Action               *string                             `json:"action"`
	ConnectionMarks      []uint                              `vyos:"connection-mark" yaml:"connectionMarks" json:"connectionMarks"`
	ConnectionStatus     FirewallRuleSetRuleConnectionStatus `yaml:"connectionStatus" json:"connectionStatus"`
	Destination          FirewallRuleSetRuleAddresses        `json:"destination"`
	Disable              bool                                `json:"disable"`
	DSCPs                []ValueOrRange[uint8]               `vyos:"dscp" json:"dscps"`
	DSCPExcludes         []ValueOrRange[uint8]               `vyos:"dscp-exclude" yaml:"dscpExcludes" json:"dscpExcludes"`
	Fragment             FirewallRuleSetRuleFragment         `json:"fragment"`
	ICMP                 FirewallRuleSetRuleICMP             `vyos:"icmp" json:"icmp"`
	ICMPV6               FirewallRuleSetRuleICMP             `vyos:"icmpv6" yaml:"icmpV6" json:"icmpV6"`
	InboundInterface     FirewallRuleSetRuleInterface        `yaml:"inboundInterface" json:"inboundInterface"`
	IPSec                FirewallRuleSetRuleIPSec            `vyos:"ipsec" yaml:"ipSec" json:"ipSec"`
	JumpTarget           *string                             `yaml:"jumpTarget" json:"jumpTarget"`
	Limit                FirewallRuleSetRuleLimit            `json:"limit"`
	Log                  *EnableDisable                      `json:"log"`
	LogLevel             *string                             `yaml:"logLevel" json:"logLevel"`
	OutboundInterface    FirewallRuleSetRuleInterface        `yaml:"outboundInterface" json:"outboundInterface"`
	PacketLengths        []ValueOrRange[uint16]              `vyos:"packet-length" yaml:"packetLengths" json:"packetLengths"`
	PacketLengthExcludes []ValueOrRange[uint16]              `vyos:"packet-length-exclude" yaml:"packetLengthExcludes" json:"packetLengthExcludes"`
	Protocol             *string                             `json:"protocol"`
	Recent               FirewallRuleSetRuleRecent           `json:"recent"`
	Source               FirewallRuleSetRuleAddresses        `json:"source"`
	State                FirewallRuleSetRuleState            `json:"state"`
	TCP                  FirewallRuleSetRuleTCP              `vyos:"tcp" json:"tcp"`
	Time                 FirewallRuleSetRuleTime             `json:"time"`
	TTL                  FirewallRuleSetRuleTTL              `vyos:"ttl" json:"ttl"`
}

type FirewallRuleSetRuleAddressGroup

type FirewallRuleSetRuleAddressGroup struct {
	AddressGroup *string `yaml:"addressGroup" json:"addressGroup"`
	NetworkGroup *string `yaml:"networkGroup" json:"networkGroup"`
	PortGroup    *string `yaml:"portGroup" json:"portGroup"`
	MacGroup     *string `yaml:"macGroup" json:"macGroup"`
	DomainGroup  *string `yaml:"domainGroup" json:"domainGroup"`
}

type FirewallRuleSetRuleAddresses

type FirewallRuleSetRuleAddresses struct {
	Address     *FirewallRuleSetRuleAddressesAddress `json:"address"`
	AddressMask net.IPMask                           `yaml:"addressMask" json:"addressMask"`
	FQDN        *string                              `vyos:"fqdn" json:"fqdn"`
	GeoIP       FirewallRuleSetRuleGeoIP             `vyos:"geoip" yaml:"geoIP" json:"geoIP"`
	Group       FirewallRuleSetRuleAddressGroup      `json:"group"`
	MacAddress  net.HardwareAddr                     `yaml:"macAddress" json:"macAddress"`
	Ports       []ValueOrRange[string]               `vyos:"port,csv" json:"ports"`
}

type FirewallRuleSetRuleAddressesAddress

type FirewallRuleSetRuleAddressesAddress struct {
	Address ValueOrRange[IPAddr]
	Negated bool
}

func (FirewallRuleSetRuleAddressesAddress) JSONSchema

func (FirewallRuleSetRuleAddressesAddress) MarshalText

func (a FirewallRuleSetRuleAddressesAddress) MarshalText() ([]byte, error)

func (FirewallRuleSetRuleAddressesAddress) String

func (*FirewallRuleSetRuleAddressesAddress) UnmarshalYAML

func (a *FirewallRuleSetRuleAddressesAddress) UnmarshalYAML(node *yaml.Node) error

type FirewallRuleSetRuleConnectionStatus

type FirewallRuleSetRuleConnectionStatus struct {
	NAT FirewallRuleSetRuleConnectionStatusNAT `vyos:"nat" json:"nat"`
}

type FirewallRuleSetRuleConnectionStatusNAT

type FirewallRuleSetRuleConnectionStatusNAT struct {
	Destination bool `json:"destination"`
	Source      bool `json:"source"`
}

type FirewallRuleSetRuleFragment

type FirewallRuleSetRuleFragment struct {
	MatchFrag    bool `yaml:"matchFrag" json:"matchFrag"`
	MatchNonFrag bool `yaml:"matchNonFrag" json:"matchNonFrag"`
}

type FirewallRuleSetRuleGeoIP

type FirewallRuleSetRuleGeoIP struct {
	CountryCode  []string `yaml:"countryCode" json:"countryCode"`
	InverseMatch bool     `yaml:"inverseMatch" json:"inverseMatch"`
}

type FirewallRuleSetRuleICMP

type FirewallRuleSetRuleICMP struct {
	Code     *uint8  `json:"code"`
	Type     *uint8  `json:"type"`
	TypeName *string `yaml:"typeName" json:"typeName"`
}

type FirewallRuleSetRuleIPSec

type FirewallRuleSetRuleIPSec struct {
	MatchIPSec *bool `vyos:"match-ipsec" yaml:"matchIPSec" json:"matchIPSec"`
	MatchNone  *bool `yaml:"matchNone" json:"matchNone"`
}

type FirewallRuleSetRuleInterface

type FirewallRuleSetRuleInterface struct {
	InterfaceGroup *string `yaml:"interfaceGroup" json:"interfaceGroup"`
	InterfaceName  *string `yaml:"interfaceName" json:"interfaceName"`
}

type FirewallRuleSetRuleLimit

type FirewallRuleSetRuleLimit struct {
	Burst *uint32 `json:"burst"`
	Rate  *string `json:"rate"`
}

type FirewallRuleSetRuleRecent

type FirewallRuleSetRuleRecent struct {
	Count *uint8  `json:"count"`
	Time  *string `json:"time"`
}

type FirewallRuleSetRuleState

type FirewallRuleSetRuleState struct {
	Established *EnableDisable `json:"established"`
	Invalid     *EnableDisable `json:"invalid"`
	New         *EnableDisable `json:"new"`
	Related     *EnableDisable `json:"related"`
}

type FirewallRuleSetRuleTCP

type FirewallRuleSetRuleTCP struct {
	Flags FirewallRuleSetRuleTCPFlags `json:"flags"`
	MSS   *ValueOrRange[uint16]       `json:"mss"`
}

type FirewallRuleSetRuleTCPFlags

type FirewallRuleSetRuleTCPFlags struct {
	Ack bool                         `json:"ack"`
	Cwr bool                         `json:"cwr"`
	Ecn bool                         `json:"ecn"`
	Fin bool                         `json:"fin"`
	Psh bool                         `json:"psh"`
	Rst bool                         `json:"rst"`
	Syn bool                         `json:"syn"`
	Urg bool                         `json:"urg"`
	Not *FirewallRuleSetRuleTCPFlags `json:"not"`
}

type FirewallRuleSetRuleTTL

type FirewallRuleSetRuleTTL struct {
	Eq *uint8 `json:"eq"`
	Gt *uint8 `json:"gt"`
	Lt *uint8 `json:"lt"`
}

type FirewallRuleSetRuleTime

type FirewallRuleSetRuleTime struct {
	StartDate *string               `vyos:"startdate" yaml:"startDate" json:"startDate"`
	StartTime *string               `vyos:"starttime" yaml:"startTime" json:"startTime"`
	StopDate  *string               `vyos:"stopdate" yaml:"stopDate" json:"stopDate"`
	StopTime  *string               `vyos:"stoptime" yaml:"stopTime" json:"stopTime"`
	Weekday   *ValueOrRange[string] `json:"weekday"`
}

type FirewallStatePolicies

type FirewallStatePolicies struct {
	Established FirewallStatePolicy `json:"established"`
	Invalid     FirewallStatePolicy `json:"invalid"`
	Related     FirewallStatePolicy `json:"related"`
}

type FirewallStatePolicy

type FirewallStatePolicy struct {
	Action   *string        `json:"action"`
	Log      *EnableDisable `json:"log"`
	LogLevel *string        `json:"logLevel"`
}

type FirewallZone

type FirewallZone struct {
	DefaultAction      *string                        `vyos:"default-action"`
	Description        *string                        `json:"description"`
	EnableDefaultLog   bool                           `yaml:"enableDefaultLog" json:"enableDefaultLog"`
	From               map[string]FirewallZoneFrom    `json:"from"`
	Interfaces         []string                       `vyos:"interface" json:"interfaces"`
	IntraZoneFiltering FirewallZoneIntraZoneFiltering `yaml:"intraZoneFiltering" json:"intraZoneFiltering"`
	LocalZone          bool                           `yaml:"localZone" json:"localZone"`
}

type FirewallZoneFrom

type FirewallZoneFrom struct {
	Firewall FirewallAppliedRuleSets `json:"firewall"`
}

type FirewallZoneIntraZoneFiltering

type FirewallZoneIntraZoneFiltering struct {
	Action   *string                 `json:"action"`
	Firewall FirewallAppliedRuleSets `json:"firewall"`
}

type IPAddr

type IPAddr struct {
	netip.Addr
}

func (IPAddr) JSONSchema

func (IPAddr) JSONSchema() *jsonschema.Schema

type IPPrefix

type IPPrefix struct {
	netip.Prefix
}

func (IPPrefix) JSONSchema

func (IPPrefix) JSONSchema() *jsonschema.Schema

type Marshaler

type Marshaler interface {
	MarshalVyOS() (any, error)
}

type ValueOrRange

type ValueOrRange[T comparable] struct {
	Start T
	End   T
}

ValueOrRange is either a range or single value, if only Start is set

func (ValueOrRange[T]) JSONSchema

func (ValueOrRange[T]) JSONSchema() *jsonschema.Schema

func (ValueOrRange[T]) MarshalText

func (v ValueOrRange[T]) MarshalText() ([]byte, error)

func (ValueOrRange[T]) String

func (v ValueOrRange[T]) String() string

func (*ValueOrRange[T]) UnmarshalYAML

func (v *ValueOrRange[T]) UnmarshalYAML(node *yaml.Node) error

Jump to

Keyboard shortcuts

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