mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 18:53:43 -04:00
core: small cleanup (#877)
Add some docs about normalize.Host and normalize.Name. They are used correctly in the middleware even though they are somewhat confusing, esp when you copy from ServerBlockKeys in your middleware.
This commit is contained in:
@@ -81,7 +81,6 @@ func autoParse(c *caddy.Controller) (Auto, error) {
|
||||
config := dnsserver.GetConfig(c)
|
||||
|
||||
for c.Next() {
|
||||
if c.Val() == "auto" {
|
||||
// auto [ZONES...]
|
||||
a.Zones.origins = make([]string, len(c.ServerBlockKeys))
|
||||
copy(a.Zones.origins, c.ServerBlockKeys)
|
||||
@@ -165,8 +164,6 @@ func autoParse(c *caddy.Controller) (Auto, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ func dnssecParse(c *caddy.Controller) ([]string, []*DNSKEY, int, error) {
|
||||
|
||||
capacity := defaultCap
|
||||
for c.Next() {
|
||||
if c.Val() == "dnssec" {
|
||||
// dnssec [zones...]
|
||||
zones = make([]string, len(c.ServerBlockKeys))
|
||||
copy(zones, c.ServerBlockKeys)
|
||||
@@ -73,7 +72,6 @@ func dnssecParse(c *caddy.Controller) ([]string, []*DNSKEY, int, error) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := range zones {
|
||||
zones[i] = middleware.Host(zones[i]).Normalize()
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ func etcdParse(c *caddy.Controller) (*Etcd, bool, error) {
|
||||
stubzones = false
|
||||
)
|
||||
for c.Next() {
|
||||
if c.Val() == "etcd" {
|
||||
etc.Zones = c.RemainingArgs()
|
||||
if len(etc.Zones) == 0 {
|
||||
etc.Zones = make([]string, len(c.ServerBlockKeys))
|
||||
@@ -125,7 +124,6 @@ func etcdParse(c *caddy.Controller) (*Etcd, bool, error) {
|
||||
|
||||
return &etc, stubzones, nil
|
||||
}
|
||||
}
|
||||
return &Etcd{}, false, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ func fileParse(c *caddy.Controller) (Zones, error) {
|
||||
config := dnsserver.GetConfig(c)
|
||||
|
||||
for c.Next() {
|
||||
if c.Val() == "file" {
|
||||
// file db.file [zones...]
|
||||
if !c.NextArg() {
|
||||
return Zones{}, c.ArgErr()
|
||||
@@ -127,7 +126,6 @@ func fileParse(c *caddy.Controller) (Zones, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Zones{Z: z, Names: names}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ func hostsParse(c *caddy.Controller) (Hosts, error) {
|
||||
config := dnsserver.GetConfig(c)
|
||||
|
||||
for c.Next() {
|
||||
if c.Val() == "hosts" { // hosts [FILE] [ZONES...]
|
||||
args := c.RemainingArgs()
|
||||
if len(args) >= 1 {
|
||||
h.path = args[0]
|
||||
@@ -83,6 +82,5 @@ func hostsParse(c *caddy.Controller) (Hosts, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return h, nil
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ func (z Zones) Matches(qname string) string {
|
||||
return zone
|
||||
}
|
||||
|
||||
// Normalize fully qualifies all zones in z.
|
||||
// Normalize fully qualifies all zones in z. The zones in Z must be domain names, without
|
||||
// a port or protocol prefix.
|
||||
func (z Zones) Normalize() {
|
||||
for i := range z {
|
||||
z[i] = Name(z[i]).Normalize()
|
||||
@@ -54,7 +55,7 @@ func (n Name) Normalize() string { return strings.ToLower(dns.Fqdn(string(n))) }
|
||||
|
||||
type (
|
||||
// Host represents a host from the Corefile, may contain port.
|
||||
Host string // Host represents a host from the Corefile, may contain port.
|
||||
Host string
|
||||
)
|
||||
|
||||
// Normalize will return the host portion of host, stripping
|
||||
|
||||
@@ -34,19 +34,15 @@ func setupReverse(c *caddy.Controller) error {
|
||||
}
|
||||
|
||||
func reverseParse(c *caddy.Controller) (nets networks, fall bool, err error) {
|
||||
|
||||
// normalize zones, validation is almost done by dnsserver
|
||||
// TODO(miek): need sane helpers for these.
|
||||
zones := make([]string, len(c.ServerBlockKeys))
|
||||
wildcard := false
|
||||
|
||||
// We copy from the serverblock, these contains Hosts.
|
||||
for i, str := range c.ServerBlockKeys {
|
||||
zones[i] = middleware.Host(str).Normalize()
|
||||
}
|
||||
|
||||
for c.Next() {
|
||||
if c.Val() == "reverse" {
|
||||
|
||||
var cidrs []*net.IPNet
|
||||
|
||||
// parse all networks
|
||||
@@ -144,7 +140,6 @@ func reverseParse(c *caddy.Controller) (nets networks, fall bool, err error) {
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sort by cidr
|
||||
sort.Sort(nets)
|
||||
|
||||
Reference in New Issue
Block a user