pocketbase

package
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ZonesCacheRefreshInterval defines how often the zones cache should be refreshed.
	ZonesCacheRefreshInterval = 10 * time.Second
	// ZonesCacheKey is the key used to store zones in the cache.
	ZonesCacheKey = "zones"
	// RecordsCacheKeyFormat defines the format for record cache keys.
	RecordsCacheKeyFormat = "records.[%s]-[%s]-[%s]"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Composer

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

Composer is responsible for composing DNS records from PocketBase data. It provides methods to convert PocketBase record data into DNS resource records.

func NewComposer

func NewComposer(inst *Instance) *Composer

NewComposer creates a new Composer instance with the given PocketBase instance.

type Instance

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

Instance represents a PocketBase instance with DNS-specific configurations and caching. It manages the connection to PocketBase and provides methods for DNS record operations.

func NewWithDataDir

func NewWithDataDir(dataDir string) *Instance

NewWithDataDir creates a new Instance with the specified data directory. The data directory will be converted to an absolute path if it's relative.

func (*Instance) ComposeAAAARecord

func (inst *Instance) ComposeAAAARecord(rec *m.Record) (record dns.RR, extras []dns.RR, err error)

ComposeAAAARecord creates a DNS AAAA record from a PocketBase record. It returns the composed AAAA record and any additional records needed.

func (*Instance) ComposeARecord

func (inst *Instance) ComposeARecord(rec *m.Record) (record dns.RR, extras []dns.RR, err error)

ComposeARecord creates a DNS A record from a PocketBase record. It returns the composed A record and any additional records needed.

func (*Instance) ComposeCAARecord

func (inst *Instance) ComposeCAARecord(rec *m.Record) (record dns.RR, extras []dns.RR, err error)

ComposeCAARecord creates a DNS CAA record from a PocketBase record. It returns the composed CAA record and any additional records needed.

func (*Instance) ComposeCNAMERecord

func (inst *Instance) ComposeCNAMERecord(rec *m.Record) (record dns.RR, extras []dns.RR, err error)

ComposeCNAMERecord creates a DNS CNAME record from a PocketBase record. It returns the composed CNAME record and any additional records needed.

func (*Instance) ComposeMXRecord

func (inst *Instance) ComposeMXRecord(rec *m.Record) (record dns.RR, extras []dns.RR, err error)

ComposeMXRecord creates a DNS MX record from a PocketBase record. It returns the composed MX record and any additional records needed.

func (*Instance) ComposeNSRecord

func (inst *Instance) ComposeNSRecord(rec *m.Record) (record dns.RR, extras []dns.RR, err error)

ComposeNSRecord creates a DNS NS record from a PocketBase record. It returns the composed NS record and any additional records needed.

func (*Instance) ComposeSOARecord

func (inst *Instance) ComposeSOARecord(rec *m.Record) (record dns.RR, extras []dns.RR, err error)

ComposeSOARecord creates a DNS SOA record from a PocketBase record. It returns the composed SOA record and any additional records needed.

func (*Instance) ComposeSRVRecord

func (inst *Instance) ComposeSRVRecord(rec *m.Record) (record dns.RR, extras []dns.RR, err error)

ComposeSRVRecord creates a DNS SRV record from a PocketBase record. It returns the composed SRV record and any additional records needed.

func (*Instance) ComposeTXTRecord

func (inst *Instance) ComposeTXTRecord(rec *m.Record) (record dns.RR, extras []dns.RR, err error)

ComposeTXTRecord creates a DNS TXT record from a PocketBase record. It returns the composed TXT record and any additional records needed.

func (*Instance) FetchRecords

func (inst *Instance) FetchRecords(zone string, name string, types ...string) (recs []*m.Record, err error)

FetchRecords retrieves DNS records from PocketBase for a given zone, name, and record types. It first checks the cache if enabled, then queries the database if not found in cache. For wildcard records, it recursively checks parent domains until a match is found. Returns a slice of records and any error encountered.

func (*Instance) FetchZones

func (inst *Instance) FetchZones() (zones []string, err error)

FetchZones retrieves all unique DNS zones from PocketBase. It first checks the cache if enabled, then queries the database if not found in cache. Returns a slice of zone names and any error encountered.

func (*Instance) Hosts

func (inst *Instance) Hosts(zone string, name string) (answers []dns.RR, err error)

Hosts retrieves and composes DNS resource records for a given zone and name. It supports A, AAAA, and CNAME record types. Returns a slice of DNS resource records and any error encountered.

func (*Instance) Start

func (inst *Instance) Start() error

Start initializes and starts the PocketBase server. It configures the server to run in development mode and sets up necessary hooks. Returns an error if the server fails to start.

func (*Instance) WaitForReady

func (inst *Instance) WaitForReady()

WaitForReady blocks until the PocketBase instance is fully initialized and ready to serve requests.

func (*Instance) WithCacheCapacity

func (inst *Instance) WithCacheCapacity(capacity int) *Instance

WithCacheCapacity sets the capacity for the records cache. If capacity is greater than 1, both zones and records caching will be enabled. If there's an error initializing the cache, caching will be disabled.

func (*Instance) WithDefaultTtl

func (inst *Instance) WithDefaultTtl(defaultTtl int) *Instance

WithDefaultTtl sets the default TTL (Time To Live) for DNS records. This value will be used when no specific TTL is provided for a record.

func (*Instance) WithListen

func (inst *Instance) WithListen(listen string) *Instance

WithListen sets the address and port where the PocketBase server should listen. The format should be "address:port".

func (*Instance) WithSuPassword

func (inst *Instance) WithSuPassword(suPassword string) *Instance

WithSuPassword sets the superuser password for the Instance. This is used for authentication and administrative operations.

func (*Instance) WithSuUserName

func (inst *Instance) WithSuUserName(suEmail string) *Instance

WithSuUserName sets the superuser email for the Instance. This is used for authentication and administrative operations.

Directories

Path Synopsis
Package cache provides caching functionality for DNS records and zones.
Package cache provides caching functionality for DNS records and zones.

Jump to

Keyboard shortcuts

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