mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 02:03:20 -04:00 
			
		
		
		
	* Don't add OPT RR to non-EDNS0 queries Signed-off-by: Patrick W. Healy <phealy@phealy.com> Signed-off-by: Patrick W. Healy <patrick.healy@microsoft.com> * Update plugin/bufsize/README.md Co-authored-by: Chris O'Haver <cohaver@infoblox.com> Signed-off-by: Patrick W. Healy <patrick.healy@microsoft.com> Co-authored-by: Chris O'Haver <cohaver@infoblox.com>
		
			
				
	
	
		
			29 lines
		
	
	
		
			666 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			666 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Package bufsize implements a plugin that modifies EDNS0 buffer size.
 | |
| package bufsize
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 
 | |
| 	"github.com/coredns/coredns/plugin"
 | |
| 
 | |
| 	"github.com/miekg/dns"
 | |
| )
 | |
| 
 | |
| // Bufsize implements bufsize plugin.
 | |
| type Bufsize struct {
 | |
| 	Next plugin.Handler
 | |
| 	Size int
 | |
| }
 | |
| 
 | |
| // ServeDNS implements the plugin.Handler interface.
 | |
| func (buf Bufsize) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
 | |
| 	if option := r.IsEdns0(); option != nil {
 | |
| 		option.SetUDPSize(uint16(buf.Size))
 | |
| 	}
 | |
| 
 | |
| 	return plugin.NextOrFailure(buf.Name(), buf.Next, ctx, w, r)
 | |
| }
 | |
| 
 | |
| // Name implements the Handler interface.
 | |
| func (buf Bufsize) Name() string { return "bufsize" }
 |