Documentation
¶
Overview ¶
Package cloudflare implements the Cloudflare DNS provider.
Index ¶
- func NewDeleteRequest(ctx context.Context, zoneID, recordID string) (*http.Request, error)
- type Client
- func (c *Client) CreateDNSRecord(ctx context.Context, zoneID string, record *DNSRecord) (DNSRecord, error)
- func (c *Client) DeleteDNSRecord(ctx context.Context, zoneID, recordID string) error
- func (c *Client) ListDNSRecords(ctx context.Context, zoneID string, req *ListDNSRecordsRequest) ([]DNSRecord, error)
- func (c *Client) UpdateDNSRecord(ctx context.Context, zoneID, recordID string, req *UpdateDNSRecordRequest) (DNSRecord, error)
- type DNSRecord
- type DNSRecordData
- type DNSRecordMeta
- type Keeper
- type KeeperConfig
- type ListDNSRecordsRequest
- type RecordConfig
- type Response
- type ResponseInfo
- type ResultInfo
- type ResultInfoCursors
- type UpdateDNSRecordRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Cloudflare API client for managing DNS records.
func (*Client) CreateDNSRecord ¶
func (c *Client) CreateDNSRecord(ctx context.Context, zoneID string, record *DNSRecord) (DNSRecord, error)
CreateDNSRecord creates a DNS record in a zone.
func (*Client) DeleteDNSRecord ¶
DeleteDNSRecord deletes a DNS record in a zone.
func (*Client) ListDNSRecords ¶
func (c *Client) ListDNSRecords(ctx context.Context, zoneID string, req *ListDNSRecordsRequest) ([]DNSRecord, error)
ListDNSRecords lists DNS records in a zone.
func (*Client) UpdateDNSRecord ¶
func (c *Client) UpdateDNSRecord(ctx context.Context, zoneID, recordID string, req *UpdateDNSRecordRequest) (DNSRecord, error)
UpdateDNSRecord updates a DNS record in a zone.
type DNSRecord ¶
type DNSRecord struct { ID string `json:"id"` ZoneID string `json:"zone_id,omitempty"` ZoneName string `json:"zone_name,omitempty"` Name string `json:"name"` Type string `json:"type"` Content string `json:"content"` Priority uint16 `json:"priority,omitempty"` Proxiable bool `json:"proxiable,omitempty"` Proxied bool `json:"proxied"` Locked bool `json:"locked,omitempty"` TTL int `json:"ttl,omitempty"` Data *DNSRecordData `json:"data,omitempty"` Meta *DNSRecordMeta `json:"meta,omitempty"` Comment string `json:"comment,omitempty"` Tags []string `json:"tags,omitempty"` CreatedOn time.Time `json:"created_on"` ModifiedOn time.Time `json:"modified_on"` }
DNSRecord represents a DNS record in a zone.
type DNSRecordData ¶
type DNSRecordData struct { Name string `json:"name,omitempty"` Target string `json:"target,omitempty"` Value string `json:"value,omitempty"` Priority uint16 `json:"priority,omitempty"` Weight uint16 `json:"weight,omitempty"` Port uint16 `json:"port,omitempty"` }
DNSRecordData represents the data of a DNS record.
type DNSRecordMeta ¶
type DNSRecordMeta struct { AutoAdded bool `json:"auto_added"` ManagedByApps bool `json:"managed_by_apps"` ManagedByArgoTunnel bool `json:"managed_by_argo_tunnel"` }
DNSRecordMeta represents the metadata of a DNS record.
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper interacts with Cloudflare's API to manage a domain's DNS records.
Keeper implements provider.RecordKeeper.
func NewKeeper ¶
func NewKeeper(domain string, client *Client, config KeeperConfig) (*Keeper, error)
NewKeeper creates a new Keeper.
func (*Keeper) FeedSourceState ¶
FeedSourceState feeds the current IP addresses of the source to the record keeper.
FeedSourceState implements provider.RecordKeeper.FeedSourceState.
func (*Keeper) FetchRecords ¶
FetchRecords fetches the state of the domain's managed DNS records.
FetchRecords implements provider.RecordKeeper.FetchRecords.
func (*Keeper) SyncRecords ¶
SyncRecords synchronizes the domain's managed DNS records with the source state, creating or updating records as needed.
SyncRecords implements provider.RecordKeeper.SyncRecords.
type KeeperConfig ¶
type KeeperConfig struct { // ZoneID is the ID of the Cloudflare zone. ZoneID string `json:"zone_id"` // ARecord is the configuration for the managed A record. ARecord RecordConfig `json:"a_record"` // AAAARecord is the configuration for the managed AAAA record. AAAARecord RecordConfig `json:"aaaa_record"` // HTTPSRecord is the configuration for the managed HTTPS record. HTTPSRecord RecordConfig `json:"https_record"` }
KeeperConfig contains configuration options specific to the Cloudflare domain DNS record keeper.
type ListDNSRecordsRequest ¶
type ListDNSRecordsRequest struct { Name string // name Type string // type Content string // content Proxied *bool // proxied Comment string // comment CommentAbsent string // comment.absent CommentContains string // comment.contains CommentEndsWith string // comment.endswith CommentExact string // comment.exact CommentPresent string // comment.present CommentStartsWith string // comment.startswith Tags []string // tag TagAbsent string // tag.absent TagContains string // tag.contains TagEndsWith string // tag.endswith TagExact string // tag.exact TagPresent string // tag.present TagStartsWith string // tag.startswith TagMatch string // tag_match Order string // order Direction string // direction Match string // match Search string // search Page int // page PerPage int // per_page }
ListDNSRecordsRequest contains the query parameters for listing DNS records.
func (*ListDNSRecordsRequest) NewRequest ¶
func (r *ListDNSRecordsRequest) NewRequest(ctx context.Context, zoneID string) (*http.Request, error)
NewRequest creates a new request to list DNS records.
type RecordConfig ¶
type RecordConfig struct { // Enabled controls whether to manage the record. Enabled bool `json:"enabled"` // Priority is the SvcPriority of the managed HTTPS DNS record. // // Per RFC 9460: // // When SvcPriority is 0, the SVCB record is in AliasMode (Section 2.4.2). // Otherwise, it is in ServiceMode (Section 2.4.3). Priority uint16 `json:"priority"` // Proxied controls whether to proxy the A/AAAA record through Cloudflare. Proxied bool `json:"proxied"` // TTL is the TTL of the managed DNS record in seconds. // Setting to 1 means 'automatic'. Value must be between 60 and 86400, // with the minimum reduced to 30 for Enterprise zones. TTL int `json:"ttl"` // Target is the target of the managed HTTPS DNS record. // If empty, "." is used. Target string `json:"target"` // SvcParams are additional SvcParamKey=SvcParamValue pairs for the managed HTTPS DNS record. // Depending on the configured sources, "ipv4hint" and/or "ipv6hint" may not be allowed in the list. SvcParams string `json:"svc_params"` // Comment is a comment about the managed DNS record. Comment string `json:"comment"` // Tags are custom tags for the managed DNS record. Tags []string `json:"tags"` }
RecordConfig contains configuration options for a managed DNS record.
type Response ¶
type Response[R any] struct { Success bool `json:"success"` Errors []ResponseInfo `json:"errors"` Messages []ResponseInfo `json:"messages"` Result R `json:"result"` ResultInfo ResultInfo `json:"result_info"` }
Response is a generic response from the Cloudflare API.
type ResponseInfo ¶
ResponseInfo contains a code and message returned by the API as errors or informational messages inside the response.
type ResultInfo ¶
type ResultInfo struct { Page int `json:"page"` PerPage int `json:"per_page"` TotalPages int `json:"total_pages"` Count int `json:"count"` Total int `json:"total_count"` Cursor string `json:"cursor"` Cursors ResultInfoCursors `json:"cursors"` }
ResultInfo contains metadata about the Response.
type ResultInfoCursors ¶
ResultInfoCursors contains information about cursors.
type UpdateDNSRecordRequest ¶
type UpdateDNSRecordRequest struct { Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Content string `json:"content,omitempty"` Priority uint16 `json:"priority,omitempty"` Proxied *bool `json:"proxied,omitempty"` TTL int `json:"ttl,omitempty"` Data *DNSRecordData `json:"data,omitempty"` Comment *string `json:"comment,omitempty"` Tags []string `json:"tags,omitempty"` }
UpdateDNSRecordRequest is the request body for updating a DNS record.
func (*UpdateDNSRecordRequest) NewRequest ¶
func (r *UpdateDNSRecordRequest) NewRequest(ctx context.Context, zoneID, recordID string) (*http.Request, error)
NewRequest creates a new request to update a DNS record.