Documentation ¶
Index ¶
- Constants
- func Provider() terraform.ResourceProvider
- type DHCPSession
- func (s *DHCPSession) Apply(iface, formName, formValue string) error
- func (s *DHCPSession) CreateOrEdit(m *StaticMapping) error
- func (s *DHCPSession) CreateStaticMapping(m *StaticMapping) error
- func (s *DHCPSession) DeleteStaticMapping(m *StaticMapping) error
- func (s *DHCPSession) FindMappingByMAC(m *StaticMapping) (*StaticMapping, error)
- func (s *DHCPSession) GetAllInterfaceStaticMappings(iface string) ([]StaticMapping, error)
- func (s *DHCPSession) GetStaticFieldNames(node *html.Node, start int)
- func (s *DHCPSession) GetStaticMappingField(node *html.Node, f string) string
- func (s *DHCPSession) ReadStaticMapping(m *StaticMapping) error
- func (s *DHCPSession) UpdateStaticMapping(m *StaticMapping) error
- type DNSHostEntry
- type DNSSession
- func (s *DNSSession) Apply(formName, formValue string) error
- func (s *DNSSession) CreateHostOverride(h *DNSHostEntry) error
- func (s *DNSSession) CreateOrEdit(e *DNSHostEntry) error
- func (s *DNSSession) DeleteHostOverride(h *DNSHostEntry) error
- func (s *DNSSession) FindHostEntry(h *DNSHostEntry) (*DNSHostEntry, error)
- func (s *DNSSession) FindHostEntryByID(id int) (*DNSHostEntry, error)
- func (s *DNSSession) GetAllHostEntries() ([]DNSHostEntry, error)
- func (s *DNSSession) GetStaticFieldNames(node *html.Node, start int)
- func (s *DNSSession) GetStaticMappingField(node *html.Node, f string) string
- func (s *DNSSession) HostsMatch(e1, e2 *DNSHostEntry) bool
- func (s *DNSSession) ReadHostOverride(h *DNSHostEntry) error
- func (s *DNSSession) UpdateHostOverride(h *DNSHostEntry) error
- type OPNSession
- type ProviderConfiguration
- type StaticMapping
Constants ¶
const ( // DHCPStaticARP refers to the HTML table field for DHCP static map creation/edition DHCPStaticARP = "Static ARP" // DHCPMAC refers to the HTML table field for DHCP static map creation/edition DHCPMAC = "MAC address" // DHCPIP refers to the HTML table field for DHCP static map creation/edition DHCPIP = "IP address" // DHCPHostname refers to the HTML table field for DHCP static map creation/edition DHCPHostname = "Hostname" // DHCPDescription refers to the HTML table field for DHCP static map creation/edition DHCPDescription = "Description" )
const ( // DHCPServiceURI is the WebUI service URI DHCPServiceURI = "/services_dhcp.php" // DHCPServiceEditURI is the WebUI service edit URI DHCPServiceEditURI = "/services_dhcp_edit.php" )
const ( // ErrNoMappings is thrown when no mapping can be found ErrNoMappings = "unable to retrieve list of static mappings" // ErrMACExists is thrown when a mapping already exists for this MAC address ErrMACExists = "mapping for this MAC already exists" // ErrNoSuchMAC is thrown if no mapping can be found for the specific Interface/MAC couple ErrNoSuchMAC = "mapping doesn't exists for this MAC address" )
const ( // DNSHost refers to the HTML table field for DNS host entry creation/edition DNSHost = "Host" // DNSDomain refers to the HTML table field for DNS host entry creation/edition DNSDomain = "Domain" // DNSType refers to the HTML table field for DNS host entry creation/edition DNSType = "Type" // DNSValue refers to the HTML table field for DNS host entry creation/edition DNSValue = "Value" // DNSDescription refers to the HTML table field for DNS host entry creation/edition DNSDescription = "Description" )
const ( // DNSServiceURI is the WebUI service URI DNSServiceURI = "/services_unbound_overrides.php" // DNSServiceEditURI is the WebUI service edit URI DNSServiceEditURI = "/services_unbound_host_edit.php" )
const ( // ErrDNSNoEntries is thrown when no entry can be found ErrDNSNoEntries = "unable to retrieve list of DNS host overrides" // ErrDNSHostExists is thrown when an entry already exists for this host override ErrDNSHostExists = "DNS override for this host already exists" // ErrDNSNoSuchEntry is thrown if no host override entry can be found ErrDNSNoSuchEntry = "host override entry doesn't exists" )
const ( // KeyInterface corresponds to the associated resource schema key KeyInterface = "interface" // KeyMAC corresponds to the associated resource schema key KeyMAC = "mac" // KeyIP corresponds to the associated resource schema key KeyIP = "ipaddr" // KeyName corresponds to the associated resource schema key KeyName = "hostname" )
const ( // KeyDNSType corresponds to the associated resource schema key KeyDNSType = "type" // KeyDNSHost corresponds to the associated resource schema key KeyDNSHost = "host" // KeyDNSDomain corresponds to the associated resource schema key KeyDNSDomain = "domain" // KeyDNSIP corresponds to the associated resource schema key KeyDNSIP = "ip" )
const DHCPEntryStartingRow = 2
DHCPEntryStartingRow exposes the HTML row where static maps actually start from
const DNSEntryStartingRow = 2
DNSEntryStartingRow exposes the HTML row where static maps actually start from
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DHCPSession ¶ added in v0.2.0
type DHCPSession struct { OPN *OPNSession Fields []string }
DHCPSession abstracts OPNSense DHCP Interface
func (*DHCPSession) Apply ¶ added in v0.2.0
func (s *DHCPSession) Apply(iface, formName, formValue string) error
Apply validates the configuration for a given interface and reload DHCP server
func (*DHCPSession) CreateOrEdit ¶ added in v0.2.0
func (s *DHCPSession) CreateOrEdit(m *StaticMapping) error
CreateOrEdit creates or edit a static mapping
func (*DHCPSession) CreateStaticMapping ¶ added in v0.2.0
func (s *DHCPSession) CreateStaticMapping(m *StaticMapping) error
CreateStaticMapping creates a new static lease
func (*DHCPSession) DeleteStaticMapping ¶ added in v0.2.0
func (s *DHCPSession) DeleteStaticMapping(m *StaticMapping) error
DeleteStaticMapping destroy an existing static mapping
func (*DHCPSession) FindMappingByMAC ¶ added in v0.2.0
func (s *DHCPSession) FindMappingByMAC(m *StaticMapping) (*StaticMapping, error)
FindMappingByMAC retrieves all entries for a given interface and select the one that matches
func (*DHCPSession) GetAllInterfaceStaticMappings ¶ added in v0.2.0
func (s *DHCPSession) GetAllInterfaceStaticMappings(iface string) ([]StaticMapping, error)
GetAllInterfaceStaticMappings retrieves the list of all configured static mappings for a given interface
func (*DHCPSession) GetStaticFieldNames ¶ added in v0.2.0
func (s *DHCPSession) GetStaticFieldNames(node *html.Node, start int)
GetStaticFieldNames extracts the HTML page leases headers for creation/edition
func (*DHCPSession) GetStaticMappingField ¶ added in v0.2.0
func (s *DHCPSession) GetStaticMappingField(node *html.Node, f string) string
GetStaticMappingField extracts a given DHCP mapping from OPNsense DHCP interface web page
func (*DHCPSession) ReadStaticMapping ¶ added in v0.2.0
func (s *DHCPSession) ReadStaticMapping(m *StaticMapping) error
ReadStaticMapping retrieves mapping information for a specified Interface/MAC couple
func (*DHCPSession) UpdateStaticMapping ¶ added in v0.2.0
func (s *DHCPSession) UpdateStaticMapping(m *StaticMapping) error
UpdateStaticMapping modifies an already existing static mapping
type DNSHostEntry ¶ added in v0.3.0
DNSHostEntry abstracts a DNS Host override
type DNSSession ¶ added in v0.3.0
type DNSSession struct { OPN *OPNSession Fields []string }
DNSSession abstracts OPNSense UnboundDNS Overrides
func (*DNSSession) Apply ¶ added in v0.3.0
func (s *DNSSession) Apply(formName, formValue string) error
Apply validates the configuration and reload DNS server
func (*DNSSession) CreateHostOverride ¶ added in v0.3.0
func (s *DNSSession) CreateHostOverride(h *DNSHostEntry) error
CreateHostOverride creates a new DNS host override entry
func (*DNSSession) CreateOrEdit ¶ added in v0.3.0
func (s *DNSSession) CreateOrEdit(e *DNSHostEntry) error
CreateOrEdit creates or edit an host override entry
func (*DNSSession) DeleteHostOverride ¶ added in v0.3.0
func (s *DNSSession) DeleteHostOverride(h *DNSHostEntry) error
DeleteHostOverride destroy an existing DNS host entry
func (*DNSSession) FindHostEntry ¶ added in v0.3.0
func (s *DNSSession) FindHostEntry(h *DNSHostEntry) (*DNSHostEntry, error)
FindHostEntry retrieves all entries select the one that matches
func (*DNSSession) FindHostEntryByID ¶ added in v0.3.0
func (s *DNSSession) FindHostEntryByID(id int) (*DNSHostEntry, error)
FindHostEntryByID retrieves all entries select the one that matches the ID
func (*DNSSession) GetAllHostEntries ¶ added in v0.3.0
func (s *DNSSession) GetAllHostEntries() ([]DNSHostEntry, error)
GetAllHostEntries retrieves the list of all configured DNS host overrides
func (*DNSSession) GetStaticFieldNames ¶ added in v0.3.0
func (s *DNSSession) GetStaticFieldNames(node *html.Node, start int)
GetStaticFieldNames extracts the HTML page host overrides headers for creation/edition
func (*DNSSession) GetStaticMappingField ¶ added in v0.3.0
func (s *DNSSession) GetStaticMappingField(node *html.Node, f string) string
GetStaticMappingField extracts a given DNS host override entry from OPNsense DNS overrides web page
func (*DNSSession) HostsMatch ¶ added in v0.3.0
func (s *DNSSession) HostsMatch(e1, e2 *DNSHostEntry) bool
HostsMatch compares if 2 host entries are alike
func (*DNSSession) ReadHostOverride ¶ added in v0.3.0
func (s *DNSSession) ReadHostOverride(h *DNSHostEntry) error
ReadHostOverride retrieves DNS information for a specified host
func (*DNSSession) UpdateHostOverride ¶ added in v0.3.0
func (s *DNSSession) UpdateHostOverride(h *DNSHostEntry) error
UpdateHostOverride modifies an already existing host override
type OPNSession ¶ added in v0.3.0
type OPNSession struct { RootURI string Session *requests.Request Cookies []*http.Cookie CSRF string }
OPNSession abstracts OPNSense connection
func (*OPNSession) Authenticate ¶ added in v0.3.0
func (s *OPNSession) Authenticate(rootURI, user, password string) error
Authenticate allows authentication to OPNsense main web page
func (*OPNSession) Error ¶ added in v0.3.0
func (s *OPNSession) Error(err string) error
Error throws custom errors
func (*OPNSession) IsAuthenticated ¶ added in v0.3.0
func (s *OPNSession) IsAuthenticated() error
IsAuthenticated throws an error if no session has been initialized
type ProviderConfiguration ¶
type ProviderConfiguration struct { OPN *OPNSession DHCP *DHCPSession DNS *DNSSession Mutex *sync.Mutex Cond *sync.Cond }
ProviderConfiguration struct for opnsense-provider