mikrotik

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMikrotikProvider

func NewMikrotikProvider(domainFilter endpoint.DomainFilter, config *Config) (provider.Provider, error)

NewMikrotikProvider initializes a new DNSProvider.

Types

type Config

type Config struct {
	Host          string `env:"MIKROTIK_HOST,notEmpty"`
	Port          string `env:"MIKROTIK_PORT,notEmpty" envDefault:"443"`
	Username      string `env:"MIKROTIK_USERNAME,notEmpty"`
	Password      string `env:"MIKROTIK_PASSWORD,notEmpty"`
	SkipTLSVerify bool   `env:"MIKROTIK_SKIP_TLS_VERIFY" envDefault:"false"`
}

Config holds the connection details for the API client

type DNSRecord

type DNSRecord struct {
	// Common fields for all record types
	ID             string `json:".id,omitempty"`             // only fetched from API
	Name           string `json:"name"`                      // endpoint.DNSName
	Type           string `json:"type"`                      // endpoint.RecordType
	TTL            string `json:"ttl,omitempty"`             // endpoint.RecordTTL
	Comment        string `json:"comment,omitempty"`         // provider-specific
	Regexp         string `json:"regexp,omitempty"`          // provider-specific
	MatchSubdomain string `json:"match-subdomain,omitempty"` // provider-specific
	AddressList    string `json:"address-list,omitempty"`    // provider-specific

	// Record specific fields
	Address string `json:"address,omitempty"` // A, AAAA -> endpoint.Targets[0]
	CName   string `json:"cname,omitempty"`   // CNAME -> endpoint.Targets[0]
	Text    string `json:"text,omitempty"`    // TXT -> endpoint.Targets[0]

}

DNSRecord represents a MikroTik DNS record in the format used by the API https://help.mikrotik.com/docs/display/ROS/DNS#DNS-DNSStatic

func NewDNSRecord added in v0.2.0

func NewDNSRecord(endpoint *endpoint.Endpoint) (*DNSRecord, error)

NewDNSRecord converts an ExternalDNS Endpoint to a Mikrotik DNSRecord

type MikrotikApiClient

type MikrotikApiClient struct {
	*Config
	*http.Client
}

MikrotikApiClient encapsulates the client configuration and HTTP client

func NewMikrotikClient

func NewMikrotikClient(config *Config) (*MikrotikApiClient, error)

NewMikrotikClient creates a new instance of MikrotikApiClient

func (*MikrotikApiClient) CreateDNSRecord added in v0.2.0

func (c *MikrotikApiClient) CreateDNSRecord(endpoint *endpoint.Endpoint) (*DNSRecord, error)

CreateDNSRecord sends a request to create a new DNS record

func (*MikrotikApiClient) DeleteDNSRecord added in v0.2.0

func (c *MikrotikApiClient) DeleteDNSRecord(endpoint *endpoint.Endpoint) error

DeleteDNSRecord sends a request to delete a DNS record

func (*MikrotikApiClient) GetAllDNSRecords added in v0.2.0

func (c *MikrotikApiClient) GetAllDNSRecords() ([]DNSRecord, error)

GetAllDNSRecords fetches all DNS records from the MikroTik API

func (*MikrotikApiClient) GetSystemInfo

func (c *MikrotikApiClient) GetSystemInfo() (*SystemInfo, error)

GetSystemInfo fetches system information from the MikroTik API

type MikrotikProvider added in v0.2.0

type MikrotikProvider struct {
	provider.BaseProvider
	// contains filtered or unexported fields
}

DNS Provider for working with mikrotik

func (*MikrotikProvider) ApplyChanges added in v0.2.0

func (p *MikrotikProvider) ApplyChanges(ctx context.Context, changes *plan.Changes) error

ApplyChanges applies a given set of changes in the DNS provider.

func (*MikrotikProvider) GetDomainFilter added in v0.2.0

func (p *MikrotikProvider) GetDomainFilter() endpoint.DomainFilterInterface

GetDomainFilter returns the domain filter for the provider.

func (*MikrotikProvider) Records added in v0.2.0

func (p *MikrotikProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, error)

Records returns the list of all DNS records.

type SystemInfo

type SystemInfo struct {
	ArchitectureName     string `json:"architecture-name"`
	BadBlocks            string `json:"bad-blocks"`
	BoardName            string `json:"board-name"`
	BuildTime            string `json:"build-time"`
	CPU                  string `json:"cpu"`
	CPUCount             string `json:"cpu-count"`
	CPUFrequency         string `json:"cpu-frequency"`
	CPULoad              string `json:"cpu-load"`
	FactorySoftware      string `json:"factory-software"`
	FreeHDDSpace         string `json:"free-hdd-space"`
	FreeMemory           string `json:"free-memory"`
	Platform             string `json:"platform"`
	TotalHDDSpace        string `json:"total-hdd-space"`
	TotalMemory          string `json:"total-memory"`
	Uptime               string `json:"uptime"`
	Version              string `json:"version"`
	WriteSectSinceReboot string `json:"write-sect-since-reboot"`
	WriteSectTotal       string `json:"write-sect-total"`
}

SystemInfo represents MikroTik system information https://help.mikrotik.com/docs/display/ROS/Resource

Jump to

Keyboard shortcuts

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