Make node id a property

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2020-01-16 08:47:17 +01:00
parent acd0b73a49
commit 6da97627a7
7 changed files with 70 additions and 46 deletions

View File

@@ -18,19 +18,8 @@ type Traffic struct {
Next plugin.Handler
}
// New returns a pointer to a new and initialized Traffic.
func New(addr, node string) (*Traffic, error) {
c, err := xds.New(":18000", "mycoredns")
if err != nil {
return nil, err
}
return &Traffic{c: c}, nil
}
func (t *Traffic) Close() {
t.c.Close()
}
// shutdown closes the connection to the managment endpoints and stops any running goroutines.
func (t *Traffic) shutdown() { t.c.Close() }
// ServeDNS implements the plugin.Handler interface.
func (t *Traffic) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
@@ -49,8 +38,8 @@ func (t *Traffic) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
m.SetReply(r)
m.Answer = []dns.RR{&dns.A{
dns.RR_Header{Name: state.QName(), Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 5},
addr,
Hdr: dns.RR_Header{Name: state.QName(), Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 5},
A: addr,
}}
w.WriteMsg(m)