mirror of
https://github.com/coredns/coredns.git
synced 2026-07-10 09:40:12 -04:00
* plugin/hosts: add wildcard support for owner names Signed-off-by: youknowforsearch <amirhebrahimzader@gmail.com> * plugin/hosts: document wildcard owner name support Signed-off-by: youknowforsearch <amirhebrahimzader@gmail.com> * plugin/hosts: remove unused lookupStaticHost Signed-off-by: Amirhossein Ebrahimzade <amirhossein.e@smartech.ir> --------- Signed-off-by: youknowforsearch <amirhebrahimzader@gmail.com> Signed-off-by: Amirhossein Ebrahimzade <amirhossein.e@smartech.ir> Co-authored-by: Amirhossein Ebrahimzade <amirhossein.e@smartech.ir>
19 lines
439 B
Go
19 lines
439 B
Go
package hosts
|
|
|
|
import "github.com/miekg/dns"
|
|
|
|
// isWildcardName reports whether name is a wildcard owner name (*.example.com.).
|
|
func isWildcardName(name string) bool {
|
|
return len(name) >= 2 && name[0] == '*' && name[1] == '.'
|
|
}
|
|
|
|
// replaceWithAsteriskLabel replaces the leftmost label with '*'.
|
|
func replaceWithAsteriskLabel(qname string) string {
|
|
i, shot := dns.NextLabel(qname, 0)
|
|
if shot {
|
|
return ""
|
|
}
|
|
|
|
return "*." + qname[i:]
|
|
}
|