Documentation
¶
Overview ¶
Package acme implements a CoreDNS plugin that handles ACME DNS-01 challenges. It provides a REST API for updating TXT records needed for ACME DNS-01 validation.
Index ¶
- Constants
- Variables
- type ACME
- type ACMETxt
- type APIConfig
- type Account
- type AuthConfig
- type BadgerDB
- func (b *BadgerDB) CleanupRecord(fqdn, value string) error
- func (b *BadgerDB) Close() error
- func (b *BadgerDB) GetAccount(username, zone string) (Account, error)
- func (b *BadgerDB) GetRecords(fqdn string) ([]string, error)
- func (b *BadgerDB) PresentRecord(fqdn, value string) error
- func (b *BadgerDB) RegisterAccount(account Account, hashedPassword []byte) error
- type CIDRList
- type DB
- type MemDB
- func (m *MemDB) CleanupRecord(fqdn string, value string) error
- func (m *MemDB) Close() error
- func (m *MemDB) GetAccount(username, subdomain string) (Account, error)
- func (m *MemDB) GetRecords(fqdn string) ([]string, error)
- func (m *MemDB) PresentRecord(fqdn string, value string) error
- func (m *MemDB) RegisterAccount(a Account, passwordHash []byte) error
- type RegisterRequest
- type SQLiteDB
- func (s *SQLiteDB) CleanupRecord(fqdn, value string) error
- func (s *SQLiteDB) Close() error
- func (s *SQLiteDB) Exec(query string, args ...any) (sql.Result, error)
- func (s *SQLiteDB) GetAccount(username, subdomain string) (Account, error)
- func (s *SQLiteDB) GetRecords(fqdn string) ([]string, error)
- func (s *SQLiteDB) PresentRecord(fqdn, value string) error
- func (s *SQLiteDB) Query(query string, args ...any) (*sql.Rows, error)
- func (s *SQLiteDB) QueryRow(query string, args ...any) *sql.Row
- func (s *SQLiteDB) RegisterAccount(a Account, passwordHash []byte) error
Constants ¶
const ACMEAccountKey key = 0
ACMEAccountKey is a context key for storing Account information
const ACMERequestKey key = 1
const TXT_LENGTH = 43
Variables ¶
var ( ErrNoAuthenticationCredentials = errors.New("no authentication credentials") ErrInvalidUsernameOrPassword = errors.New("invalid username or password") ErrAuthDisabled = errors.New("authentication disabled") )
var ( ErrRecordNotFound = errors.New("record not found") ErrReadOnlyDatabase = errors.New("database is in read-only mode") )
var ( // RequestCount exports a prometheus metric that is incremented every time a DNS request is processed by the acme plugin. RequestCount = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "acme", Name: "request_count_total", Help: "Counter of DNS requests served by the acme plugin.", }, []string{"server", "type"}) // APIRequestCount exports a prometheus metric that is incremented every time an API request is processed. APIRequestCount = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: "acme", Name: "api_request_count_total", Help: "Counter of API requests to the acme plugin.", }, []string{"server", "endpoint"}) )
Variables declared for monitoring.
Functions ¶
This section is empty.
Types ¶
type ACME ¶
type ACME struct {
Next plugin.Handler
Fall fall.F
Zones []string
AuthConfig AuthConfig
APIConfig APIConfig
TLSConfig *tls.Config
// contains filtered or unexported fields
}
ACME is a CoreDNS plugin that implements the ACME DNS challenge protocol
func (*ACME) Auth ¶
func (a *ACME) Auth(next http.HandlerFunc) http.HandlerFunc
Auth is middleware that authenticates API requests
type APIConfig ¶
type APIConfig struct {
// APIAddr is the address of the API server
APIAddr string
// EnableRegistration is a flag to enable registration
EnableRegistration bool
}
APIConfig holds API server configuration
type AuthConfig ¶
type AuthConfig struct {
// AllowedIPs is a list of IP addresses or CIDR blocks that are allowed to update records
AllowedIPs CIDRList
// ExtractIPFromHeader is the name of the header to use for client IP
ExtractIPFromHeader string
// RequireAuth determines if authentication is required for API record updates
RequireAuth bool
}
AuthConfig holds authentication configuration
type BadgerDB ¶
type BadgerDB struct {
// contains filtered or unexported fields
}
BadgerDB is an implementation of the DB interface using Badger
func NewBadgerDB ¶
NewBadgerDB creates a new BadgerDB instance
func NewBadgerDBWithROOption ¶
NewBadgerDBWithROOption creates a new BadgerDB instance with specified read-only option
func (*BadgerDB) CleanupRecord ¶
CleanupRecord removes a TXT record for a FQDN
func (*BadgerDB) GetAccount ¶
GetAccount retrieves an account by username and zone
func (*BadgerDB) GetRecords ¶
GetRecords retrieves all TXT values for a given FQDN
func (*BadgerDB) PresentRecord ¶
PresentRecord adds a TXT record for a FQDN
type CIDRList ¶
type CIDRList []string
func NewCIDRList ¶
NewCIDRList creates a new CIDRList from a comma-separated string
type DB ¶
type DB interface {
GetRecords(fqdn string) ([]string, error)
PresentRecord(fqdn string, value string) error
CleanupRecord(fqdn string, value string) error
RegisterAccount(account Account, hashedPassword []byte) error
GetAccount(username, zone string) (Account, error)
Close() error
}
DB interface for different database backends
type MemDB ¶
type MemDB struct {
// contains filtered or unexported fields
}
MemDB is an in-memory implementation of the DB interface
func (*MemDB) CleanupRecord ¶
CleanupRecord removes a DNS record
func (*MemDB) GetAccount ¶
GetAccount retrieves an account by username and zone, doing longest zone match
func (*MemDB) GetRecords ¶
GetRecords retrieves DNS records by FQDN
func (*MemDB) PresentRecord ¶
PresentRecord adds or updates a DNS record
type RegisterRequest ¶
type SQLiteDB ¶
type SQLiteDB struct {
// contains filtered or unexported fields
}
SQLiteDB is a SQLite implementation of the DB interface
func NewSQLiteDB ¶
NewSQLiteDB creates a new SQLite database
func NewSQLiteDBWithROOption ¶
NewSQLiteDBWithROOption creates a new SQLite database with specified read-only option
func (*SQLiteDB) CleanupRecord ¶
func (*SQLiteDB) GetAccount ¶
GetAccount retrieves an account by username and subdomain
func (*SQLiteDB) GetRecords ¶
GetRecord retrieves a DNS record by domain
func (*SQLiteDB) PresentRecord ¶
PresentRecord updates a DNS record