Documentation ¶
Overview ¶
Copyright © 2023 Laura Kalb <dev@lauka.net>
Copyright © 2023 Laura Kalb <dev@lauka.net>
Copyright © 2023 Laura Kalb <dev@lauka.net>
Copyright © 2023 Laura Kalb <dev@lauka.net>
Copyright © 2023 Laura Kalb <dev@lauka.net>
Copyright © 2023 Laura Kalb <dev@lauka.net>
Index ¶
- func AddDNSFqdn(fqdn string, addr netip.Addr) error
- func DeleteDNSFqdn(fqdn string, addr netip.Addr) error
- func DeleteSubnet(net netip.Prefix) error
- func Execute()
- func ListSubnets() []string
- func SubnetExists(net netip.Prefix) bool
- type Address
- type DNSRecord
- type DNSRecordSet
- type DNSZone
- type Patch
- type Subnet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDNSFqdn ¶
AddDNSFqdn tries to create forward and reverse lookup records for given fqdn with netip.Addr addr, IF PowerDNS integration is enabled.
Returns nil on success, error otherwise
func DeleteDNSFqdn ¶
DeleteDNSFqdn tries to delete the corresponding record for given fqdn with netip.Addr addr from the DNS server.
Returns nil on success, error otherwise
func DeleteSubnet ¶
DeleteSubnet deletes the subnet file on disk for netip.Prefix net.
Returns nil on success, or a *PathError on failure
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func ListSubnets ¶
func ListSubnets() []string
ListSubnets returns a list of strings containing the current subnets configured.
func SubnetExists ¶
SubnetExists will return true if the given subnet already exists on file, false otherwise.
Types ¶
type Address ¶
type Address struct { IP netip.Addr `json:"ip"` FQDN string `json:"fqdn"` ChangedAt time.Time `json:"changedat,omitempty"` ChangedBy string `json:"changedby,omitempty"` }
func SortAddresses ¶
SortAddresses sorts the given list of IP addresses using netip.Addr.Less() and returns the sorted slice.
type DNSRecordSet ¶
type DNSZone ¶
type DNSZone struct { ID string `json:"id"` Name string `json:"name"` Kind string `json:"kind"` RRsets []DNSRecordSet `json:"rrsets"` Metadata map[string]string `json:"metadata"` DNSSEC bool `json:"dnssec"` NSEC3Param string `json:"nsec3param,omitempty"` Account string `json:"account,omitempty"` Serial int `json:"serial"` }
func GetBestDNSZone ¶
GetBestDNSZone requests a list of all zones from PowerDNS and determines the best zone, if possible.
Returns the found DNSZone and nil if a suitable zone was found, an empty DNSZone object and an error if not.
func GetDNSZone ¶
GetDNSZone retrieves the corresponding DNSZone for string zone from the DNS server.
Returns the DNSZone and nil if successful, empty DNSZone and an error otherwise
func (DNSZone) GetRecord ¶
GetRecord checks if a given Record already exists in the DNSRecordSet list.
Returns the DNSRecordSet and true if record exists, empty DNSRecordSet and false if not.
type Patch ¶
type Patch struct {
Rrsets []DNSRecordSet `json:"rrsets"`
}
type Subnet ¶
type Subnet struct { Subnet netip.Prefix `json:"subnet"` Name string `json:"name"` Vlan string `json:"vlan"` ChangedAt time.Time `json:"changedat,omitempty"` ChangedBy string `json:"changedby,omitempty"` Addresses []Address `json:"addresses"` }
func FindBestSubnet ¶
FindBestSubnet tries to load the most fitting IP subnet file on disk. It takes an IP object and tries to get the best subnet (meaning the subnet with the smallest subnet size).
Returns the best subnet as Subnet object and true if a suitable subnet was found, otherwise an empty Subnet object and false.
func GetSubnet ¶
GetSubnet reads the corresponding file for the given netip.Prefix net and constructs a Subnet object.
Returns the Subnet object and nil if the file read was successful, an empty Subnet object and the error otherwise.
func (Subnet) FindFirstFreeIP ¶
FindFirstFreeIP finds and returns the next free netip.Addr or an invalid netip.Addr if no free IP was found
func (Subnet) GetIP ¶
GetIP returns the Address object for the subnet with netip.Addr ip.
Returns the Address object and true if a corresponding object was found, an empty Address and false otherwise.
func (Subnet) GetIPCount ¶
GetIPCount gets the IP count for the Subnet
Returns the IP count or -1 if it's a IPv6 prefix
func (Subnet) HasIP ¶
HasIP checks if a Subnet already contains given netip.Addr. Returns true if the IP already is present, false otherwise.
func (Subnet) RemoveIP ¶
RemoveIP removes the Address object for given ip from the Address list of the subnet.
Returns the changed Subnet and nil if delete was successful, or an empty Subnet and an error if ip could not be deleted.
func (Subnet) WriteSubnet ¶
WriteSubnet takes a given Subnet object and tries to write it to file.
Returns nil on success or the error that happened.