mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 02:03:20 -04:00 
			
		
		
		
	Allow debug queries to etcd middleware (#150)
With this you can retreive the raw data that the etcd middleware used to create the reply. The debug data is put in TXT records that are stuffed in the CH classs. This is only enabled if you specify `debug` in the etcd stanza. You can retrieve it by prefixing your query with 'o-o.debug.' For instance: ; <<>> DiG 9.10.3-P4-Ubuntu <<>> @localhost -p 1053 SRV o-o.debug.production.*.skydns.local ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47798 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 3 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;o-o.debug.production.*.skydns.local. IN SRV ;; ANSWER SECTION: production.*.skydns.local. 154 IN SRV 10 50 8080 service1.example.com. production.*.skydns.local. 154 IN SRV 10 50 8080 service2.example.com. ;; ADDITIONAL SECTION: skydns.local.skydns.east.production.rails.1. 154 CH TXT "service1.example.com:8080(10,0,,false)[0,]" skydns.local.skydns.west.production.rails.2. 154 CH TXT "service2.example.com:8080(10,0,,false)[0,]"
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| package msg | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"net" | ||||
| 	"strings" | ||||
|  | ||||
| @@ -35,6 +36,37 @@ type Service struct { | ||||
| 	Key string `json:"-"` | ||||
| } | ||||
|  | ||||
| // RR returns an RR representation of s. It is in a condensed form to minimize space | ||||
| // when this is returned in a DNS message. | ||||
| // The RR will look like: | ||||
| //	skydns.local.skydns.east.production.rails.1. 300 CH TXT "service1.example.com:8080(10,0,,false)[0,]" | ||||
| //                      etcd Key                     Ttl               Host:Port          <   see below   > | ||||
| // between parens: (Priority, Weight, Text (only first 200 bytes!), Mail) | ||||
| // between blockquotes: [TargetStrip,Group] | ||||
| // If the record is synthesised by CoreDNS (i.e. no lookup in etcd happened): | ||||
| // | ||||
| //	skydns.local.skydns.east.production.rails.1. 300 CH TXT "service1.example.com:8080(10,0,,false)[0,]" | ||||
| // | ||||
| func (s *Service) RR() *dns.TXT { | ||||
| 	l := len(s.Text) | ||||
| 	if l > 200 { | ||||
| 		l = 200 | ||||
| 	} | ||||
| 	t := new(dns.TXT) | ||||
| 	t.Hdr.Class = dns.ClassCHAOS | ||||
| 	t.Hdr.Ttl = s.Ttl | ||||
| 	t.Hdr.Rrtype = dns.TypeTXT | ||||
| 	// TODO(miek): key guaranteerd to be > 1? | ||||
| 	t.Hdr.Name = strings.Replace(s.Key[1:], "/", ".", -1) + "." // TODO(miek): slightly more like etcd.Domain() | ||||
|  | ||||
| 	t.Txt = make([]string, 1) | ||||
| 	t.Txt[0] = fmt.Sprintf("%s:%d(%d,%d,%s,%t)[%d,%s]", | ||||
| 		s.Host, s.Port, | ||||
| 		s.Priority, s.Weight, s.Text[:l], s.Mail, | ||||
| 		s.TargetStrip, s.Group) | ||||
| 	return t | ||||
| } | ||||
|  | ||||
| // NewSRV returns a new SRV record based on the Service. | ||||
| func (s *Service) NewSRV(name string, weight uint16) *dns.SRV { | ||||
| 	host := targetStrip(dns.Fqdn(s.Host), s.TargetStrip) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user