Documentation
¶
Overview ¶
Package knot implements a client for the Knot DNS server's control protocol.
Index ¶
- Constants
- Variables
- type Conn
- func (c *Conn) Close()
- func (c *Conn) Command(data Data) ([]Data, error)
- func (c *Conn) ConfAbort() ([]Data, error)
- func (c *Conn) ConfBegin() ([]Data, error)
- func (c *Conn) ConfCheck() ([]Data, error)
- func (c *Conn) ConfCommit() ([]Data, error)
- func (c *Conn) ConfDiff(section, id, item string) ([]Data, error)
- func (c *Conn) ConfExport(filename string, schema bool) ([]Data, error)
- func (c *Conn) ConfGet(section, id, item string) ([]Data, error)
- func (c *Conn) ConfImport(filename string, nopurge bool) ([]Data, error)
- func (c *Conn) ConfInit() ([]Data, error)
- func (c *Conn) ConfList(section, id, item string) ([]Data, error)
- func (c *Conn) ConfRead(section, id, item string) ([]Data, error)
- func (c *Conn) ConfSet(section, id, item string, data ...string) ([]Data, error)
- func (c *Conn) ConfUnset(section, id, item string, data ...string) ([]Data, error)
- func (c *Conn) Connect(path string) error
- func (c *Conn) ReadResponse() ([]Data, error)
- func (c *Conn) Receive() (Type, Data, error)
- func (c *Conn) Reload() ([]Data, error)
- func (c *Conn) Send(t Type, data *Data) error
- func (c *Conn) SendCommand(data Data) error
- func (c *Conn) SetTimeout(ms int)
- func (c *Conn) Stats(module, counter string) ([]Data, error)
- func (c *Conn) Status(detail string) ([]Data, error)
- func (c *Conn) Stop() ([]Data, error)
- func (c *Conn) ZoneAbort(zones ...string) ([]Data, error)
- func (c *Conn) ZoneBackup(backupDir, filters string, zones ...string) ([]Data, error)
- func (c *Conn) ZoneBegin(benevolent bool, zones ...string) ([]Data, error)
- func (c *Conn) ZoneCheck(zones ...string) ([]Data, error)
- func (c *Conn) ZoneCommit(zones ...string) ([]Data, error)
- func (c *Conn) ZoneDiff(zone string) ([]Data, error)
- func (c *Conn) ZoneFlush(filters string, zones ...string) ([]Data, error)
- func (c *Conn) ZoneFreeze(zones ...string) ([]Data, error)
- func (c *Conn) ZoneGet(zone, owner, rrType string) ([]Data, error)
- func (c *Conn) ZoneKSKSubmitted(zones ...string) ([]Data, error)
- func (c *Conn) ZoneKeyRollover(zone string, keyType KeyType) ([]Data, error)
- func (c *Conn) ZoneKeysLoad(zones ...string) ([]Data, error)
- func (c *Conn) ZoneNotify(zones ...string) ([]Data, error)
- func (c *Conn) ZonePurge(filters string, zones ...string) ([]Data, error)
- func (c *Conn) ZoneRead(zone, owner, rrType string) ([]Data, error)
- func (c *Conn) ZoneRefresh(zones ...string) ([]Data, error)
- func (c *Conn) ZoneReload(zones ...string) ([]Data, error)
- func (c *Conn) ZoneRestore(backupDir, filters string, zones ...string) ([]Data, error)
- func (c *Conn) ZoneRetransfer(zones ...string) ([]Data, error)
- func (c *Conn) ZoneSerialSet(zone, serial string) ([]Data, error)
- func (c *Conn) ZoneSet(zone, owner, ttl, rrType, rdata string) ([]Data, error)
- func (c *Conn) ZoneSign(zones ...string) ([]Data, error)
- func (c *Conn) ZoneStats(zone, module, counter string) ([]Data, error)
- func (c *Conn) ZoneStatus(filters string, zones ...string) ([]Data, error)
- func (c *Conn) ZoneThaw(zones ...string) ([]Data, error)
- func (c *Conn) ZoneUnset(zone, owner, rrType, rdata string) ([]Data, error)
- func (c *Conn) ZoneValidate(zones ...string) ([]Data, error)
- func (c *Conn) ZoneXFRFreeze(zones ...string) ([]Data, error)
- func (c *Conn) ZoneXFRThaw(zones ...string) ([]Data, error)
- type Data
- type KeyType
- type KnotError
- type ResponseError
- type Type
Constants ¶
const ( IdxCmd = 0 IdxFlags = 1 IdxError = 2 IdxSection = 3 IdxItem = 4 IdxID = 5 IdxZone = 6 IdxOwner = 7 IdxTTL = 8 IdxType = 9 IdxData = 10 IdxFilters = 11 )
Field index constants for Data, matching knot_ctl_idx_t.
const DataLen = 12
DataLen is the number of indexed fields in a control data unit. It matches KNOT_CTL_IDX__COUNT from libknot.
Variables ¶
var ErrAlloc = errors.New("knot: failed to allocate control context")
ErrAlloc is returned when libknot fails to allocate a control context.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a client connection to the knot control socket.
func (*Conn) Close ¶
func (c *Conn) Close()
Close closes the connection and frees the underlying C context. After Close, the Conn must not be used.
func (*Conn) Command ¶
Command sends a command and reads the full server response in one call. It is equivalent to calling SendCommand followed by ReadResponse.
func (*Conn) ConfCommit ¶
ConfCommit commits the current configuration transaction.
func (*Conn) ConfDiff ¶
ConfDiff returns configuration differences within the current transaction. All parameters are optional.
func (*Conn) ConfExport ¶
ConfExport exports the confdb. filename is optional (empty means stdout). Set schema to true to export the JSON schema instead of the configuration.
func (*Conn) ConfGet ¶
ConfGet reads configuration data within the current transaction. All parameters are optional.
func (*Conn) ConfImport ¶
ConfImport imports a configuration file into the confdb. Set nopurge to true to preserve existing confdb contents.
func (*Conn) ConfList ¶
ConfList lists confdb sections or items. All parameters are optional; pass empty strings to list all top-level sections.
func (*Conn) ConfSet ¶
ConfSet sets configuration item data within the current transaction. Additional values beyond the first are transmitted as TypeExtra units.
func (*Conn) ConfUnset ¶
ConfUnset removes configuration item data within the current transaction. Additional values beyond the first are transmitted as TypeExtra units.
func (*Conn) ReadResponse ¶
ReadResponse reads response units until the server sends a block or end marker. Each DATA and EXTRA unit is collected into the returned slice. If the server includes an error message in any unit, a *ResponseError is returned alongside whatever rows were collected before it.
func (*Conn) Send ¶
Send transmits a control unit of the given type. data is required for TypeData and TypeExtra; pass nil for TypeEnd and TypeBlock.
func (*Conn) SendCommand ¶
SendCommand sends a single data unit followed by a block marker, signalling to the server that the full request has been delivered.
func (*Conn) SetTimeout ¶
SetTimeout sets the socket operation timeout in milliseconds. Pass 0 for no timeout.
func (*Conn) Stats ¶
Stats returns global statistics. module and counter are both optional; pass empty strings to retrieve all counters across all modules.
func (*Conn) ZoneBackup ¶
ZoneBackup backs up zone data and metadata. backupDir is the +backupdir path (required). filters is optional. Pass no zones for all.
func (*Conn) ZoneBegin ¶
ZoneBegin begins a zone transaction. Set benevolent to true to tolerate a pre-existing transaction from another client. Pass no zones to begin a transaction for all zones.
func (*Conn) ZoneCheck ¶
ZoneCheck checks whether the given zones can be loaded. Pass no zones to check all configured zones.
func (*Conn) ZoneCommit ¶
ZoneCommit commits the current zone transaction. Pass no zones for all.
func (*Conn) ZoneFlush ¶
ZoneFlush flushes zone journals into zone files. filters is optional. Pass no zones for all.
func (*Conn) ZoneFreeze ¶
ZoneFreeze temporarily postpones automatic zone-changing events. Pass no zones for all.
func (*Conn) ZoneGet ¶
ZoneGet returns zone records within the current transaction. owner and rrType are optional filters.
func (*Conn) ZoneKSKSubmitted ¶
ZoneKSKSubmitted confirms that the parent DS record is present after KSK submission. Pass no zones for all.
func (*Conn) ZoneKeyRollover ¶
ZoneKeyRollover triggers an immediate key rollover for the given zone. keyType must be KeyTypeKSK or KeyTypeZSK.
func (*Conn) ZoneKeysLoad ¶
ZoneKeysLoad reloads keys from the KASP database and re-signs the zone. Pass no zones for all.
func (*Conn) ZoneNotify ¶
ZoneNotify sends a NOTIFY to all configured remotes. Pass no zones for all.
func (*Conn) ZonePurge ¶
ZonePurge purges zone data, zone file, journal, timers, and KASP data. filters is optional. Pass no zones for all.
func (*Conn) ZoneRead ¶
ZoneRead returns the zone records currently being served. owner and rrType are optional filters; pass empty strings to return all records.
func (*Conn) ZoneRefresh ¶
ZoneRefresh forces a slave zone refresh. Pass no zones for all.
func (*Conn) ZoneReload ¶
ZoneReload reloads zones from disk. Pass no zones to reload all.
func (*Conn) ZoneRestore ¶
ZoneRestore restores zone data and metadata. backupDir is the +backupdir path (required). filters is optional. Pass no zones for all.
func (*Conn) ZoneRetransfer ¶
ZoneRetransfer forces a slave zone retransfer without a serial check. Pass no zones for all.
func (*Conn) ZoneSerialSet ¶
ZoneSerialSet gets or sets the SOA serial for a zone. Pass an empty string to retrieve the current serial, a plain number to set it, or "+N" to increment by N.
func (*Conn) ZoneSet ¶
ZoneSet adds or replaces a zone record within the current transaction. ttl is optional; pass an empty string to use the zone default.
func (*Conn) ZoneStatus ¶
ZoneStatus returns the status of zones. filters is an optional space-separated list of +filter names (e.g. "+role +serial"). Pass no zones to query all configured zones.
func (*Conn) ZoneUnset ¶
ZoneUnset removes records from a zone within the current transaction. rrType and rdata narrow the match; pass empty strings to remove more broadly.
func (*Conn) ZoneValidate ¶
ZoneValidate triggers DNSSEC validation. Pass no zones for all.
func (*Conn) ZoneXFRFreeze ¶
ZoneXFRFreeze temporarily disables outgoing AXFR/IXFR. Pass no zones for all.
type Data ¶
Data holds the string fields of a knot control data unit. Index each field using the Idx* constants.
type KnotError ¶
type KnotError struct {
Code int
}
KnotError represents a libknot error code returned by the C library.
type ResponseError ¶
type ResponseError struct {
Message string
}
ResponseError is a server-side error reported inside a knot response unit.
func (*ResponseError) Error ¶
func (e *ResponseError) Error() string
type Type ¶
type Type int
Type is the type of a knot control unit.
const ( TypeEnd Type = Type(C.KNOT_CTL_TYPE_END) TypeData Type = Type(C.KNOT_CTL_TYPE_DATA) TypeExtra Type = Type(C.KNOT_CTL_TYPE_EXTRA) TypeBlock Type = Type(C.KNOT_CTL_TYPE_BLOCK) )
Control unit type constants, matching knot_ctl_type_t.