pfsenseapi

package
v0.0.0-...-6f6f346 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package pfsenseapi provides the api client for calling the pfsense api

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIConfiguration

type APIConfiguration struct {
	Enable            string `json:"enable"`
	Persist           string `json:"persist"`
	AllowedInterfaces string `json:"allowed_interfaces"`
	AuthMode          string `json:"authmode"`
	ContentType       string `json:"content_type"`
	JwtExp            string `json:"jwt_exp"`
	Keyhash           string `json:"keyhash"`
	Keybytes          string `json:"keybytes"`
	Keys              string `json:"keys"`
	AccessList        string `json:"access_list"`
}

APIConfiguration represents the API configuration

type APIConfigurationRequest

type APIConfigurationRequest struct {
	AccessList            []string            `json:"access_list"`
	AllowOptions          bool                `json:"allow_options"`
	AuthMode              string              `json:"authmode"`
	AllowedInterfaces     []string            `json:"allowed_interfaces"`
	CustomHeaders         []map[string]string `json:"custom_headers"`
	Enable                bool                `json:"enable"`
	EnableLoginProtection bool                `json:"enable_login_protection"`
	LogSuccessfulAuth     bool                `json:"log_successful_auth"`
	Hasync                bool                `json:"hasync"`
	HasyncHosts           []string            `json:"hasync_hosts"`
	HasyncPassword        string              `json:"hasync_password"`
	HasyncUsername        string              `json:"hasync_username"`
	JwtExp                int                 `json:"jwt_exp"`
	Keybytes              int                 `json:"keybytes"`
	Keyhash               string              `json:"keyhash"`
	Persist               bool                `json:"persist"`
	Readonly              bool                `json:"readonly"`
}

APIConfigurationRequest is the request used to update the API configuration

type APIVersion

type APIVersion struct {
	CurrentVersion  string `json:"current_version"`
	LatestVersion   string `json:"latest_version"`
	UpdateAvailable bool   `json:"update_available"`
}

APIVersion represents the API Versions.

type ArpEntry

type ArpEntry struct {
	Ip        string `json:"ip"`
	Mac       string `json:"mac"`
	Interface string `json:"interface"`
	Status    string `json:"status"`
	Linktype  string `json:"linktype"`
}

ArpEntry represents a single arp entry in the arp table.

type CACertificate

type CACertificate struct {
	Refid        string `json:"refid"`
	Descr        string `json:"descr"`
	Trust        string `json:"trust"`
	Randomserial string `json:"randomserial"`
	Crt          string `json:"crt"`
	Prv          string `json:"prv"`
	Serial       string `json:"serial"`
}

CACertificate represents a single CACertificate.

type CACertificateRequest

type CACertificateRequest struct {
	Caref                string `json:"caref"`
	Crt                  string `json:"crt"`
	Descr                string `json:"descr"`
	DigestAlg            string `json:"digest_alg"`
	DnCity               string `json:"dn_city"`
	DnCommonname         string `json:"dn_commonname"`
	DnCountry            string `json:"dn_country"`
	DnOrganization       string `json:"dn_organization"`
	DnOrganizationalunit string `json:"dn_organizationalunit"`
	DnState              string `json:"dn_state"`
	Ecname               string `json:"ecname"`
	Keylen               int    `json:"keylen"`
	Keytype              string `json:"keytype"`
	Lifetime             int    `json:"lifetime"`
	Method               string `json:"method"`
	Prv                  string `json:"prv"`
	RandomSerial         bool   `json:"randomserial"`
	Serial               int    `json:"serial"`
	Trust                bool   `json:"trust"`
}

type Certificate

type Certificate struct {
	Refid string `json:"refid"`
	Descr string `json:"descr"`
	Prv   string `json:"prv"`
	Crt   string `json:"crt"`
	Caref string `json:"caref"`
}

Certificate represents a single installed SSL/TLS certificate.

type Client

type Client struct {
	Cfg Config

	System    *SystemService
	Token     *TokenService
	DHCP      *DHCPService
	Status    *StatusService
	Interface *InterfaceService
	Routing   *RoutingService
	Firewall  *FirewallService
	User      *UserService
	// contains filtered or unexported fields
}

Client provides client Methods

func NewClient

func NewClient(config Config) *Client

NewClient constructs a new Client

func NewClientWithJWTAuth

func NewClientWithJWTAuth(host, user, password string) *Client

NewClientWithJWTAuth constructs a new Client using JWT token authentication. The username and password provided here will be used to generate JWT tokens for authentication.

func NewClientWithLocalAuth

func NewClientWithLocalAuth(host, user, password string) *Client

NewClientWithLocalAuth constructs a new Client using Local username/password authentication

func NewClientWithNoAuth

func NewClientWithNoAuth(host string) *Client

NewClientWithNoAuth constructs a new Client using defaults for everything except the host

func NewClientWithTokenAuth

func NewClientWithTokenAuth(host, apiClientID, apiClientToken string) *Client

NewClientWithTokenAuth constructs a new Client using token authentication

func (*Client) WithLogger

func (c *Client) WithLogger(l *zap.Logger) *Client

type Config

type Config struct {
	Host string

	LocalAuthEnabled bool
	User             string
	Password         string

	JWTAuthEnabled bool
	JWTToken       string

	TokenAuthEnabled bool
	ApiClientID      string
	ApiClientToken   string

	SkipTLS bool
	Timeout time.Duration
}

Config provides configuration for the client. These values are only read in when NewClient is called.

type DHCPLease

type DHCPLease struct {
	Ip                  string `json:"ip"`
	Type                string `json:"type"`
	Mac                 string `json:"mac"`
	If                  string `json:"if"`
	Starts              string `json:"starts"`
	Ends                string `json:"ends"`
	Hostname            string `json:"hostname"`
	Descr               string `json:"descr"`
	Online              bool   `json:"online"`
	StaticmapArrayIndex int    `json:"staticmap_array_index"`
	State               string `json:"state"`
}

DHCPLease represents a single DHCP lease

type DHCPService

type DHCPService service

DHCPService provides DHCP API methods

func (DHCPService) CreateStaticMapping

func (s DHCPService) CreateStaticMapping(ctx context.Context, newStaticMapping DHCPStaticMappingRequest) error

CreateStaticMapping creates a new DHCP static mapping.

func (DHCPService) DeleteStaticMapping

func (s DHCPService) DeleteStaticMapping(ctx context.Context, mappingInterface string, idToDelete int) error

DeleteStaticMapping deletes a DHCP static mapping.

func (DHCPService) ListLeases

func (s DHCPService) ListLeases(ctx context.Context) ([]*DHCPLease, error)

ListLeases returns a list of the DHCP leases

func (DHCPService) ListStaticMappings

func (s DHCPService) ListStaticMappings(ctx context.Context, netInterface string) ([]*DHCPStaticMapping, error)

ListStaticMappings returns a list of the static reservations for the interface provided. The interface can be either the interface's descriptive name, the pfSense interface ID (e.g. wan, lan, optx), or the real interface ID (e.g. igb0).

func (DHCPService) UpdateStaticMapping

func (s DHCPService) UpdateStaticMapping(ctx context.Context, idToUpdate int, mappingData DHCPStaticMappingRequest) error

UpdateStaticMapping modifies a DHCP static mapping.

type DHCPStaticMapping

type DHCPStaticMapping struct {
	ID                     int    `json:"id"`
	Mac                    string `json:"mac"`
	Cid                    string `json:"cid"`
	IPaddr                 string `json:"ipaddr"`
	Hostname               string `json:"hostname"`
	Descr                  string `json:"descr"`
	Filename               string `json:"filename"`
	Rootpath               string `json:"rootpath"`
	DefaultLeaseTime       string `json:"defaultleasetime"`
	MaxLeaseTime           string `json:"maxleasetime"`
	Gateway                string `json:"gateway"`
	Domain                 string `json:"domain"`
	DomainSearchList       string `json:"domainsearchlist"`
	DDNSDomain             string `json:"ddnsdomain"`
	DDNSDomainPrimary      string `json:"ddnsdomainprimary"`
	DDNSDomainSecondary    string `json:"ddnsdomainsecondary"`
	DDNSDomainkeyName      string `json:"ddnsdomainkeyname"`
	DDNSDomainkeyAlgorithm string `json:"ddnsdomainkeyalgorithm"`
	DDNSDomainkey          string `json:"ddnsdomainkey"`
	TFTP                   string `json:"tftp"`
	LDAP                   string `json:"ldap"`
	NextServer             string `json:"nextserver"`
	Filename32             string `json:"filename32"`
	Filename64             string `json:"filename64"`
	Filename32Arm          string `json:"filename32arm"`
	Filename64Arm          string `json:"filename64arm"`
	NumberOptions          string `json:"numberoptions"`
}

DHCPStaticMapping represents a single DHCP static reservation

type DHCPStaticMappingRequest

type DHCPStaticMappingRequest struct {
	ArpTableStaticEntry bool     `json:"arp_table_static_entry"`
	Cid                 string   `json:"cid"`
	Descr               string   `json:"descr"`
	DNSServer           []string `json:"dnsserver"`
	Domain              string   `json:"domain"`
	DomainSearchList    []string `json:"domainsearchlist"`
	Gateway             string   `json:"gateway"`
	Hostname            string   `json:"hostname"`
	Interface           string   `json:"interface"`
	Ipaddr              string   `json:"ipaddr"`
	Mac                 string   `json:"mac"`
}

DHCPStaticMappingRequest represents a single DHCP static reservation. This type is used for updating or creating a new static reservation.

type DNSConfiguration

type DNSConfiguration struct {
	Dnsserver        []string `json:"dnsserver"`
	Dnsallowoverride bool     `json:"dnsallowoverride"`
	Dnslocalhost     bool     `json:"dnslocalhost"`
}

DNSConfiguration represents the system DNS configuration.

type DefaultGatewayRequest

type DefaultGatewayRequest struct {
	DefaultGW4 string `json:"defaultgw4"`
	DefaultGW6 string `json:"defaultgw6"`
	Apply      bool   `json:"apply"`
}

type EmailNotification

type EmailNotification struct {
	Ipaddress               string `json:"ipaddress"`
	Port                    string `json:"port"`
	Sslvalidate             string `json:"sslvalidate"`
	Timeout                 string `json:"timeout"`
	Notifyemailaddress      string `json:"notifyemailaddress"`
	Username                string `json:"username"`
	Password                string `json:"password"`
	AuthenticationMechanism string `json:"authentication_mechanism"`
	Fromaddress             string `json:"fromaddress"`
	Disable                 string `json:"disable"`
}

EmailNotification represents the email notification configuration.

type EmailNotificationRequest

type EmailNotificationRequest struct {
	AuthenticationMechanism string `json:"authentication_mechanism"`
	Disabled                bool   `json:"disabled"`
	FromAddress             string `json:"fromaddress"`
	Ipaddress               string `json:"ipaddress"`
	Notifyemailaddress      string `json:"notifyemailaddress"`
	Password                string `json:"password"`
	Port                    int    `json:"port"`
	Ssl                     bool   `json:"ssl"`
	SslValidate             bool   `json:"sslvalidate"`
	Timeout                 int    `json:"timeout"`
	Username                string `json:"username"`
}

type ErrorDefinition

type ErrorDefinition struct {
	Status  string `json:"status"`
	Code    int    `json:"code"`
	Return  int    `json:"return"`
	Message string `json:"message"`
}

ErrorDefinition represents a single error definition.

type FirewallAlias

type FirewallAlias struct {
	Name    string `json:"name"`
	Type    string `json:"type"`
	Address string `json:"address"`
	Descr   string `json:"descr"`
	Detail  string `json:"detail"`
}

FirewallAlias represents a single firewall alias

type FirewallAliasRequest

type FirewallAliasRequest struct {
	Address []string `json:"address"`
	Descr   string   `json:"descr"`
	Detail  []string `json:"detail"`
	Name    string   `json:"name"`
	Type    string   `json:"type"`
}

type FirewallRule

type FirewallRule struct {
	Id           string            `json:"id"`
	Tracker      string            `json:"tracker"`
	Type         string            `json:"type"`
	Interface    string            `json:"interface"`
	Ipprotocol   string            `json:"ipprotocol"`
	Tag          string            `json:"tag"`
	Tagged       string            `json:"tagged"`
	Max          string            `json:"max"`
	MaxSrcNodes  string            `json:"max-src-nodes"`
	MaxSrcConn   string            `json:"max-src-conn"`
	MaxSrcStates string            `json:"max-src-states"`
	Statetimeout string            `json:"statetimeout"`
	Statetype    string            `json:"statetype"`
	Os           string            `json:"os"`
	Source       map[string]string `json:"source"`
	Destination  map[string]string `json:"destination"`
	Descr        string            `json:"descr"`
	Updated      struct {
		Time     string `json:"time"`
		Username string `json:"username"`
	} `json:"updated"`
	Created struct {
		Time     string `json:"time"`
		Username string `json:"username"`
	} `json:"created"`
}

type FirewallRuleRequest

type FirewallRuleRequest struct {
	AckQueue     string   `json:"ackqueue"`
	DefaultQueue string   `json:"defaultqueue"`
	Descr        string   `json:"descr"`
	Direction    string   `json:"direction"`
	Disabled     bool     `json:"disabled"`
	Dnpipe       string   `json:"dnpipe"`
	Dst          string   `json:"dst"`
	DstPort      string   `json:"dstport"`
	Floating     bool     `json:"floating"`
	Gateway      string   `json:"gateway"`
	IcmpType     []string `json:"icmptype"`
	Interface    []string `json:"interface"`
	IpProtocol   string   `json:"ipprotocol"`
	Log          bool     `json:"log"`
	Pdnpipe      string   `json:"pdnpipe"`
	Protocol     string   `json:"protocol"`
	Quick        bool     `json:"quick"`
	Sched        string   `json:"sched"`
	Src          string   `json:"src"`
	SrcPort      string   `json:"srcport"`
	StateType    string   `json:"statetype"`
	TcpFlagsAny  bool     `json:"tcpflags_any"`
	TcpFlags1    []string `json:"tcpflags1"`
	TcpFlags2    []string `json:"tcpflags2"`
	Top          bool     `json:"top"`
	Type         string   `json:"type"`
}

type FirewallService

type FirewallService service

FirewallService provides firewall API methods

func (FirewallService) AddAliasEntry

func (s FirewallService) AddAliasEntry(ctx context.Context, aliasName string, toAdd map[string]string, apply bool) error

AddAliasEntry adds an address to an existing Alias. The addresses to add is represented by a map with the address to add being the key, and the description being the value.

func (FirewallService) Apply

func (s FirewallService) Apply(ctx context.Context) error

Apply applies pending firewall changes

func (FirewallService) CreateAlias

func (s FirewallService) CreateAlias(ctx context.Context, newAlias FirewallAliasRequest, apply bool) error

CreateAlias creates a new Alias

func (FirewallService) CreateRule

func (s FirewallService) CreateRule(ctx context.Context, newRule FirewallRuleRequest, apply bool) error

CreateRule creates a new Rule

func (FirewallService) DeleteAlias

func (s FirewallService) DeleteAlias(ctx context.Context, aliasToDelete string, apply bool) error

DeleteAlias deletes a firewall Alias

func (FirewallService) DeleteAliasEntry

func (s FirewallService) DeleteAliasEntry(ctx context.Context, aliasName string, address string, apply bool) error

DeleteAliasEntry deletes a address from a firewall alias

func (FirewallService) DeleteRule

func (s FirewallService) DeleteRule(ctx context.Context, tracker int, apply bool) error

DeleteRule deletes a firewall Rule

func (FirewallService) ListAliases

func (s FirewallService) ListAliases(ctx context.Context) ([]*FirewallAlias, error)

ListAliases returns the aliases

func (FirewallService) ListRules

func (s FirewallService) ListRules(ctx context.Context) ([]*FirewallRule, error)

ListRules returns the rules

func (FirewallService) UpdateAlias

func (s FirewallService) UpdateAlias(ctx context.Context, aliasToUpdate string, newAliasData FirewallAliasRequest, apply bool) error

UpdateAlias modifies an existing alias

func (FirewallService) UpdateRule

func (s FirewallService) UpdateRule(ctx context.Context, ruleToUpdate int, newRuleData FirewallRuleRequest, apply bool) error

UpdateRule modifies an existing rule

type Gateway

type Gateway struct {
	Dynamic         bool   `json:"dynamic"`
	IpProtocol      string `json:"ipprotocol"`
	Gateway         string `json:"gateway"`
	Interface       string `json:"interface"`
	FriendlyIface   string `json:"friendlyiface"`
	FriendlyIfDescr string `json:"friendlyifdescr"`
	Name            string `json:"name"`
	Attribute       any    `json:"attribute"`
	IsDefaultGW     bool   `json:"isdefaultgw"`
	Monitor         string `json:"monitor"`
	Descr           string `json:"descr"`
	TierName        string `json:"tiername"`
}

Gateway represents a single routing gateway

type GatewayRequest

type GatewayRequest struct {
	ActionDisable  bool   `json:"action_disable"`
	AlertInterval  int    `json:"alert_interval"`
	Apply          bool   `json:"apply"`
	DataPayload    int    `json:"data_payload"`
	Descr          string `json:"descr"`
	Disabled       bool   `json:"disabled"`
	ForceDown      bool   `json:"force_down"`
	Gateway        string `json:"gateway"`
	Interface      string `json:"interface"`
	Interval       int    `json:"interval"`
	IpProtocol     string `json:"ipprotocol"`
	LatencyHigh    int    `json:"latencyhigh"`
	LatencyLow     int    `json:"latencylow"`
	LossInterval   int    `json:"loss_interval"`
	LossHigh       int    `json:"losshigh"`
	LossLow        int    `json:"losslow"`
	Monitor        string `json:"monitor"`
	MonitorDisable bool   `json:"monitor_disable"`
	Name           string `json:"name"`
	TimePeriod     int    `json:"time_period"`
	Weight         int    `json:"weight"`
}

GatewayRequest represents a single gateway to be created or modified. This type is use for creations and updates.

type GatewayStatus

type GatewayStatus struct {
	Monitorip string  `json:"monitorip"`
	Srcip     string  `json:"srcip"`
	Name      string  `json:"name"`
	Delay     float64 `json:"delay"`
	Stddev    float64 `json:"stddev"`
	Loss      int     `json:"loss"`
	Status    string  `json:"status"`
	Substatus string  `json:"substatus"`
}

type Group

type Group struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Scope       string   `json:"scope"`
	Gid         int      `json:"gid"`
	Member      []int    `json:"member"`
	Priv        []string `json:"priv"`
}

Group represents a single user group.

type GroupRequest

type GroupRequest struct {
	Name        string   `json:"name"`
	Scope       string   `json:"scope"`
	Description string   `json:"description"`
	Member      []int    `json:"member"`
	Priv        []string `json:"priv"`
}

type Interface

type Interface struct {
	Enable                          string `json:"enable"`
	If                              string `json:"if"`
	Descr                           string `json:"descr"`
	AliasAddress                    string `json:"alias-address"`
	AliasSubnet                     string `json:"alias-subnet"`
	Ipaddr                          string `json:"ipaddr"`
	Dhcprejectfrom                  string `json:"dhcprejectfrom"`
	AdvDhcpPtTimeout                string `json:"adv_dhcp_pt_timeout"`
	AdvDhcpPtRetry                  string `json:"adv_dhcp_pt_retry"`
	AdvDhcpPtSelectTimeout          string `json:"adv_dhcp_pt_select_timeout"`
	AdvDhcpPtReboot                 string `json:"adv_dhcp_pt_reboot"`
	AdvDhcpPtBackoffCutoff          string `json:"adv_dhcp_pt_backoff_cutoff"`
	AdvDhcpPtInitialInterval        string `json:"adv_dhcp_pt_initial_interval"`
	AdvDhcpPtValues                 string `json:"adv_dhcp_pt_values"`
	AdvDhcpSendOptions              string `json:"adv_dhcp_send_options"`
	AdvDhcpRequestOptions           string `json:"adv_dhcp_request_options"`
	AdvDhcpRequiredOptions          string `json:"adv_dhcp_required_options"`
	AdvDhcpOptionModifiers          string `json:"adv_dhcp_option_modifiers"`
	AdvDhcpConfigAdvanced           string `json:"adv_dhcp_config_advanced"`
	AdvDhcpConfigFileOverride       string `json:"adv_dhcp_config_file_override"`
	AdvDhcpConfigFileOverridePath   string `json:"adv_dhcp_config_file_override_path"`
	Ipaddrv6                        string `json:"ipaddrv6"`
	Dhcp6Duid                       string `json:"dhcp6-duid"`
	Dhcp6IaPdLen                    string `json:"dhcp6-ia-pd-len"`
	AdvDhcp6PrefixSelectedInterface string `json:"adv_dhcp6_prefix_selected_interface"`
	Blockpriv                       string `json:"blockpriv"`
	Blockbogons                     string `json:"blockbogons"`
	Subnet                          string `json:"subnet"`
	Spoofmac                        string `json:"spoofmac"`
	Name                            string `json:"name"`
}

Interface represents a single interface.

type InterfaceGroup

type InterfaceGroup struct {
	Members string `json:"members"`
	Descr   string `json:"descr"`
	Ifname  string `json:"ifname"`
}

type InterfaceGroupRequestCreate

type InterfaceGroupRequestCreate struct {
	Descr   string   `json:"descr"`
	Members []string `json:"members"`
	Ifname  string   `json:"ifname"`
}

type InterfaceGroupRequestUpdate

type InterfaceGroupRequestUpdate struct {
	Descr   string   `json:"descr"`
	Id      string   `json:"id"`
	Members []string `json:"members"`
}

type InterfaceRequest

type InterfaceRequest struct {
	AdvDhcpConfigAdvanced         bool     `json:"adv_dhcp_config_advanced"`
	AdvDhcpConfigFileOverride     bool     `json:"adv_dhcp_config_file_override"`
	AdvDhcpConfigFileOverrideFile string   `json:"adv_dhcp_config_file_override_file"`
	AdvDhcpOptionModifiers        string   `json:"adv_dhcp_option_modifiers"`
	AdvDhcpPtBackoffCutoff        int      `json:"adv_dhcp_pt_backoff_cutoff"`
	AdvDhcpPtInitialInterval      int      `json:"adv_dhcp_pt_initial_interval"`
	AdvDhcpPtReboot               int      `json:"adv_dhcp_pt_reboot"`
	AdvDhcpPtRetry                int      `json:"adv_dhcp_pt_retry"`
	AdvDhcpPtSelectTimeout        int      `json:"adv_dhcp_pt_select_timeout"`
	AdvDhcpPtTimeout              int      `json:"adv_dhcp_pt_timeout"`
	AdvDhcpRequestOptions         string   `json:"adv_dhcp_request_options"`
	AdvDhcpRequiredOptions        string   `json:"adv_dhcp_required_options"`
	AdvDhcpSendOptions            string   `json:"adv_dhcp_send_options"`
	AliasAddress                  string   `json:"alias-address"`
	AliasSubnet                   int      `json:"alias-subnet"`
	Apply                         bool     `json:"apply"`
	Blockbogons                   bool     `json:"blockbogons"`
	Blockpriv                     bool     `json:"blockpriv"`
	Descr                         string   `json:"descr"`
	Dhcpcvpt                      int      `json:"dhcpcvpt"`
	Dhcphostname                  string   `json:"dhcphostname"`
	Dhcprejectfrom                []string `json:"dhcprejectfrom"`
	Dhcpvlanenable                bool     `json:"dhcpvlanenable"`
	Enable                        bool     `json:"enable"`
	Gateway                       string   `json:"gateway"`
	Gateway6Rd                    string   `json:"gateway-6rd"`
	Gatewayv6                     string   `json:"gatewayv6"`
	If                            string   `json:"if"`
	Ipaddr                        string   `json:"ipaddr"`
	Ipaddrv6                      string   `json:"ipaddrv6"`
	Ipv6Usev4Iface                bool     `json:"ipv6usev4iface"`
	Media                         string   `json:"media"`
	Mss                           string   `json:"mss"`
	Mtu                           int      `json:"mtu"`
	Prefix6Rd                     string   `json:"prefix-6rd"`
	Prefix6RdV4Plen               int      `json:"prefix-6rd-v4plen"`
	Spoofmac                      string   `json:"spoofmac"`
	Subnet                        int      `json:"subnet"`
	Subnetv6                      string   `json:"subnetv6"`
	Track6Interface               string   `json:"track6-interface"`
	Track6PrefixIdHex             int      `json:"track6-prefix-id-hex"`
	Type                          string   `json:"type"`
	Type6                         string   `json:"type6"`
}

type InterfaceService

type InterfaceService service

InterfaceService provides interface API methods

func (InterfaceService) Apply

func (s InterfaceService) Apply(ctx context.Context, async bool) error

Apply applies pending interface changes

func (InterfaceService) CreateInterface

func (s InterfaceService) CreateInterface(ctx context.Context, newInterface InterfaceRequest) error

CreateInterface creates a new interface.

func (InterfaceService) CreateInterfaceGroup

func (s InterfaceService) CreateInterfaceGroup(ctx context.Context, newGroup InterfaceGroupRequestCreate) error

CreateInterfaceGroup creates a new interface group.

func (InterfaceService) CreateVLAN

func (s InterfaceService) CreateVLAN(ctx context.Context, newVLAN VLANRequest) error

CreateVLAN creates a new VLAN.

func (InterfaceService) DeleteInterface

func (s InterfaceService) DeleteInterface(ctx context.Context, interfaceID string) error

DeleteInterface deletes the interface. The interfaceID can be specified in either the interface's descriptive name, the pfSense ID (wan, lan, optx), or the physical interface id (e.g. igb0).

func (InterfaceService) DeleteInterfaceGroup

func (s InterfaceService) DeleteInterfaceGroup(ctx context.Context, idToDelete int) error

DeleteInterfaceGroup deletes an interface group.

func (InterfaceService) DeleteVLAN

func (s InterfaceService) DeleteVLAN(ctx context.Context, idToDelete int) error

DeleteVLAN deletes a VLAN.

func (InterfaceService) ListInterfaceGroups

func (s InterfaceService) ListInterfaceGroups(ctx context.Context) ([]*InterfaceGroup, error)

ListInterfaceGroups returns the interface groups.

func (InterfaceService) ListInterfaces

func (s InterfaceService) ListInterfaces(ctx context.Context) ([]*Interface, error)

ListInterfaces returns the interfaces

func (InterfaceService) ListVLANs

func (s InterfaceService) ListVLANs(ctx context.Context) ([]*VLAN, error)

ListVLANs returns the VLANs

func (InterfaceService) UpdateInterface

func (s InterfaceService) UpdateInterface(ctx context.Context, idToUpdate int, interfaceData InterfaceRequest) error

UpdateInterface modifies an existing interface.

func (InterfaceService) UpdateInterfaceGroup

func (s InterfaceService) UpdateInterfaceGroup(ctx context.Context, groupData InterfaceGroupRequestUpdate) error

UpdateInterfaceGroup updates an existing interface group.

func (InterfaceService) UpdateVLAN

func (s InterfaceService) UpdateVLAN(ctx context.Context, idToUpdate int, vlanData VLANRequest) error

UpdateVLAN modifies an existing VLAN.

type InterfaceStatus

type InterfaceStatus struct {
	Name          string `json:"name"`
	Descr         string `json:"descr"`
	Hwif          string `json:"hwif"`
	Enable        bool   `json:"enable"`
	If            string `json:"if"`
	Status        string `json:"status"`
	Macaddr       string `json:"macaddr"`
	Mtu           int    `json:"mtu"`
	Ipaddr        string `json:"ipaddr"`
	Subnet        string `json:"subnet"`
	Linklocal     string `json:"linklocal"`
	Ipaddrv6      string `json:"ipaddrv6"`
	Subnetv6      int    `json:"subnetv6"`
	Inerrs        int    `json:"inerrs"`
	Outerrs       int    `json:"outerrs"`
	Collisions    int    `json:"collisions"`
	Inbytespass   int64  `json:"inbytespass"`
	Outbytespass  int64  `json:"outbytespass"`
	Inpktspass    int    `json:"inpktspass"`
	Outpktspass   int    `json:"outpktspass"`
	Inbytesblock  int    `json:"inbytesblock"`
	Outbytesblock int    `json:"outbytesblock"`
	Inpktsblock   int    `json:"inpktsblock"`
	Outpktsblock  int    `json:"outpktsblock"`
	Inbytes       int64  `json:"inbytes"`
	Outbytes      int64  `json:"outbytes"`
	Inpkts        int    `json:"inpkts"`
	Outpkts       int    `json:"outpkts"`
	Dhcplink      string `json:"dhcplink"`
	Media         string `json:"media"`
	Gateway       string `json:"gateway"`
	Gatewayv6     string `json:"gatewayv6"`
}

type Package

type Package struct {
	Name             string `json:"name"`
	Version          string `json:"version"`
	InstalledVersion string `json:"installed_version"`
	Descr            string `json:"descr"`
	Installed        bool   `json:"installed"`
	UpdateAvailable  bool   `json:"update_available"`
}

Package represents a single package.

type RoutingService

type RoutingService service

RoutingService provides routing API methods

func (RoutingService) Apply

func (s RoutingService) Apply(ctx context.Context) error

Apply applies pending routing changes

func (RoutingService) CreateGateway

func (s RoutingService) CreateGateway(ctx context.Context, newGateway GatewayRequest) error

CreateGateway creates a new Gateway

func (RoutingService) DeleteGateway

func (s RoutingService) DeleteGateway(ctx context.Context, gatewayID int) error

DeleteGateway deletes a Gateway

func (RoutingService) ListGateways

func (s RoutingService) ListGateways(ctx context.Context) ([]*Gateway, error)

ListGateways returns the gateways

func (RoutingService) SetDefaultGateway

func (s RoutingService) SetDefaultGateway(ctx context.Context, newDefaultGateway DefaultGatewayRequest) error

SetDefaultGateway sets the default gateway

func (RoutingService) UpdateGateway

func (s RoutingService) UpdateGateway(ctx context.Context, gatewayToUpdate GatewayRequest) error

UpdateGateway modifies a existing gateway

type StatusService

type StatusService service

StatusService provides Status API methods

func (StatusService) DHCPLog

func (s StatusService) DHCPLog(ctx context.Context) ([]string, error)

DHCPLog returns the DHCP log

func (StatusService) FirewallLog

func (s StatusService) FirewallLog(ctx context.Context) ([]string, error)

FirewallLog returns the firewall log

func (StatusService) GetSystemStatus

func (s StatusService) GetSystemStatus(ctx context.Context) (*SystemStatus, error)

GetSystemStatus returns the system status

func (StatusService) ListGatewayStatus

func (s StatusService) ListGatewayStatus(ctx context.Context) ([]*GatewayStatus, error)

ListGatewayStatus returns the interface status

func (StatusService) ListInterfaceStatus

func (s StatusService) ListInterfaceStatus(ctx context.Context) ([]*InterfaceStatus, error)

ListInterfaceStatus returns the interface status

func (StatusService) SystemLog

func (s StatusService) SystemLog(ctx context.Context) ([]string, error)

SystemLog returns the firewall log

type SystemHostname

type SystemHostname struct {
	Hostname string `json:"hostname"`
	Domain   string `json:"domain"`
}

type SystemService

type SystemService service

SystemService provides System API methods

func (SystemService) AddDNSServers

func (s SystemService) AddDNSServers(ctx context.Context, newDNSServers []string) error

AddDNSServers adds new DNS servers to the system DNS configuration.

func (SystemService) CreateCACertificate

func (s SystemService) CreateCACertificate(ctx context.Context, newCACertificate CACertificateRequest) error

CreateCACertificate generate or import new CA certificate.

func (SystemService) CreateTunable

func (s SystemService) CreateTunable(ctx context.Context, newTunable TunableRequest) error

CreateTunable creates a new system tunable.

func (SystemService) DeleteArpEntry

func (s SystemService) DeleteArpEntry(ctx context.Context, address string) error

DeleteArpEntry deletes a arp entry for an address from the arp table

func (SystemService) DeleteCACertificate

func (s SystemService) DeleteCACertificate(ctx context.Context, refid string) error

DeleteCACertificate deletes a CA certificate installed on the system.

func (SystemService) DeleteCertificate

func (s SystemService) DeleteCertificate(ctx context.Context, refid string) error

DeleteCertificate deletes a SSL/TLS certificate installed on the system.

func (SystemService) DeleteDNSServer

func (s SystemService) DeleteDNSServer(ctx context.Context, dnsserver string) error

DeleteDNSServer deletes a system DNS server.

func (SystemService) DeleteTunable

func (s SystemService) DeleteTunable(ctx context.Context, tunableID int) error

DeleteTunable deletes a system tunable.

func (SystemService) GetAPIConfiguration

func (s SystemService) GetAPIConfiguration(ctx context.Context) (*APIConfiguration, error)

GetAPIConfiguration returns the API configuration

func (SystemService) GetAPIVersion

func (s SystemService) GetAPIVersion(ctx context.Context) (*APIVersion, error)

GetAPIVersion returns the API versions

func (SystemService) GetDNSConfiguration

func (s SystemService) GetDNSConfiguration(ctx context.Context) (*DNSConfiguration, error)

GetDNSConfiguration returns the system DNS configuration.

func (SystemService) GetEmailNotification

func (s SystemService) GetEmailNotification(ctx context.Context) (*EmailNotification, error)

GetEmailNotification returns the system email notification configuration.

func (SystemService) GetErrorDefinitions

func (s SystemService) GetErrorDefinitions(ctx context.Context) (map[string]*ErrorDefinition, error)

GetErrorDefinitions returns a map with the error code being the key and value being the error definition.

func (SystemService) GetHostname

func (s SystemService) GetHostname(ctx context.Context) (*SystemHostname, error)

GetHostname returns the system hostname configuration.

func (SystemService) GetVersion

func (s SystemService) GetVersion(ctx context.Context) (*Version, error)

GetVersion returns the system version.

func (SystemService) GetVersionUpgradeStatus

func (s SystemService) GetVersionUpgradeStatus(ctx context.Context, useCache bool) (*VersionUpgradeStatus, error)

GetVersionUpgradeStatus checks if there is an version upgrade available, but does not perform the upgrade.

func (SystemService) Halt

func (s SystemService) Halt(ctx context.Context) error

Halt shuts down the pfsense system.

func (SystemService) InstallPackage

func (s SystemService) InstallPackage(ctx context.Context, name string) error

InstallPackage installs a new package on the system.

func (SystemService) ListArpTable

func (s SystemService) ListArpTable(ctx context.Context) ([]*ArpEntry, error)

ListArpTable returns all the arp entries in the arp table.

func (SystemService) ListCACertificates

func (s SystemService) ListCACertificates(ctx context.Context) ([]*CACertificate, error)

ListCACertificates returns all the CA certificates installed on the system.

func (SystemService) ListCertificates

func (s SystemService) ListCertificates(ctx context.Context) ([]*Certificate, error)

ListCertificates returns all the SSL/TLS certificates installed on the system.

func (SystemService) ListPackages

func (s SystemService) ListPackages(ctx context.Context, all bool) ([]*Package, error)

ListPackages returns a list of the packages. Passing the true to the all argument here includes all pfSense packages available, even packages that are not installed.

func (SystemService) ListTunables

func (s SystemService) ListTunables(ctx context.Context) ([]*Tunable, error)

ListTunables returns a list of the system tunables.

func (SystemService) Reboot

func (s SystemService) Reboot(ctx context.Context) error

Reboot initiates a system reboot.

func (SystemService) UninstallPackage

func (s SystemService) UninstallPackage(ctx context.Context, name string) error

UninstallPackage uninstalls a package.

func (SystemService) UpdateAPIConfiguration

func (s SystemService) UpdateAPIConfiguration(ctx context.Context, apiConfiguration APIConfigurationRequest) error

UpdateAPIConfiguration updates the API configuration

func (SystemService) UpdateDNSConfiguration

func (s SystemService) UpdateDNSConfiguration(ctx context.Context, dnsConfiguration DNSConfiguration) error

UpdateDNSConfiguration updates the DNS configuration

func (SystemService) UpdateEmailNotification

func (s SystemService) UpdateEmailNotification(ctx context.Context, newConfig EmailNotificationRequest) error

UpdateEmailNotification updates the system email notification configuration.

func (SystemService) UpdateHostname

func (s SystemService) UpdateHostname(ctx context.Context, newHostname SystemHostname) error

UpdateHostname updates the system hostname.

func (SystemService) UpdateTunable

func (s SystemService) UpdateTunable(ctx context.Context, tunableToUpdate string, newTunable TunableRequest) error

UpdateTunable modifies an existing tunable.

type SystemStatus

type SystemStatus struct {
	SystemPlatform  string    `json:"system_platform"`
	SystemSerial    string    `json:"system_serial"`
	SystemNetgateId string    `json:"system_netgate_id"`
	BiosVendor      string    `json:"bios_vendor"`
	BiosVersion     string    `json:"bios_version"`
	BiosDate        string    `json:"bios_date"`
	CpuModel        string    `json:"cpu_model"`
	KernelPti       bool      `json:"kernel_pti"`
	MdsMitigation   string    `json:"mds_mitigation"`
	TempC           int       `json:"temp_c"`
	TempF           float64   `json:"temp_f"`
	LoadAvg         []float64 `json:"load_avg"`
	MbufUsage       float64   `json:"mbuf_usage"`
	MemUsage        float64   `json:"mem_usage"`
	SwapUsage       int       `json:"swap_usage"`
	DiskUsage       float64   `json:"disk_usage"`
}

type TokenService

type TokenService service

TokenService provides Token API methods

func (TokenService) CreateAccessToken

func (s TokenService) CreateAccessToken(ctx context.Context) (string, error)

CreateAccessToken creates a new AccessToken

type Tunable

type Tunable struct {
	Tunable  string `json:"tunable"`
	Value    string `json:"value"`
	Descr    string `json:"descr"`
	Modified bool   `json:"modified"`
}

Tunable represents a single system tunable.

type TunableRequest

type TunableRequest struct {
	Descr   string `json:"descr"`
	Tunable string `json:"tunable"`
	Value   string `json:"value"`
}

type User

type User struct {
	Scope            string   `json:"scope"`
	BcryptHash       string   `json:"bcrypt-hash"`
	Descr            string   `json:"descr"`
	Name             string   `json:"name"`
	Expires          string   `json:"expires"`
	Dashboardcolumns string   `json:"dashboardcolumns"`
	AuthorizedKeys   string   `json:"authorizedkeys"`
	Ipsecpsk         string   `json:"ipsecpsk"`
	Webguicss        string   `json:"webguicss"`
	Cert             []string `json:"cert"`
	Uid              string   `json:"uid"`
	GroupName        string   `json:"groupname"`
	Priv             []string `json:"priv"`
}

User represents a single user.

type UserRequest

type UserRequest struct {
	AuthorizedKeys string   `json:"authorizedkeys"`
	Cert           []string `json:"cert"`
	Descr          string   `json:"descr"`
	Disabled       bool     `json:"disabled"`
	Expires        string   `json:"expires"`
	Ipsecpsk       string   `json:"ipsecpsk"`
	Password       string   `json:"password"`
	Priv           []string `json:"priv"`
	Username       string   `json:"username"`
}

type UserService

type UserService service

UserService provides User API methods

func (UserService) AddPrivilegesToUser

func (s UserService) AddPrivilegesToUser(ctx context.Context, username string, privileges []string) error

AddPrivilegesToUser adds existing privileges to a user.

func (UserService) AddUserToGroups

func (s UserService) AddUserToGroups(ctx context.Context, username string, groups []string) error

AddUserToGroups adds a user to existing groups.

func (UserService) CreateGroup

func (s UserService) CreateGroup(ctx context.Context, newGroup GroupRequest) error

CreateGroup creates a new Group.

func (UserService) CreateUser

func (s UserService) CreateUser(ctx context.Context, newUser UserRequest) error

CreateUser creates a new User.

func (UserService) DeleteGroup

func (s UserService) DeleteGroup(ctx context.Context, groupname string) error

DeleteGroup deletes a group by group name.

func (UserService) DeleteUser

func (s UserService) DeleteUser(ctx context.Context, username string) error

DeleteUser deletes a user by username.

func (UserService) ListGroups

func (s UserService) ListGroups(ctx context.Context) ([]*Group, error)

ListGroups returns a list of the groups.

func (UserService) ListUsers

func (s UserService) ListUsers(ctx context.Context) ([]*User, error)

ListUsers returns a list of the users.

func (UserService) RemovePrivilegeFromUser

func (s UserService) RemovePrivilegeFromUser(ctx context.Context, username, privname string) error

RemovePrivilegeFromUser removes a privilege from a user.

func (UserService) RemoveUserFromGroup

func (s UserService) RemoveUserFromGroup(ctx context.Context, username, groupname string) error

RemoveUserFromGroup removes a user from a group.

func (UserService) UpdateGroup

func (s UserService) UpdateGroup(ctx context.Context, groupToUpdate string, newGroupData GroupRequest) error

UpdateGroup modifies an existing group.

func (UserService) UpdateUser

func (s UserService) UpdateUser(ctx context.Context, userData UserRequest) error

UpdateUser updates a user.

type VLAN

type VLAN struct {
	If     string `json:"if"`
	Tag    string `json:"tag"`
	Pcp    string `json:"pcp"`
	Descr  string `json:"descr"`
	Vlanif string `json:"vlanif"`
}

VLAN represents a single VLAN.

type VLANRequest

type VLANRequest struct {
	Descr string `json:"descr"`
	If    string `json:"if"`
	Pcp   int    `json:"pcp"`
	Tag   int    `json:"tag"`
}

type Version

type Version struct {
	Version    string `json:"version"`
	Base       string `json:"base"`
	Patch      string `json:"patch"`
	Buildtime  string `json:"buildtime"`
	Lastcommit string `json:"lastcommit"`
	Program    int    `json:"program"`
}

Version represents the system version.

type VersionUpgradeStatus

type VersionUpgradeStatus struct {
	Version           string `json:"version"`
	InstalledVersion  string `json:"installed_version"`
	PkgVersionCompare string `json:"pkg_version_compare"`
}

VersionUpgradeStatus represents the system version upgrade status.

Jump to

Keyboard shortcuts

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