mirror of
https://github.com/lxc/incus.git
synced 2026-02-05 09:46:19 +01:00
Merge pull request #2843 from dankm/dns-soa
Use the standard DNS SOA format
This commit is contained in:
@@ -2970,3 +2970,7 @@ This adds a new `X-Incus-force` HTTP header that when set to `true` allows for r
|
||||
## `nic_sriov_select_ext`
|
||||
|
||||
Adds support for selecting an SR-IOV network interface by vendor ID, product ID, or PCI address.
|
||||
|
||||
## `network_zones_dns_contact`
|
||||
|
||||
Adds a `dns.contact` configuration key to network zones.
|
||||
|
||||
@@ -4173,6 +4173,13 @@ User keys can be used in search.
|
||||
|
||||
<!-- config group network_sriov-common end -->
|
||||
<!-- config group network_zone-common start -->
|
||||
```{config:option} dns.contact network_zone-common
|
||||
:required: "no"
|
||||
:shortdesc: "Admin contact email for DNS server"
|
||||
:type: "string"
|
||||
|
||||
```
|
||||
|
||||
```{config:option} dns.nameservers network_zone-common
|
||||
:required: "no"
|
||||
:shortdesc: "Comma-separated list of DNS server FQDNs (for NS records)"
|
||||
|
||||
@@ -4727,6 +4727,14 @@
|
||||
"network_zone": {
|
||||
"common": {
|
||||
"keys": [
|
||||
{
|
||||
"dns.contact": {
|
||||
"longdesc": "",
|
||||
"required": "no",
|
||||
"shortdesc": "Admin contact email for DNS server",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"dns.nameservers": {
|
||||
"longdesc": "",
|
||||
|
||||
@@ -173,6 +173,14 @@ func (d *zone) validateConfig(info *api.NetworkZonePut) error {
|
||||
// shortdesc: Comma-separated list of DNS server FQDNs (for NS records)
|
||||
rules["dns.nameservers"] = validate.IsListOf(validate.IsAny)
|
||||
|
||||
// gendoc:generate(entity=network_zone, group=common, key=dns.contact)
|
||||
//
|
||||
// ---
|
||||
// type: string
|
||||
// required: no
|
||||
// shortdesc: Admin contact email for DNS server
|
||||
rules["dns.contact"] = validate.Optional(validate.IsAny)
|
||||
|
||||
// gendoc:generate(entity=network_zone, group=common, key=network.nat)
|
||||
//
|
||||
// ---
|
||||
@@ -571,15 +579,22 @@ func (d *zone) Content() (*strings.Builder, error) {
|
||||
nameservers = append(nameservers, entry)
|
||||
}
|
||||
|
||||
primary := "hostmaster." + d.info.Name
|
||||
primary := d.info.Name
|
||||
if len(nameservers) > 0 {
|
||||
primary = nameservers[0]
|
||||
}
|
||||
|
||||
contact := "hostmaster." + primary
|
||||
if len(d.info.Config["dns.contact"]) > 0 {
|
||||
contact = d.info.Config["dns.contact"]
|
||||
contact = strings.TrimSuffix(strings.TrimSpace(contact), ".")
|
||||
}
|
||||
|
||||
// Template the zone file.
|
||||
sb := &strings.Builder{}
|
||||
err = zoneTemplate.Execute(sb, map[string]any{
|
||||
"primary": primary,
|
||||
"contact": contact,
|
||||
"nameservers": nameservers,
|
||||
"zone": d.info.Name,
|
||||
"serial": time.Now().Unix(),
|
||||
@@ -605,15 +620,22 @@ func (d *zone) SOA() (*strings.Builder, error) {
|
||||
nameservers = append(nameservers, entry)
|
||||
}
|
||||
|
||||
primary := "hostmaster." + d.info.Name
|
||||
primary := d.info.Name
|
||||
if len(nameservers) > 0 {
|
||||
primary = nameservers[0]
|
||||
}
|
||||
|
||||
contact := "hostmaster." + primary
|
||||
if len(d.info.Config["dns.contact"]) > 0 {
|
||||
contact = d.info.Config["dns.contact"]
|
||||
contact = strings.TrimSuffix(strings.TrimSpace(contact), ".")
|
||||
}
|
||||
|
||||
// Template the zone file.
|
||||
sb := &strings.Builder{}
|
||||
err := zoneTemplate.Execute(sb, map[string]any{
|
||||
"primary": primary,
|
||||
"contact": contact,
|
||||
"nameservers": nameservers,
|
||||
"zone": d.info.Name,
|
||||
"serial": time.Now().Unix(),
|
||||
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
|
||||
// DNS zone template.
|
||||
var zoneTemplate = template.Must(template.New("zoneTemplate").Parse(`
|
||||
{{.zone}}. 3600 IN SOA {{.zone}}. {{.primary}}. {{.serial}} 120 60 86400 30
|
||||
{{.zone}}. 3600 IN SOA {{.primary}}. {{.contact}}. {{.serial}} 120 60 86400 30
|
||||
{{- range $index, $element := .nameservers}}
|
||||
{{$.zone}}. 300 IN NS {{$element}}.
|
||||
{{- end}}
|
||||
{{- range .records}}
|
||||
{{ if ne .name "@" }}{{.name}}.{{ end }}{{$.zone}}. {{.ttl}} IN {{.type}} {{.value}}
|
||||
{{- end}}
|
||||
{{.zone}}. 3600 IN SOA {{.zone}}. {{.primary}}. {{.serial}} 120 60 86400 30
|
||||
{{.zone}}. 3600 IN SOA {{.primary}}. {{.contact}}. {{.serial}} 120 60 86400 30
|
||||
`))
|
||||
|
||||
@@ -515,6 +515,7 @@ var APIExtensions = []string{
|
||||
"oidc_allowed_subnets",
|
||||
"file_delete_force",
|
||||
"nic_sriov_select_ext",
|
||||
"network_zones_dns_contact",
|
||||
}
|
||||
|
||||
// APIExtensionsCount returns the number of available API extensions.
|
||||
|
||||
Reference in New Issue
Block a user