mirror of
https://github.com/coredns/coredns.git
synced 2026-07-13 11:10:10 -04:00
plugin/hosts: add wildcard support (#8185)
* 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>
This commit is contained in:
committed by
GitHub
parent
e45ad5f87a
commit
6805f6f8a0
18
plugin/hosts/wildcard.go
Normal file
18
plugin/hosts/wildcard.go
Normal file
@@ -0,0 +1,18 @@
|
||||
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:]
|
||||
}
|
||||
Reference in New Issue
Block a user