handler

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: 11 Imported by: 0

Documentation

Overview

Package handler provides configuration management for the CoreDNS PocketBase integration. It defines the configuration structure and default values for the service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigVal4DefaultTtl

func DefaultConfigVal4DefaultTtl() int

Types

type Config

type Config struct {
	// Listen is the address and port the service listens on
	Listen string
	// DataDir is the directory for PocketBase data storage
	DataDir string
	// SuEmail is the superuser email for PocketBase
	SuEmail string
	// SuPassword is the superuser password for PocketBase
	SuPassword string
	// CacheCapacity is the number of records to cache (0 means no caching)
	CacheCapacity int
	// DefaultTtl is the default TTL (Time To Live) in seconds for DNS records
	DefaultTtl int
}

Config represents the configuration for the CoreDNS PocketBase integration. It contains settings for the service's network interface, data storage, authentication, and caching behavior.

func NewConfig

func NewConfig() *Config

NewConfig creates a new Config instance with default values

func (*Config) MixWithEnv

func (c *Config) MixWithEnv() *Config

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid Returns an error if any required field is empty or if numeric values are negative

func (*Config) WithCacheCapacity

func (c *Config) WithCacheCapacity(cacheCapacity int) *Config

WithCacheCapacity sets the cache capacity and returns the modified Config

func (*Config) WithDataDir

func (c *Config) WithDataDir(dataDir string) *Config

WithDataDir sets the data directory and returns the modified Config

func (*Config) WithDefaultTtl

func (c *Config) WithDefaultTtl(defaultTtl int) *Config

WithDefaultTtl sets the default TTL and returns the modified Config

func (*Config) WithListen

func (c *Config) WithListen(listen string) *Config

WithListen sets the listen address and returns the modified Config

func (*Config) WithSuEmail

func (c *Config) WithSuEmail(suUserName string) *Config

WithSuEmail sets the superuser email and returns the modified Config

func (*Config) WithSuPassword

func (c *Config) WithSuPassword(suPassword string) *Config

WithSuPassword sets the superuser password and returns the modified Config

type ErrUnsupportedRecordType

type ErrUnsupportedRecordType struct {
	RecordType string
}

func (*ErrUnsupportedRecordType) Error

func (e *ErrUnsupportedRecordType) Error() string

type PocketBaseHandler

type PocketBaseHandler struct {
	Next plugin.Handler
	// contains filtered or unexported fields
}

func NewWithConfig

func NewWithConfig(config *Config) (handler *PocketBaseHandler, err error)

func (*PocketBaseHandler) Name

func (handler *PocketBaseHandler) Name() string

Name implements the Handler interface.

func (*PocketBaseHandler) ServeDNS

func (handler *PocketBaseHandler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handler interface. It processes DNS queries by: 1. Fetching available zones 2. Matching the query against available zones 3. Fetching and composing appropriate DNS records Returns DNS response code and any error encountered

func (*PocketBaseHandler) WarmUp

func (handler *PocketBaseHandler) WarmUp()

Directories

Path Synopsis
cache
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