mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 02:03:20 -04:00 
			
		
		
		
	* Add set EDNS0 with variable substitution
* Change variable from $ to {}. Un-export constants
* Update README
* Change getRuleData() to ruleData(); Change to use string match from regexp
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			518 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			518 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package rewrite
 | |
| 
 | |
| import (
 | |
| 	"github.com/coredns/coredns/middleware"
 | |
| 
 | |
| 	"github.com/miekg/dns"
 | |
| )
 | |
| 
 | |
| type nameRule struct {
 | |
| 	From, To string
 | |
| }
 | |
| 
 | |
| func newNameRule(from, to string) (Rule, error) {
 | |
| 	return &nameRule{middleware.Name(from).Normalize(), middleware.Name(to).Normalize()}, nil
 | |
| }
 | |
| 
 | |
| // Rewrite rewrites the the current request.
 | |
| func (rule *nameRule) Rewrite(w dns.ResponseWriter, r *dns.Msg) Result {
 | |
| 	if rule.From == r.Question[0].Name {
 | |
| 		r.Question[0].Name = rule.To
 | |
| 		return RewriteDone
 | |
| 	}
 | |
| 	return RewriteIgnored
 | |
| }
 |