Documentation
¶
Overview ¶
Package netconf groups functionality to configure networking related resources.
Index ¶
- Constants
- func NewDroptailerServiceApplier(kb KnowledgeBase, v net.Validator) (net.Applier, error)
- func NewFirewallControllerServiceApplier(kb KnowledgeBase, v net.Validator) (net.Applier, error)
- func NewFrrConfigApplier(kind BareMetalType, kb KnowledgeBase, tmpFile string) net.Applier
- func NewHostnameApplier(kb KnowledgeBase, tmpFile string) net.Applier
- func NewHostsApplier(kb KnowledgeBase, tmpFile string) net.Applier
- func NewNftablesConfigApplier(kb KnowledgeBase, validator net.Validator, enableDNSProxy bool) net.Applier
- func NewNftablesExporterServiceApplier(kb KnowledgeBase, v net.Validator) (net.Applier, error)
- func NewNodeExporterServiceApplier(kb KnowledgeBase, v net.Validator) (net.Applier, error)
- func NewSuricataConfigApplier(kb KnowledgeBase, tmpFile string) (net.Applier, error)
- func NewSuricataDefaultsApplier(kb KnowledgeBase, tmpFile string) (net.Applier, error)
- func NewSuricataUpdateServiceApplier(kb KnowledgeBase, v net.Validator) (net.Applier, error)
- func NewSystemdLinkApplier(kind BareMetalType, machineUUID string, nicIndex int, nic NIC, tmpFile string, ...) net.Applier
- func NewSystemdNetworkdApplier(tmpFile string, data interface{}) net.Applier
- type AccessPolicy
- type AddrSpec
- type AddressFamily
- type BareMetalType
- type Bridge
- type ChronyServiceEnabler
- type CommonConfigurator
- type CommonFRRData
- type Configurator
- type DNAT
- type DroptailerData
- type EVPNIface
- type FRRValidator
- type FirewallConfigurator
- type FirewallControllerData
- type FirewallFRRData
- type HostnameData
- type HostnameValidator
- type HostsData
- type HostsValidator
- type IPPrefixList
- type Identity
- type IfacesApplier
- type IfacesData
- type ImportSettings
- type KnowledgeBase
- type Loopback
- type MachineConfigurator
- type MachineFRRData
- type NIC
- type NftablesData
- type NftablesExporterData
- type NftablesReloader
- type NftablesValidator
- type NodeExporterData
- type RouteMap
- type SNAT
- type SVI
- type ServiceValidator
- type SuricataConfigData
- type SuricataConfigValidator
- type SuricataDefaultsData
- type SuricataDefaultsValidator
- type SuricataUpdateData
- type SystemdCommonData
- type SystemdLinkData
- type SystemdNetworkdValidator
- type SystemdValidator
- type VRF
- type VXLAN
Constants ¶
const ( // FileModeSystemd represents a file mode that allows systemd to read e.g. /etc/systemd/network files. FileModeSystemd = 0644 // FileModeSixFourFour represents file mode 0644 FileModeSixFourFour = 0644 // FileModeDefault represents the default file mode sufficient e.g. to /etc/network/interfaces or /etc/frr.conf. FileModeDefault = 0600 // Firewall defines the bare metal server to function as firewall. Firewall BareMetalType = iota // Machine defines the bare metal server to function as machine. Machine // SystemdUnitPath is the path where systemd units will be generated. SystemdUnitPath = "/etc/systemd/system/" )
const ( // FRRVersion holds a string that is used in the frr.conf to define the FRR version. FRRVersion = "7.5" // TplFirewallFRR defines the name of the template to render FRR configuration to a 'firewall'. TplFirewallFRR = "frr.firewall.tpl" // TplMachineFRR defines the name of the template to render FRR configuration to a 'machine'. TplMachineFRR = "frr.machine.tpl" // IPPrefixListSeqSeed specifies the initial value for prefix lists sequence number. IPPrefixListSeqSeed = 100 // IPPrefixListNoExportSuffix defines the suffix to use for private IP ranges that must not be exported. IPPrefixListNoExportSuffix = "-no-export" // RouteMapOrderSeed defines the initial value for route-map order. RouteMapOrderSeed = 10 // AddressFamilyIPv4 is the name for this address family for the routing daemon. AddressFamilyIPv4 = "ip" // AddressFamilyIPv6 is the name for this address family for the routing daemon. AddressFamilyIPv6 = "ipv6" )
const ( // IPv4ZeroCIDR is the CIDR block for the whole IPv4 address space IPv4ZeroCIDR = "0.0.0.0/0" // IPv6ZeroCIDR is the CIDR block for the whole IPv6 address space IPv6ZeroCIDR = "::/0" // Permit defines an access policy that allows access. Permit AccessPolicy = iota // Deny defines an access policy that forbids access. Deny )
const TplHostname = "hostname.tpl"
TplHostname defines the name of the template to render /etc/hostname.
const TplHosts = "hosts.tpl"
TplHosts defines the name of the template to render hosts file.
const (
// TplNftables defines the name of the template to render nftables configuration.
TplNftables = "nftrules.tpl"
)
const TplSuricataConfig = "suricata_config.yaml.tpl"
TplSuricataConfig is the name of the template for the suricata configuration.
const (
// VLANOffset defines a number to start with when creating new VLAN IDs.
VLANOffset = 1000
)
Variables ¶
This section is empty.
Functions ¶
func NewDroptailerServiceApplier ¶
NewDroptailerServiceApplier constructs a new instance of this type.
func NewFirewallControllerServiceApplier ¶
NewFirewallControllerServiceApplier constructs a new instance of this type.
func NewFrrConfigApplier ¶
func NewFrrConfigApplier(kind BareMetalType, kb KnowledgeBase, tmpFile string) net.Applier
NewFrrConfigApplier constructs a new Applier of the given type of Bare Metal.
func NewHostnameApplier ¶
func NewHostnameApplier(kb KnowledgeBase, tmpFile string) net.Applier
NewHostnameApplier creates a new Applier to render hostname.
func NewHostsApplier ¶
func NewHostsApplier(kb KnowledgeBase, tmpFile string) net.Applier
NewHostsApplier creates a new hosts applier.
func NewNftablesConfigApplier ¶
func NewNftablesConfigApplier(kb KnowledgeBase, validator net.Validator, enableDNSProxy bool) net.Applier
NewNftablesConfigApplier constructs a new instance of this type.
func NewNftablesExporterServiceApplier ¶
NewNftablesExporterServiceApplier constructs a new instance of this type.
func NewNodeExporterServiceApplier ¶
NewNodeExporterServiceApplier constructs a new instance of this type.
func NewSuricataConfigApplier ¶
func NewSuricataConfigApplier(kb KnowledgeBase, tmpFile string) (net.Applier, error)
NewSuricataConfigApplier constructs a new instance of this type.
func NewSuricataDefaultsApplier ¶
func NewSuricataDefaultsApplier(kb KnowledgeBase, tmpFile string) (net.Applier, error)
NewSuricataDefaultsApplier constructs a new instance of this type.
func NewSuricataUpdateServiceApplier ¶
NewSuricataUpdateServiceApplier constructs a new instance of this type.
func NewSystemdLinkApplier ¶
func NewSystemdLinkApplier(kind BareMetalType, machineUUID string, nicIndex int, nic NIC, tmpFile string, evpnIfaces []EVPNIface) net.Applier
NewSystemdLinkApplier creates a new Applier to configure systemd.link.
func NewSystemdNetworkdApplier ¶
NewSystemdNetworkdApplier creates a new Applier to configure systemd.network.
Types ¶
type AccessPolicy ¶
type AccessPolicy int
AccessPolicy is a type that represents a policy to manage access roles.
func (AccessPolicy) String ¶
func (p AccessPolicy) String() string
type AddressFamily ¶
type AddressFamily string
AddressFamily is the address family for the routing daemon.
type BareMetalType ¶
type BareMetalType int
BareMetalType defines the type of configuration to apply.
type ChronyServiceEnabler ¶
type ChronyServiceEnabler struct {
VRF string
}
ChronyServiceEnabler can enable chrony systemd service for the given VRF.
func NewChronyServiceEnabler ¶
func NewChronyServiceEnabler(kb KnowledgeBase) (ChronyServiceEnabler, error)
NewChronyServiceEnabler constructs a new instance of this type.
func (ChronyServiceEnabler) Enable ¶
func (c ChronyServiceEnabler) Enable() error
Enable enables chrony systemd service for the given VRF to be started after boot.
type CommonConfigurator ¶
type CommonConfigurator struct {
Kb KnowledgeBase
}
CommonConfigurator contains information that is common to all configurators.
type CommonFRRData ¶
type CommonFRRData struct {
ASN int64
Comment string
FRRVersion string
Hostname string
RouterID string
}
CommonFRRData contains attributes that are common to FRR configuration of all kind of bare metal servers.
type Configurator ¶
type Configurator interface {
Configure()
}
Configurator is an interface to configure bare metal servers.
func NewConfigurator ¶
func NewConfigurator(kind BareMetalType, kb KnowledgeBase) Configurator
NewConfigurator creates a new configurator.
type DroptailerData ¶
DroptailerData contains the data to render the droptailer service template.
type EVPNIface ¶
EVPNIface represents the information required to render EVPN interfaces configuration.
type FRRValidator ¶
type FRRValidator struct {
// contains filtered or unexported fields
}
FRRValidator validates the frr.conf to apply.
func (FRRValidator) Validate ¶
func (v FRRValidator) Validate() error
Validate can be used to run validation on FRR configuration using vtysh.
type FirewallConfigurator ¶
type FirewallConfigurator struct {
CommonConfigurator
EnableDNSProxy bool
}
FirewallConfigurator is a configurator that configures a bare metal server as 'firewall'.
func (FirewallConfigurator) Configure ¶
func (configurator FirewallConfigurator) Configure()
Configure applies configuration to a bare metal server to function as 'firewall'.
func (FirewallConfigurator) ConfugureNftables ¶ added in v0.7.0
func (configurator FirewallConfigurator) ConfugureNftables()
type FirewallControllerData ¶
type FirewallControllerData struct {
Comment string
DefaultRouteVrf string
ServiceIP string
PrivateVrfID int64
}
FirewallControllerData contains the data to render the firewall-controller service template.
type FirewallFRRData ¶
type FirewallFRRData struct {
CommonFRRData
VRFs []VRF
}
FirewallFRRData contains attributes required to render frr.conf of bare metal servers that function as 'firewall'.
type HostnameData ¶
type HostnameData struct {
Comment, Hostname string
}
HostnameData contains attributes to render hostname file.
type HostnameValidator ¶
type HostnameValidator struct {
// contains filtered or unexported fields
}
HostnameValidator validates hostname changes.
func (HostnameValidator) Validate ¶
func (v HostnameValidator) Validate() error
Validate validates hostname rendering.
type HostsValidator ¶
type HostsValidator struct {
// contains filtered or unexported fields
}
HostsValidator validates hosts file.
func (HostsValidator) Validate ¶
func (v HostsValidator) Validate() error
Validate validates hosts file.
type IPPrefixList ¶
type IPPrefixList struct {
Name string
Spec string
AddressFamily AddressFamily
// SourceVRF specifies from which VRF the given prefix list should be imported
SourceVRF string
}
IPPrefixList represents 'ip prefix-list' filtering mechanism to be used in combination with route-maps.
type IfacesApplier ¶
type IfacesApplier struct {
// contains filtered or unexported fields
}
IfacesApplier applies interfaces configuration.
func NewIfacesApplier ¶
func NewIfacesApplier(kind BareMetalType, kb KnowledgeBase) IfacesApplier
NewIfacesApplier constructs a new instance of this type.
func (*IfacesApplier) Apply ¶
func (a *IfacesApplier) Apply()
Apply applies the interface configuration with systemd-networkd.
type IfacesData ¶
IfacesData contains attributes required to render network interfaces configuration of a bare metal server.
type ImportSettings ¶ added in v0.7.1
type ImportSettings struct {
ImportPrefixes []importPrefix
ImportPrefixesNoExport []importPrefix
}
type KnowledgeBase ¶
type KnowledgeBase struct {
Hostname string `yaml:"hostname"`
Ipaddress string `yaml:"ipaddress"`
Asn string `yaml:"asn"`
Networks []models.V1MachineNetwork `yaml:"networks"`
Machineuuid string `yaml:"machineuuid"`
Sshpublickey string `yaml:"sshpublickey"`
Password string `yaml:"password"`
Devmode bool `yaml:"devmode"`
Console string `yaml:"console"`
Nics []NIC `yaml:"nics"`
}
KnowledgeBase was generated with: https://mengzhuo.github.io/yaml-to-go/. It represents the input yaml that is needed to render network configuration files.
func NewKnowledgeBase ¶
func NewKnowledgeBase(path string) KnowledgeBase
NewKnowledgeBase creates a new instance of this type.
func (KnowledgeBase) CollectIPs ¶
func (kb KnowledgeBase) CollectIPs(types ...string) []string
CollectIPs collects IPs of the given networks.
func (KnowledgeBase) GetDefaultRouteNetwork ¶ added in v0.7.1
func (kb KnowledgeBase) GetDefaultRouteNetwork() *models.V1MachineNetwork
func (KnowledgeBase) GetNetworks ¶
func (kb KnowledgeBase) GetNetworks(types ...string) []models.V1MachineNetwork
GetNetworks returns all networks present.
func (KnowledgeBase) Validate ¶
func (kb KnowledgeBase) Validate(kind BareMetalType) error
Validate validates the containing information depending on the demands of the bare metal type.
type MachineConfigurator ¶
type MachineConfigurator struct {
CommonConfigurator
}
MachineConfigurator is a configurator that configures a bare metal server as 'machine'.
func (MachineConfigurator) Configure ¶
func (configurator MachineConfigurator) Configure()
Configure applies configuration to a bare metal server to function as 'machine'.
type MachineFRRData ¶
type MachineFRRData struct {
CommonFRRData
}
MachineFRRData contains attributes required to render frr.conf of bare metal servers that function as 'machine'.
type NIC ¶
type NIC struct {
Mac string `yaml:"mac"`
Name string `yaml:"name"`
Neighbors []struct {
Mac string `yaml:"mac"`
Name interface{} `yaml:"name"`
Neighbors []interface{} `yaml:"neighbors"`
} `yaml:"neighbors"`
}
NIC is a representation of network interfaces attributes.
type NftablesData ¶
NftablesData represents the information required to render nftables configuration.
type NftablesExporterData ¶
NftablesExporterData contains the data to render the nftables_exporter service template.
type NftablesReloader ¶ added in v0.8.0
type NftablesReloader struct{}
func (*NftablesReloader) Reload ¶ added in v0.8.0
func (*NftablesReloader) Reload() error
type NftablesValidator ¶
type NftablesValidator struct {
// contains filtered or unexported fields
}
NftablesValidator can validate configuration for nftables rules.
func (NftablesValidator) Validate ¶
func (v NftablesValidator) Validate() error
Validate validates network interfaces configuration.
type NodeExporterData ¶
NodeExporterData contains the data to render the node_exporter service template.
type ServiceValidator ¶
type ServiceValidator struct {
// contains filtered or unexported fields
}
ServiceValidator holds information for systemd service validation.
func (ServiceValidator) Validate ¶
func (v ServiceValidator) Validate() error
Validate validates the service file.
type SuricataConfigData ¶
SuricataConfigData represents the information required to render suricata configuration.
type SuricataConfigValidator ¶
type SuricataConfigValidator struct {
// contains filtered or unexported fields
}
SuricataConfigValidator can validate configuration for suricata.
func (SuricataConfigValidator) Validate ¶
func (v SuricataConfigValidator) Validate() error
Validate validates suricata configuration.
type SuricataDefaultsData ¶
SuricataDefaultsData represents the information required to render suricata defaults.
type SuricataDefaultsValidator ¶
type SuricataDefaultsValidator struct {
// contains filtered or unexported fields
}
SuricataDefaultsValidator can validate defaults for suricata.
func (SuricataDefaultsValidator) Validate ¶
func (v SuricataDefaultsValidator) Validate() error
Validate validates suricata defaults.
type SuricataUpdateData ¶
SuricataUpdateData contains the data to render the suricata-update service template.
type SystemdCommonData ¶
SystemdCommonData contains attributes common to systemd.network and systemd.link files.
type SystemdLinkData ¶
type SystemdLinkData struct {
SystemdCommonData
MAC string
MTU int
EVPNIfaces []EVPNIface
}
SystemdLinkData contains attributes required to render systemd.link files.
type SystemdNetworkdValidator ¶
type SystemdNetworkdValidator struct {
// contains filtered or unexported fields
}
SystemdNetworkdValidator defines the base type of an systemd-networkd validator.
func (SystemdNetworkdValidator) Validate ¶
func (v SystemdNetworkdValidator) Validate() error
Validate network interfaces configuration done with systemd-networkd. Assumes systemd-networkd is installed.
type SystemdValidator ¶
type SystemdValidator struct {
// contains filtered or unexported fields
}
SystemdValidator validates systemd.network and system.link files.
func (SystemdValidator) Validate ¶
func (v SystemdValidator) Validate() error
Validate validates systemd.network and systemd.link files.