cf

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cloudflare

type Cloudflare struct {
	// contains filtered or unexported fields
}

func NewCloudflare

func NewCloudflare(zoneKey, dnsKey string) (*Cloudflare, error)

NewCloudflare creates a new Cloudflare API client for both the zone and DNS API. This returns instances to the given APIs and any errors. TODO: check api keys

func (*Cloudflare) AddRecord

func (c *Cloudflare) AddRecord(zoneID string, t, name, content, comment string, proxied bool) (*Record, error)

func (*Cloudflare) DeleteRecord

func (c *Cloudflare) DeleteRecord(zoneID string, id string) error

func (*Cloudflare) FilterRecords

func (c *Cloudflare) FilterRecords(records []*Record, filters ...RecordFilter) []*Record

func (*Cloudflare) GetRecords

func (c *Cloudflare) GetRecords(zoneID string, filters ...RecordFilter) ([]*Record, error)

func (*Cloudflare) GetZones

func (c *Cloudflare) GetZones(filters ...ZoneFilter) (map[string]string, error)

GetZones returns a map of zone names to zone IDs. This is useful for interacting with the Cloudflare API since many requests (such as DNS requests) require a zone ID. Zones can be filtered too based on a given set of filters that are ran in the order provided.

func (*Cloudflare) Poll

func (c *Cloudflare) Poll(ctx context.Context, interval time.Duration) <-chan error

func (*Cloudflare) Records

func (c *Cloudflare) Records() map[string]*Record

func (*Cloudflare) SetAllowedZones

func (c *Cloudflare) SetAllowedZones(names ...string)

func (*Cloudflare) UpdateRecordAddress

func (c *Cloudflare) UpdateRecordAddress(zoneID string, id, address string) error

func (*Cloudflare) ZoneID

func (c *Cloudflare) ZoneID(name string) (string, error)

type Record

type Record struct {
	ID      string
	Type    string
	Name    string
	Address string
	Comment string
	Proxied bool
}

type RecordFilter

type RecordFilter func(record []*Record) []*Record

func RecordFilterAddressIn

func RecordFilterAddressIn(addresses ...netip.Addr) RecordFilter

func RecordFilterCommentContains

func RecordFilterCommentContains(str string) RecordFilter

func RecordFilterNameIn

func RecordFilterNameIn(names ...string) RecordFilter

func RecordFilterTypeIn

func RecordFilterTypeIn(types ...string) RecordFilter

type ZoneFilter

type ZoneFilter func(zone []cloudflare.Zone) []cloudflare.Zone

func ZoneFilterIDIn

func ZoneFilterIDIn(ids ...string) ZoneFilter

ZoneFilterIDIn returns a zone filter that filters zones based on the given ids. If a zone has an id that is **not** in the given list, it will be filtered out of any returned set.

func ZoneFilterNameIn

func ZoneFilterNameIn(names ...string) ZoneFilter

ZoneFilterNameIn returns a zone filter that filters zones based on the given names. If a zone has a name that is **not** in the given list, it will be filtered out of any returned set.

Jump to

Keyboard shortcuts

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