+ rewrites: support exceptions:

*.host -> IP
my.host -> my.host
*.my.host -> *.my.host

Requests for my.host and *.my.host will be passed to upstream servers,
 while all other requests for *.host will be answered with a rewritten IP
This commit is contained in:
Simon Zolin
2020-05-26 11:42:42 +03:00
parent 383507bc0c
commit 118b170210
3 changed files with 52 additions and 5 deletions

View File

@@ -43,14 +43,14 @@ func (a rewritesArray) Len() int { return len(a) }
func (a rewritesArray) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
// Priority:
// . CNAME > A/AAAA;
// . exact > wildcard;
// . higher level wildcard > lower level wildcard
// . CNAME < A/AAAA;
// . exact < wildcard;
// . higher level wildcard < lower level wildcard
func (a rewritesArray) Less(i, j int) bool {
if a[i].Type == dns.TypeCNAME && a[j].Type != dns.TypeCNAME {
return false
} else if a[i].Type != dns.TypeCNAME && a[j].Type == dns.TypeCNAME {
return true
} else if a[i].Type != dns.TypeCNAME && a[j].Type == dns.TypeCNAME {
return false
}
if isWildcard(a[i].Domain) {