Documentation
¶
Index ¶
- Constants
- func ChangeOwnerHandler(c echo.Context) error
- func Commit(zoneId uint) error
- func CommitAllHandler(c echo.Context) error
- func CommitAllZones() (int, error)
- func CommitHandler(c echo.Context) error
- func DeleteRecord(zoneId uint, recordId uint) error
- func DeleteRecordHandler(c echo.Context) error
- func DeleteZone(zoneId uint) error
- func DeleteZoneFile(domain string) error
- func DeleteZoneFileHandler(c echo.Context) error
- func DeleteZoneHandler(c echo.Context) error
- func DeleteZoneOnSecondary(secondaryURL, token, domain string) error
- func FetchConfigData()
- func GetDNSSECStatusHandler(c echo.Context) error
- func GetDSRecords(domain string) ([]string, error)
- func GetDatabaseConnection() *gorm.DB
- func GetMetricsHandler(c echo.Context) error
- func GetRecordHandler(c echo.Context) error
- func GetRecordsHandler(c echo.Context) error
- func GetZoneHandler(c echo.Context) error
- func GetZonesHandler(c echo.Context) error
- func IsValidDomain(domain string) bool
- func NewRecordHandler(c echo.Context) error
- func NewZoneHandler(c echo.Context) error
- func PostBindReloadHandler(c echo.Context) error
- func PostZoneRefreshHandler(c echo.Context) error
- func PostZoneRetransferHandler(c echo.Context) error
- func PutBindConfigHandler(c echo.Context) error
- func PutZoneFileHandler(c echo.Context) error
- func RefreshZone(domain string) error
- func RefreshZoneOnSecondary(secondaryURL, token, domain string) error
- func ReloadBind() error
- func RetransferZone(domain string) error
- func RetransferZoneOnSecondary(secondaryURL, token, domain string) error
- func Run()
- func SentryMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func SetDNSSEC(zoneId uint, enabled bool) error
- func SetDNSSECHandler(c echo.Context) error
- func SetMasterBindConfig()
- func SetNameServerIPs()
- func SetSlavesBindConfig()
- func SyncBindConfigToSecondary(secondaryURL, token, content string) error
- func SyncZoneToSecondary(secondaryURL, token, domain, content string) error
- func TestZoneHandler(c echo.Context) error
- func TokenMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func UpdateRecordHandler(c echo.Context) error
- func UpdateZoneHandler(c echo.Context) error
- func WriteBindConfig(configPath, content string) error
- func WriteZoneFile(domain, content string) error
- func ZoneStatusHandler(c echo.Context) error
- type ChangeOwnerRequest
- type Config
- type CreateRecordRequest
- type CreateZoneRequest
- type DNSCheckRecord
- type DNSCheckResponse
- type DNSKEYRecord
- type DNSSECStatusResponse
- type ErrorResponse
- type MessageResponse
- type Record
- type SetDNSSECRequest
- type UpdateRecordRequest
- type UpdateZoneRequest
- type Zone
- func (z *Zone) AddRecord(name string, ttl int, recordType string, prio int, value string) (*Record, []error)
- func (z *Zone) Render() string
- func (z *Zone) RenderAbuseEmail() string
- func (z *Zone) RenderPrimary() string
- func (z *Zone) RenderSecondary() string
- func (z *Zone) SetNewSerial()
- func (z *Zone) Validate() []error
- type ZoneNSStatus
- type ZoneStatusResponse
Examples ¶
Constants ¶
const ( RuntimeModePrimary = "primary" RuntimeModeSecondary = "secondary" )
const ( SecondaryZoneSyncTransfer = "transfer" SecondaryZoneSyncPush = "push" )
const ( // Where zones are saved in bind's config directory PrimaryZonePath = "/var/cache/bind" // Where bind's configuration is saved in bind's directory (master) PrimaryBindConfigPath = "/etc/bind/named.conf.rosti" // Where bind's configuration is saved in bind's directory (slave) SecondaryBindConfigPath = "/etc/bind/named.conf.rosti" RECORD_NOT_FOUND_MESSAGE = "record not found" )
Variables ¶
This section is empty.
Functions ¶
func ChangeOwnerHandler ¶
@Summary Change zone owner @Description Change the owner of a zone. Optionally pass ?owner= to require the zone to currently belong to that owner before the change is applied (returns 404 if not). @ID change-zone-owner @Tags zones @Security ApiKeyAuth @Accept json @Produce json @Param zone_id path int true "Zone ID" @Param owner query string false "Require zone to be owned by this owner (returns 404 if not)" @Param body body ChangeOwnerRequest true "New owner" @Success 200 {object} Zone @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /zones/{zone_id}/owner [patch]
func CommitAllHandler ¶
@Summary Commit all zones @Description Commit every zone in the database, regenerating zone files and syncing to secondaries. Returns the count of successfully committed zones. @ID commit-all-zones @Tags zones @Security ApiKeyAuth @Produce json @Success 200 {object} map[string]int @Failure 500 {object} ErrorResponse @Router /zones/commit-all [put]
func CommitAllZones ¶
CommitAllZones commits every zone in the database in bulk, avoiding the named.conf write/reload race that occurs when calling Commit() per zone. Zone files are written sequentially, then named.conf is written and bind is reloaded exactly once. Secondary sync and transfer happen in goroutines.
func CommitHandler ¶
@Summary Commit zone @Description Write zone changes into DNS servers. @ID commit-zone @Tags zones @Security ApiKeyAuth @Produce json @Param zone_id path int true "Zone ID" @Param owner query string false "Require zone to be owned by this owner (returns 404 if not)" @Success 200 {object} MessageResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /zones/{zone_id}/commit [put]
func DeleteRecordHandler ¶
@Summary Delete record @Description Delete a record within a zone. @ID delete-record @Tags records @Security ApiKeyAuth @Produce json @Param zone_id path int true "Zone ID" @Param record_id path int true "Record ID" @Param owner query string false "Require zone to be owned by this owner (returns 404 if not)" @Success 200 {object} MessageResponse @Failure 404 {object} ErrorResponse @Failure 400 {object} ErrorResponse @Router /zones/{zone_id}/records/{record_id} [delete]
func DeleteZoneFile ¶
DeleteZoneFile removes a zone file. Returns nil if the file does not exist.
func DeleteZoneFileHandler ¶
@Summary Delete zone file (secondary mode) @Description Removes a zone file from the bind zone directory. @ID delete-zone-file @Tags secondary @Security ApiKeyAuth @Param domain path string true "Zone domain name" @Produce json @Success 200 {object} MessageResponse @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /bind/zones/{domain} [delete]
func DeleteZoneHandler ¶
@Summary Delete zone @Description Delete a zone and all its records. @ID delete-zone @Tags zones @Security ApiKeyAuth @Produce json @Param zone_id path int true "Zone ID" @Param owner query string false "Require zone to be owned by this owner (returns 404 if not)" @Success 200 {object} MessageResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /zones/{zone_id} [delete]
func DeleteZoneOnSecondary ¶
DeleteZoneOnSecondary removes a zone file on a secondary instance.
func FetchConfigData ¶
func FetchConfigData()
func GetDNSSECStatusHandler ¶
@Summary Get DNSSEC status @Description Return DNSSEC status and DS records for a zone. DS records are generated by BIND asynchronously; the pending field is true while BIND has not yet created the keys. @ID get-dnssec-status @Tags zones @Security ApiKeyAuth @Produce json @Param zone_id path int true "Zone ID" @Param owner query string false "Require zone to be owned by this owner (returns 404 if not)" @Success 200 {object} DNSSECStatusResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /zones/{zone_id}/dnssec [get]
func GetDSRecords ¶
GetDSRecords returns the DS record lines for a domain by examining KSK/CSK key files in config.DNSSECKeyDirectory and computing DS records in pure Go. Returns an empty slice (not an error) when no key files exist yet — BIND generates them asynchronously after the first reload with dnssec-policy enabled.
func GetDatabaseConnection ¶
func GetMetricsHandler ¶
@Summary Metrics @Description Return prometheus metrics. @ID metrics @Tags default @Produce plain @Success 200 {string} string @Failure 500 {object} ErrorResponse @Router /metrics [get]
func GetRecordHandler ¶
@Summary Get record @Description Return one record within a zone. @ID get-record @Tags records @Security ApiKeyAuth @Produce json @Param zone_id path int true "Zone ID" @Param record_id path int true "Record ID" @Param owner query string false "Require zone to be owned by this owner (returns 404 if not)" @Success 200 {object} Record @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /zones/{zone_id}/records/{record_id} [get]
func GetRecordsHandler ¶
@Summary List records @Description Return all records for a zone. @ID get-records @Tags records @Security ApiKeyAuth @Produce json @Param zone_id path int true "Zone ID" @Param owner query string false "Require zone to be owned by this owner (returns 404 if not)" @Success 200 {array} Record @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /zones/{zone_id}/records/ [get]
func GetZoneHandler ¶
@Summary Get zone @Description Return one zone including records. @ID get-zone @Tags zones @Security ApiKeyAuth @Produce json @Param zone_id path int true "Zone ID" @Param owner query string false "Require zone to be owned by this owner (returns 404 if not)" @Success 200 {object} Zone @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /zones/{zone_id} [get]
func GetZonesHandler ¶
@Summary List zones @Description Return all zones including records. Optionally filter by owner using the `owner` query parameter. @ID get-zones @Tags zones @Security ApiKeyAuth @Produce json @Param owner query string false "Filter zones by owner" @Success 200 {array} Zone @Failure 500 {object} ErrorResponse @Router /zones/ [get]
func IsValidDomain ¶
IsValidDomain returns true when domain looks like a proper DNS zone name.
func NewRecordHandler ¶
@Summary Create record @Description Create a new record in a zone. Call commit afterwards to write it to bind. @ID create-record @Tags records @Security ApiKeyAuth @Accept json @Produce json @Param zone_id path int true "Zone ID" @Param owner query string false "Require zone to be owned by this owner (returns 404 if not)" @Param record body CreateRecordRequest true "Record payload" @Success 201 {object} Record @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Router /zones/{zone_id}/records/ [post]
func NewZoneHandler ¶
@Summary Create zone @Description Create a new zone. @ID create-zone @Tags zones @Security ApiKeyAuth @Accept json @Produce json @Param zone body CreateZoneRequest true "Zone payload" @Success 201 {object} Zone @Failure 400 {object} ErrorResponse @Router /zones/ [post]
func PostBindReloadHandler ¶
@Summary Reload bind9 (secondary mode) @Description Reloads bind9 via the configured reload command. @ID post-bind-reload @Tags secondary @Security ApiKeyAuth @Produce json @Success 200 {object} MessageResponse @Failure 500 {object} ErrorResponse @Router /bind/reload [post]
func PostZoneRefreshHandler ¶
@Summary Refresh zone (secondary mode) @Description Forces a zone refresh using the configured refresh command. @ID post-zone-refresh @Tags secondary @Security ApiKeyAuth @Param domain path string true "Zone domain name" @Produce json @Success 200 {object} MessageResponse @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /bind/refresh/{domain} [post]
func PostZoneRetransferHandler ¶
@Summary Retransfer zone (secondary mode) @Description Forces a secondary zone transfer using the configured retransfer command. @ID post-zone-retransfer @Tags secondary @Security ApiKeyAuth @Param domain path string true "Zone domain name" @Produce json @Success 200 {object} MessageResponse @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /bind/retransfer/{domain} [post]
func PutBindConfigHandler ¶
@Summary Write bind config (secondary mode) @Description Receives a rendered named.conf include file, writes it to disk, and reloads bind9. @ID put-bind-config @Tags secondary @Security ApiKeyAuth @Accept plain @Produce json @Success 200 {object} MessageResponse @Failure 500 {object} ErrorResponse @Router /bind/config [put]
func PutZoneFileHandler ¶
@Summary Write zone file (secondary mode) @Description Receives a zone file and writes it to the bind zone directory. @ID put-zone-file @Tags secondary @Security ApiKeyAuth @Accept plain @Param domain path string true "Zone domain name" @Produce json @Success 200 {object} MessageResponse @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /bind/zones/{domain} [put]
func RefreshZone ¶
RefreshZone forces a zone refresh using the configured refresh command.
func RefreshZoneOnSecondary ¶
RefreshZoneOnSecondary asks a secondary instance to run the refresh command for the given zone.
func ReloadBind ¶
func ReloadBind() error
ReloadBind reloads bind9 using the configured reload command.
func RetransferZone ¶
RetransferZone forces a secondary zone transfer, bypassing SOA serial comparison.
func RetransferZoneOnSecondary ¶
RetransferZoneOnSecondary asks a secondary instance to force-transfer the given zone.
func SentryMiddleware ¶
func SentryMiddleware(next echo.HandlerFunc) echo.HandlerFunc
func SetDNSSEC ¶
SetDNSSEC enables or disables DNSSEC for the zone, commits it and rebuilds the primary bind config.
func SetDNSSECHandler ¶
@Summary Set DNSSEC @Description Enable or disable DNSSEC for a zone. When enabled, the zone is committed and BIND generates signing keys automatically using dnssec-policy default (ECDSAP256SHA256 + NSEC3). DS records become available via GET /zones/:zone_id/dnssec once BIND has generated the keys (typically within 30 seconds). @ID set-dnssec @Tags zones @Security ApiKeyAuth @Accept json @Produce json @Param zone_id path int true "Zone ID" @Param owner query string false "Require zone to be owned by this owner (returns 404 if not)" @Param body body SetDNSSECRequest true "DNSSEC toggle" @Success 200 {object} DNSSECStatusResponse @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /zones/{zone_id}/dnssec [put]
func SetMasterBindConfig ¶
func SetMasterBindConfig()
SetMasterBindConfig generates the primary bind config from the DB, writes it locally, then reloads bind.
func SetNameServerIPs ¶
func SetNameServerIPs()
If necessary, this takes PrimaryNameServer and NameServers domain names and resolves IP addresses for PrimaryNameServerIP and SecondaryNameServerIPs. Panic in case of fire!
func SetSlavesBindConfig ¶
func SetSlavesBindConfig()
SetSlavesBindConfig generates the secondary bind config from the DB and pushes it to all secondary instances.
func SyncBindConfigToSecondary ¶
SyncBindConfigToSecondary pushes a rendered bind config to a secondary instance.
func SyncZoneToSecondary ¶
SyncZoneToSecondary pushes a zone file to a secondary instance.
func TestZoneHandler ¶
@Summary Test zone DNS @Description Compare zone records in the database against what the primary and secondary nameservers currently serve. @ID test-zone @Tags zones @Security ApiKeyAuth @Produce json @Param zone_id path int true "Zone ID" @Success 200 {object} DNSCheckResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /zones/{zone_id}/test [get]
func TokenMiddleware ¶
func TokenMiddleware(next echo.HandlerFunc) echo.HandlerFunc
Process is the middleware function.
func UpdateRecordHandler ¶
@Summary Update record @Description Update an existing record within a zone. Type cannot be changed; delete and recreate instead. Call commit afterwards. @ID update-record @Tags records @Security ApiKeyAuth @Accept json @Produce json @Param zone_id path int true "Zone ID" @Param record_id path int true "Record ID" @Param owner query string false "Require zone to be owned by this owner (returns 404 if not)" @Param record body UpdateRecordRequest true "Record fields to update" @Success 200 {object} Record @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Router /zones/{zone_id}/records/{record_id} [put]
func UpdateZoneHandler ¶
@Summary Update zone @Description Update zone metadata (tags and abuse email only). Use the records endpoints to manage records. @ID update-zone @Tags zones @Security ApiKeyAuth @Accept json @Produce json @Param zone_id path int true "Zone ID" @Param owner query string false "Require zone to be owned by this owner (returns 404 if not)" @Param zone body UpdateZoneRequest true "Zone metadata to update" @Success 200 {object} Zone @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Router /zones/{zone_id} [put]
func WriteBindConfig ¶
WriteBindConfig writes content to a named.conf include file at configPath.
func WriteZoneFile ¶
WriteZoneFile writes a zone file to the bind zone directory.
func ZoneStatusHandler ¶
@Summary Zone status @Description Check whether the zone has uncommitted changes and whether it is configured on all nameservers. @ID zone-status @Tags zones @Security ApiKeyAuth @Produce json @Param zone_id path int true "Zone ID" @Success 200 {object} ZoneStatusResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /zones/{zone_id}/status [get]
Types ¶
type ChangeOwnerRequest ¶
type ChangeOwnerRequest struct {
Owner string `json:"owner" example:"company1234"`
}
ChangeOwnerRequest is the body accepted by PATCH /zones/:zone_id/owner.
type Config ¶
type Config struct {
Mode string `default:"primary" split_words:"true"` // Runtime mode: primary or secondary
PrimaryNameServerIP string `split_words:"true"` // If not set, automatically resolved from PrimaryNameServer
SecondaryNameServerIPs []string `envconfig:"SECONDARY_NAME_SERVER_IPS"` // If not set, automatically resolved from NameServers
ExtraAllowTransferIPs []string `envconfig:"EXTRA_ALLOW_TRANSFER_IPS"` // Additional IPs appended to allow-transfer in every primary zone block
SecondaryInstances []string `split_words:"true"` // Secondary dnsapi instances for sync fanout
PrimaryNameServer string `split_words:"true"` // Bind's master server
NameServers []string `split_words:"true"` // Bind's slave servers
AbuseEmail string `split_words:"true"` // Abuse email
TimeToRefresh int `default:"300" split_words:"true"` // Time to refresh the records on slaves
TimeToRetry int `default:"180" split_words:"true"` // Time to waif for another try if connection fails
TimeToExpire int `default:"604800" split_words:"true"` // Time to expire when the domain is not available on master
MinimalTTL int `default:"30" split_words:"true"` // Minimal TTL
TTL int `default:"3600"` // Default TTL
DatabasePath string `default:"gorm.sqlite" split_words:"true"` // Path to the database
BindReloadCommand string `default:"systemctl reload bind9" split_words:"true"` // Command used to reload bind9
BindRefreshCommand string `default:"rndc refresh" split_words:"true"` // Command used to refresh a zone (domain appended as last argument)
BindRetransferCommand string `split_words:"true"` // Command used to force a secondary zone transfer (domain appended as last argument)
DNSSECKeyDirectory string `default:"/var/cache/bind/keys" split_words:"true"` // Directory where BIND stores DNSSEC keys (used with dnssec-policy)
SecondaryZoneSyncMode string `default:"transfer" split_words:"true"` // Secondary zone sync mode: transfer or push
APIToken string `default:"" envconfig:"API_TOKEN"` // Token to access the API
PublicDomain string `split_words:"true"` // Public domain for this instance
HTTPS bool `split_words:"true"` // Serve HTTPS and obtain Let's Encrypt certs
ACMEEmail string `split_words:"true"` // Email for Let's Encrypt
SentryDSN string `split_words:"true"` // Sentry DSN
SentryENV string `default:"dev" split_words:"true"` // Sentry environment
Port uint16 `default:"1323"` // Port where the API listens
}
Configuration struct. All input form the maintainer is available through this struct.
func (*Config) IsPrimaryMode ¶
func (*Config) IsSecondaryMode ¶
func (*Config) RenderEmail ¶
Reformat the email so it can be used in zone files
func (*Config) SecondaryInstanceList ¶
func (*Config) UsesSecondaryZonePush ¶
type CreateRecordRequest ¶
type CreateRecordRequest struct {
Name string `json:"name" example:"www"`
TTL int `json:"ttl" example:"3600"`
Type string `json:"type" example:"A"`
Prio int `json:"prio" example:"0"`
Value string `json:"value" example:"1.2.3.4"`
}
CreateRecordRequest is the body accepted by POST /zones/:id/records/.
type CreateZoneRequest ¶
type CreateZoneRequest struct {
Domain string `json:"domain" example:"example.com"`
Tags string `json:"tags" example:"tag1,tag2"`
AbuseEmail string `json:"abuse_email" example:"admin@example.com"`
Owner string `json:"owner" example:"alice"`
}
CreateZoneRequest is the body accepted by POST /zones/.
type DNSCheckRecord ¶
type DNSCheckRecord struct {
RecordID uint `json:"record_id"`
Name string `json:"name"`
FQDN string `json:"fqdn"`
Type string `json:"type"`
DBValue string `json:"db_value"`
PrimaryValues []string `json:"primary_values"`
SecondaryValues []string `json:"secondary_values"`
PrimaryOK bool `json:"primary_ok"`
SecondaryOK bool `json:"secondary_ok"`
Supported bool `json:"supported"`
Error string `json:"error,omitempty"`
}
DNSCheckRecord holds the comparison result for one zone record.
type DNSCheckResponse ¶
type DNSCheckResponse struct {
ZoneID uint `json:"zone_id"`
Domain string `json:"domain"`
PrimaryNS string `json:"primary_ns"`
SecondaryNS []string `json:"secondary_ns"`
Records []DNSCheckRecord `json:"records"`
}
DNSCheckResponse is the response body for TestZoneHandler.
type DNSKEYRecord ¶
type DNSKEYRecord struct {
Name string `json:"name"`
Flags int `json:"flags"`
Protocol int `json:"protocol"`
Algorithm int `json:"algorithm"`
Key string `json:"key"`
KeyTag uint16 `json:"key_tag"`
DNSKEY string `json:"dnskey"`
}
DNSKEYRecord is a public DNSKEY record returned by DNSSEC status endpoints.
func GetDNSSECKeyRecords ¶
func GetDNSSECKeyRecords(domain string) ([]string, []DNSKEYRecord, error)
GetDNSSECKeyRecords returns DS and DNSKEY records for KSK/CSK key files.
type DNSSECStatusResponse ¶
type DNSSECStatusResponse struct {
Enabled bool `json:"enabled"`
Pending bool `json:"pending"`
DSRecords []string `json:"ds_records"`
DNSKEYRecords []DNSKEYRecord `json:"dnskey_records"`
}
DNSSECStatusResponse is returned by GET /zones/:zone_id/dnssec.
func GetDNSSECStatus ¶
func GetDNSSECStatus(zoneId uint) (*DNSSECStatusResponse, error)
GetDNSSECStatus returns the current DNSSEC state for the zone, including any DNSSEC records that BIND has already generated. When enabled but keys are not yet available, Pending is true.
type ErrorResponse ¶
type ErrorResponse struct {
Message string `json:"message"`
}
type MessageResponse ¶
type MessageResponse struct {
Message string `json:"message"`
}
type Record ¶
type Record struct {
ID uint `json:"id" gorm:"primary_key"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ZoneId uint `json:"-" sql:"index"`
Name string `json:"name"`
TTL int `json:"ttl"`
Type string `json:"type"` // A, AAAA, CNAME, TXT, SRV
Prio int `json:"prio"`
Value string `json:"value"`
}
func NewRecord ¶
func NewRecord(zoneId uint, name string, ttl int, recordType string, prio int, value string) (*Record, []error)
Create a new record
type SetDNSSECRequest ¶
type SetDNSSECRequest struct {
Enabled bool `json:"enabled" example:"true"`
}
SetDNSSECRequest is the body accepted by PUT /zones/:zone_id/dnssec.
type UpdateRecordRequest ¶
type UpdateRecordRequest struct {
Name string `json:"name" example:"www"`
TTL int `json:"ttl" example:"3600"`
Prio int `json:"prio" example:"0"`
Value string `json:"value" example:"1.2.3.4"`
}
UpdateRecordRequest is the body accepted by PUT /zones/:id/records/:record_id. Type cannot be changed; delete and recreate the record instead.
type UpdateZoneRequest ¶
type UpdateZoneRequest struct {
Tags string `json:"tags" example:"tag1,tag2"`
AbuseEmail string `json:"abuse_email" example:"admin@example.com"`
Owner string `json:"owner" example:"alice"`
}
UpdateZoneRequest is the body accepted by PUT /zones/:id. Only tags, abuse_email and owner can be changed; domain and records are managed separately.
type Zone ¶
type Zone struct {
ID uint `json:"id" gorm:"primary_key"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Delete bool `json:"delete" gorm:"DEFAULT:0"`
Domain string `json:"domain" sql:"index"`
Serial string `json:"serial"`
CommittedSerial string `json:"committed_serial"`
Records []Record `json:"records" gorm:"foreignkey:ZoneID"`
Tags string `json:"tags"` // Tags separated by comma
AbuseEmail string `json:"abuse_email"`
Owner string `json:"owner"`
DNSSECEnabled bool `json:"dnssec_enabled" gorm:"column:dnssec_enabled;DEFAULT:0"`
}
Example ¶
// A valid zone
zone, errs := NewZone("B-"+TEST_DOMAIN, []string{"test_tag_1", "test_tag_2"}, TEST_ABUSE_EMAIL, "testowner")
if len(errs) != 0 {
panic(errs)
}
zone.SetNewSerial()
zone.AddRecord("@", 300, "A", 0, "1.2.3.4")
zone.AddRecord("@", 300, "AAAA", 0, "2001::2")
zone.AddRecord("www", 300, "CNAME", 0, "@")
zone.AddRecord("@", 300, "MX", 10, "mail.rosti.cz.")
zone.AddRecord("@", 300, "TXT", 0, "igeeweofeiroomoogokieghaithohthaechoocherohveehiebawuyeixeecoveegoeyohfachainauquaeceetipheivubohmoegheizeelaiquanaokooquiedokaidurahveehoshazaseveitheiyitachudiishaeghaexoovachacaijuyiedeochojingafeexusuquaingeiboovachahlaechahcashoophairohthaghobahjaixieboteixameimohmaedahriebaekoshohpeecueyaoseeveibavaithohquaevoalohreingewiesaijiojiehielahzaelohpechuohiefaeyaetiegengahgatheefaipeimeeviedimibohmoyajefahghaaraehieyiepameegheathaechielixahbeidohyaitionahjaenoshikahbahyaebeachahxalaeghuloochaekuthaiquaedoo")
zone.Serial = "2018053001"
renderedZone := zone.Render()
h := sha256.New()
h.Write([]byte(renderedZone))
fmt.Printf("%x", h.Sum(nil))
Output: 635d2be2a44773e301a0938357b868dbfe5282b2e516e28d21c4b0e41d642333
func ChangeOwner ¶
ChangeOwner updates only the owner field of an existing zone.
func UpdateZone ¶
Update existing zone
func (*Zone) RenderAbuseEmail ¶
func (*Zone) RenderPrimary ¶
Example ¶
zone, errs := NewZone("C-"+TEST_DOMAIN, []string{"test_tag_1", "test_tag_2"}, TEST_ABUSE_EMAIL, "testowner")
if len(errs) != 0 {
panic(errs)
}
zone.SetNewSerial()
zone.AddRecord("@", 300, "A", 0, "1.2.3.4")
fmt.Println(zone.RenderPrimary())
Output: zone "c-ohphiuhi.txt" IN { type master; masterfile-format text; file "c-ohphiuhi.txt.zone"; allow-query { any; }; allow-transfer { 5.6.7.8; }; notify yes; };
func (*Zone) RenderSecondary ¶
Example ¶
zone, errs := NewZone("D-"+TEST_DOMAIN, []string{"test_tag_1", "test_tag_2"}, TEST_ABUSE_EMAIL, "testowner")
if len(errs) != 0 {
panic(errs)
}
zone.SetNewSerial()
zone.AddRecord("@", 300, "A", 0, "1.2.3.4")
fmt.Println(zone.RenderSecondary())
Output: zone "d-ohphiuhi.txt" IN { type slave; masterfile-format text; file "d-ohphiuhi.txt.zone"; allow-query { any; }; masters { 1.2.3.4; }; };
func (*Zone) SetNewSerial ¶
func (z *Zone) SetNewSerial()
type ZoneNSStatus ¶
type ZoneNSStatus struct {
IP string `json:"ip"`
Configured bool `json:"configured"`
Error string `json:"error,omitempty"`
}
ZoneNSStatus is the NS-reachability result for one nameserver.
type ZoneStatusResponse ¶
type ZoneStatusResponse struct {
ZoneID uint `json:"zone_id"`
Domain string `json:"domain"`
DBSerial string `json:"db_serial"`
CommittedSerial string `json:"committed_serial"`
NeedsCommit bool `json:"needs_commit"`
Primary ZoneNSStatus `json:"primary"`
Secondary []ZoneNSStatus `json:"secondary"`
AllConfigured bool `json:"all_configured"`
}
ZoneStatusResponse is returned by GET /zones/:zone_id/status.