add golangci-lint linter (#5499)
This commit is contained in:
parent
abc5ac8017
commit
c2dbb7141a
104 changed files with 83 additions and 184 deletions
16
.github/workflows/golangci-lint.yml
vendored
Normal file
16
.github/workflows/golangci-lint.yml
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
name: golangci-lint
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
jobs:
|
||||||
|
golangci:
|
||||||
|
name: lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '1.18'
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: golangci-lint
|
||||||
|
uses: golangci/golangci-lint-action@v3
|
||||||
|
with:
|
||||||
|
version: v1.46.2
|
13
.golangci.yml
Normal file
13
.golangci.yml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
run:
|
||||||
|
timeout: 5m
|
||||||
|
linters:
|
||||||
|
disable-all: true
|
||||||
|
enable:
|
||||||
|
- deadcode
|
||||||
|
- govet
|
||||||
|
- ineffassign
|
||||||
|
- staticcheck
|
||||||
|
- structcheck
|
||||||
|
- typecheck
|
||||||
|
- varcheck
|
||||||
|
- whitespace
|
|
@ -49,7 +49,6 @@ func newOverlapZone() *zoneOverlap {
|
||||||
// registerAndCheck adds a new zoneAddr for validation, it returns information about existing or overlapping with already registered
|
// registerAndCheck adds a new zoneAddr for validation, it returns information about existing or overlapping with already registered
|
||||||
// we consider that an unbound address is overlapping all bound addresses for same zone, same port
|
// we consider that an unbound address is overlapping all bound addresses for same zone, same port
|
||||||
func (zo *zoneOverlap) registerAndCheck(z zoneAddr) (existingZone *zoneAddr, overlappingZone *zoneAddr) {
|
func (zo *zoneOverlap) registerAndCheck(z zoneAddr) (existingZone *zoneAddr, overlappingZone *zoneAddr) {
|
||||||
|
|
||||||
if exist, ok := zo.registeredAddr[z]; ok {
|
if exist, ok := zo.registeredAddr[z]; ok {
|
||||||
// exact same zone already registered
|
// exact same zone already registered
|
||||||
return &exist, nil
|
return &exist, nil
|
||||||
|
|
|
@ -43,7 +43,6 @@ func TestSplitProtocolHostPort(t *testing.T) {
|
||||||
if port != test.port {
|
if port != test.port {
|
||||||
t.Errorf("Test %d: (address = %s) expected port with value %s but got %s", i, test.input, test.port, port)
|
t.Errorf("Test %d: (address = %s) expected port with value %s but got %s", i, test.input, test.port, port)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +91,6 @@ func TestOverlapAddressChecker(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
|
||||||
checker := newOverlapZone()
|
checker := newOverlapZone()
|
||||||
for _, call := range test.sequence {
|
for _, call := range test.sequence {
|
||||||
same, overlap := checker.registerAndCheck(call.zone)
|
same, overlap := checker.registerAndCheck(call.zone)
|
||||||
|
@ -108,10 +106,8 @@ func TestOverlapAddressChecker(t *testing.T) {
|
||||||
if overlap.String() != call.overlapKey {
|
if overlap.String() != call.overlapKey {
|
||||||
t.Errorf("Test %d: error, for zone %s, 'overlap Key' (%v) has not the expected value (%v)", i, sZone, overlap.String(), call.overlapKey)
|
t.Errorf("Test %d: error, for zone %s, 'overlap Key' (%v) has not the expected value (%v)", i, sZone, overlap.String(), call.overlapKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRegex1035PrefSyntax(t *testing.T) {
|
func TestRegex1035PrefSyntax(t *testing.T) {
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
zone string
|
zone string
|
||||||
expected bool
|
expected bool
|
||||||
|
|
|
@ -138,7 +138,6 @@ func (h *dnsContext) InspectServerBlocks(sourceFile string, serverBlocks []caddy
|
||||||
|
|
||||||
// MakeServers uses the newly-created siteConfigs to create and return a list of server instances.
|
// MakeServers uses the newly-created siteConfigs to create and return a list of server instances.
|
||||||
func (h *dnsContext) MakeServers() ([]caddy.Server, error) {
|
func (h *dnsContext) MakeServers() ([]caddy.Server, error) {
|
||||||
|
|
||||||
// Now that all Keys and Directives are parsed and initialized
|
// Now that all Keys and Directives are parsed and initialized
|
||||||
// lets verify that there is no overlap on the zones and addresses to listen for
|
// lets verify that there is no overlap on the zones and addresses to listen for
|
||||||
errValid := h.validateZonesAndListeningAddresses()
|
errValid := h.validateZonesAndListeningAddresses()
|
||||||
|
@ -197,7 +196,6 @@ func (h *dnsContext) MakeServers() ([]caddy.Server, error) {
|
||||||
}
|
}
|
||||||
servers = append(servers, s)
|
servers = append(servers, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return servers, nil
|
return servers, nil
|
||||||
|
@ -262,11 +260,9 @@ func (h *dnsContext) validateZonesAndListeningAddresses() error {
|
||||||
if overlapZone != nil {
|
if overlapZone != nil {
|
||||||
return fmt.Errorf("cannot serve %s - zone overlap listener capacity with %v", akey.String(), overlapZone.String())
|
return fmt.Errorf("cannot serve %s - zone overlap listener capacity with %v", akey.String(), overlapZone.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// groupSiteConfigsByListenAddr groups site configs by their listen
|
// groupSiteConfigsByListenAddr groups site configs by their listen
|
||||||
|
|
|
@ -114,7 +114,6 @@ func TestGroupingServers(t *testing.T) {
|
||||||
for _, v := range test.expectedGroups {
|
for _, v := range test.expectedGroups {
|
||||||
if _, ok := groups[v]; !ok {
|
if _, ok := groups[v]; !ok {
|
||||||
t.Errorf("Test %d : expected value %v to be in the group, was not", i, v)
|
t.Errorf("Test %d : expected value %v to be in the group, was not", i, v)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ type Server struct {
|
||||||
// NewServer returns a new CoreDNS server and compiles all plugins in to it. By default CH class
|
// NewServer returns a new CoreDNS server and compiles all plugins in to it. By default CH class
|
||||||
// queries are blocked unless queries from enableChaos are loaded.
|
// queries are blocked unless queries from enableChaos are loaded.
|
||||||
func NewServer(addr string, group []*Config) (*Server, error) {
|
func NewServer(addr string, group []*Config) (*Server, error) {
|
||||||
|
|
||||||
s := &Server{
|
s := &Server{
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
zones: make(map[string]*Config),
|
zones: make(map[string]*Config),
|
||||||
|
@ -174,7 +173,6 @@ func (s *Server) ListenPacket() (net.PacketConn, error) {
|
||||||
// immediately.
|
// immediately.
|
||||||
// This implements Caddy.Stopper interface.
|
// This implements Caddy.Stopper interface.
|
||||||
func (s *Server) Stop() (err error) {
|
func (s *Server) Stop() (err error) {
|
||||||
|
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
// force connections to close after timeout
|
// force connections to close after timeout
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
|
|
|
@ -82,7 +82,6 @@ func (s *ServergRPC) ServePacket(p net.PacketConn) error { return nil }
|
||||||
|
|
||||||
// Listen implements caddy.TCPServer interface.
|
// Listen implements caddy.TCPServer interface.
|
||||||
func (s *ServergRPC) Listen() (net.Listener, error) {
|
func (s *ServergRPC) Listen() (net.Listener, error) {
|
||||||
|
|
||||||
l, err := reuseport.Listen("tcp", s.Addr[len(transport.GRPC+"://"):])
|
l, err := reuseport.Listen("tcp", s.Addr[len(transport.GRPC+"://"):])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -104,7 +104,6 @@ func (s *ServerHTTPS) ServePacket(p net.PacketConn) error { return nil }
|
||||||
|
|
||||||
// Listen implements caddy.TCPServer interface.
|
// Listen implements caddy.TCPServer interface.
|
||||||
func (s *ServerHTTPS) Listen() (net.Listener, error) {
|
func (s *ServerHTTPS) Listen() (net.Listener, error) {
|
||||||
|
|
||||||
l, err := reuseport.Listen("tcp", s.Addr[len(transport.HTTPS+"://"):])
|
l, err := reuseport.Listen("tcp", s.Addr[len(transport.HTTPS+"://"):])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -141,7 +140,6 @@ func (s *ServerHTTPS) Stop() error {
|
||||||
// ServeHTTP is the handler that gets the HTTP request and converts to the dns format, calls the plugin
|
// ServeHTTP is the handler that gets the HTTP request and converts to the dns format, calls the plugin
|
||||||
// chain, converts it back and write it to the client.
|
// chain, converts it back and write it to the client.
|
||||||
func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
if !s.validRequest(r) {
|
if !s.validRequest(r) {
|
||||||
http.Error(w, "", http.StatusNotFound)
|
http.Error(w, "", http.StatusNotFound)
|
||||||
s.countResponse(http.StatusNotFound)
|
s.countResponse(http.StatusNotFound)
|
||||||
|
|
|
@ -88,7 +88,6 @@ RulesCheckLoop:
|
||||||
return dns.RcodeSuccess, nil
|
return dns.RcodeSuccess, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestAllowCount.WithLabelValues(metrics.WithServer(ctx)).Inc()
|
RequestAllowCount.WithLabelValues(metrics.WithServer(ctx)).Inc()
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
|
|
||||||
// Walk will recursively walk of the file under l.directory and adds the one that match l.re.
|
// Walk will recursively walk of the file under l.directory and adds the one that match l.re.
|
||||||
func (a Auto) Walk() error {
|
func (a Auto) Walk() error {
|
||||||
|
|
||||||
// TODO(miek): should add something so that we don't stomp on each other.
|
// TODO(miek): should add something so that we don't stomp on each other.
|
||||||
|
|
||||||
toDelete := make(map[string]bool)
|
toDelete := make(map[string]bool)
|
||||||
|
|
|
@ -135,7 +135,6 @@ func (a *AutoPath) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
|
||||||
w.WriteMsg(msg)
|
w.WriteMsg(msg)
|
||||||
autoPathCount.WithLabelValues(metrics.WithServer(ctx)).Add(1)
|
autoPathCount.WithLabelValues(metrics.WithServer(ctx)).Add(1)
|
||||||
return rcode, err
|
return rcode, err
|
||||||
|
|
||||||
}
|
}
|
||||||
if plugin.ClientWrite(firstRcode) {
|
if plugin.ClientWrite(firstRcode) {
|
||||||
w.WriteMsg(firstReply)
|
w.WriteMsg(firstReply)
|
||||||
|
|
|
@ -134,7 +134,6 @@ func (h *Azure) updateZones(ctx context.Context) error {
|
||||||
return fmt.Errorf("errors updating zones: %v", errs)
|
return fmt.Errorf("errors updating zones: %v", errs)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateZoneFromPublicResourceSet(recordSet publicdns.RecordSetListResultPage, newZ *file.Zone) {
|
func updateZoneFromPublicResourceSet(recordSet publicdns.RecordSetListResultPage, newZ *file.Zone) {
|
||||||
|
@ -297,7 +296,6 @@ func updateZoneFromPrivateResourceSet(recordSet privatedns.RecordSetListResultPa
|
||||||
Target: dns.Fqdn(*CNAME)}
|
Target: dns.Fqdn(*CNAME)}
|
||||||
newZ.Insert(cname)
|
newZ.Insert(cname)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,20 +29,24 @@ func setup(c *caddy.Controller) error {
|
||||||
|
|
||||||
publicDNSClient := publicAzureDNS.NewRecordSetsClient(env.Values[auth.SubscriptionID])
|
publicDNSClient := publicAzureDNS.NewRecordSetsClient(env.Values[auth.SubscriptionID])
|
||||||
if publicDNSClient.Authorizer, err = env.GetAuthorizer(); err != nil {
|
if publicDNSClient.Authorizer, err = env.GetAuthorizer(); err != nil {
|
||||||
|
cancel()
|
||||||
return plugin.Error("azure", err)
|
return plugin.Error("azure", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
privateDNSClient := privateAzureDNS.NewRecordSetsClient(env.Values[auth.SubscriptionID])
|
privateDNSClient := privateAzureDNS.NewRecordSetsClient(env.Values[auth.SubscriptionID])
|
||||||
if privateDNSClient.Authorizer, err = env.GetAuthorizer(); err != nil {
|
if privateDNSClient.Authorizer, err = env.GetAuthorizer(); err != nil {
|
||||||
|
cancel()
|
||||||
return plugin.Error("azure", err)
|
return plugin.Error("azure", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
h, err := New(ctx, publicDNSClient, privateDNSClient, keys, accessMap)
|
h, err := New(ctx, publicDNSClient, privateDNSClient, keys, accessMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
cancel()
|
||||||
return plugin.Error("azure", err)
|
return plugin.Error("azure", err)
|
||||||
}
|
}
|
||||||
h.Fall = fall
|
h.Fall = fall
|
||||||
if err := h.Run(ctx); err != nil {
|
if err := h.Run(ctx); err != nil {
|
||||||
|
cancel()
|
||||||
return plugin.Error("azure", err)
|
return plugin.Error("azure", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ func A(ctx context.Context, b ServiceBackend, zone string, state request.Request
|
||||||
dup := make(map[string]struct{})
|
dup := make(map[string]struct{})
|
||||||
|
|
||||||
for _, serv := range services {
|
for _, serv := range services {
|
||||||
|
|
||||||
what, ip := serv.HostType()
|
what, ip := serv.HostType()
|
||||||
|
|
||||||
switch what {
|
switch what {
|
||||||
|
@ -97,7 +96,6 @@ func AAAA(ctx context.Context, b ServiceBackend, zone string, state request.Requ
|
||||||
dup := make(map[string]struct{})
|
dup := make(map[string]struct{})
|
||||||
|
|
||||||
for _, serv := range services {
|
for _, serv := range services {
|
||||||
|
|
||||||
what, ip := serv.HostType()
|
what, ip := serv.HostType()
|
||||||
|
|
||||||
switch what {
|
switch what {
|
||||||
|
@ -344,7 +342,6 @@ func CNAME(ctx context.Context, b ServiceBackend, zone string, state request.Req
|
||||||
|
|
||||||
// TXT returns TXT records from Backend or an error.
|
// TXT returns TXT records from Backend or an error.
|
||||||
func TXT(ctx context.Context, b ServiceBackend, zone string, state request.Request, previousRecords []dns.RR, opt Options) (records []dns.RR, truncated bool, err error) {
|
func TXT(ctx context.Context, b ServiceBackend, zone string, state request.Request, previousRecords []dns.RR, opt Options) (records []dns.RR, truncated bool, err error) {
|
||||||
|
|
||||||
services, err := b.Services(ctx, state, false, opt)
|
services, err := b.Services(ctx, state, false, opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
|
@ -353,7 +350,6 @@ func TXT(ctx context.Context, b ServiceBackend, zone string, state request.Reque
|
||||||
dup := make(map[string]struct{})
|
dup := make(map[string]struct{})
|
||||||
|
|
||||||
for _, serv := range services {
|
for _, serv := range services {
|
||||||
|
|
||||||
what, _ := serv.HostType()
|
what, _ := serv.HostType()
|
||||||
|
|
||||||
switch what {
|
switch what {
|
||||||
|
@ -405,7 +401,6 @@ func TXT(ctx context.Context, b ServiceBackend, zone string, state request.Reque
|
||||||
dup[serv.Text] = struct{}{}
|
dup[serv.Text] = struct{}{}
|
||||||
records = append(records, serv.NewTXT(state.QName()))
|
records = append(records, serv.NewTXT(state.QName()))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +502,6 @@ func BackendError(ctx context.Context, b ServiceBackend, zone string, rcode int,
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAddress(s msg.Service, name string, ip net.IP, what uint16) dns.RR {
|
func newAddress(s msg.Service, name string, ip net.IP, what uint16) dns.RR {
|
||||||
|
|
||||||
hdr := dns.RR_Header{Name: name, Rrtype: what, Class: dns.ClassINET, Ttl: s.TTL}
|
hdr := dns.RR_Header{Name: name, Rrtype: what, Class: dns.ClassINET, Ttl: s.TTL}
|
||||||
|
|
||||||
if what == dns.TypeA {
|
if what == dns.TypeA {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func setup(c *caddy.Controller) error {
|
func setup(c *caddy.Controller) error {
|
||||||
|
|
||||||
config := dnsserver.GetConfig(c)
|
config := dnsserver.GetConfig(c)
|
||||||
// addresses will be consolidated over all BIND directives available in that BlocServer
|
// addresses will be consolidated over all BIND directives available in that BlocServer
|
||||||
all := []string{}
|
all := []string{}
|
||||||
|
|
2
plugin/cache/cache_test.go
vendored
2
plugin/cache/cache_test.go
vendored
|
@ -609,7 +609,7 @@ func TestCacheWildcardMetadata(t *testing.T) {
|
||||||
ctx = metadata.ContextWithMetadata(context.TODO())
|
ctx = metadata.ContextWithMetadata(context.TODO())
|
||||||
w = dnstest.NewRecorder(&test.ResponseWriter{})
|
w = dnstest.NewRecorder(&test.ResponseWriter{})
|
||||||
|
|
||||||
c.ServeDNS(ctx, &test.ResponseWriter{}, req)
|
c.ServeDNS(ctx, w, req)
|
||||||
f := metadata.ValueFunc(ctx, "zone/wildcard")
|
f := metadata.ValueFunc(ctx, "zone/wildcard")
|
||||||
if f == nil {
|
if f == nil {
|
||||||
t.Fatal("expected metadata func for wildcard response retrieved from cache, got nil")
|
t.Fatal("expected metadata func for wildcard response retrieved from cache, got nil")
|
||||||
|
|
|
@ -30,7 +30,7 @@ func parse(c *caddy.Controller) (string, []string, error) {
|
||||||
chaosVersion = caddy.AppName + "-" + caddy.AppVersion
|
chaosVersion = caddy.AppName + "-" + caddy.AppVersion
|
||||||
version := ""
|
version := ""
|
||||||
|
|
||||||
for c.Next() {
|
if c.Next() {
|
||||||
args := c.RemainingArgs()
|
args := c.RemainingArgs()
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return trim(chaosVersion), Owners, nil
|
return trim(chaosVersion), Owners, nil
|
||||||
|
|
|
@ -204,7 +204,6 @@ func (h *CloudDNS) updateZones(ctx context.Context) error {
|
||||||
(*z[i]).z = newZ
|
(*z[i]).z = newZ
|
||||||
h.zMu.Unlock()
|
h.zMu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
}(zName, z)
|
}(zName, z)
|
||||||
}
|
}
|
||||||
// Collect errors (if any). This will also sync on all zones updates
|
// Collect errors (if any). This will also sync on all zones updates
|
||||||
|
|
|
@ -152,7 +152,6 @@ func TestCloudDNS(t *testing.T) {
|
||||||
|
|
||||||
m.Authoritative = true
|
m.Authoritative = true
|
||||||
rcode = dns.RcodeSuccess
|
rcode = dns.RcodeSuccess
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m.SetRcode(r, rcode)
|
m.SetRcode(r, rcode)
|
||||||
|
|
|
@ -81,16 +81,19 @@ func setup(c *caddy.Controller) error {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
client, err := f(ctx, opt)
|
client, err := f(ctx, opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
cancel()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
h, err := New(ctx, client, keys, up)
|
h, err := New(ctx, client, keys, up)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
cancel()
|
||||||
return plugin.Error("clouddns", c.Errf("failed to create plugin: %v", err))
|
return plugin.Error("clouddns", c.Errf("failed to create plugin: %v", err))
|
||||||
}
|
}
|
||||||
h.Fall = fall
|
h.Fall = fall
|
||||||
|
|
||||||
if err := h.Run(ctx); err != nil {
|
if err := h.Run(ctx); err != nil {
|
||||||
|
cancel()
|
||||||
return plugin.Error("clouddns", c.Errf("failed to initialize plugin: %v", err))
|
return plugin.Error("clouddns", c.Errf("failed to initialize plugin: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ func TestNoDebug(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleLogHexdump() {
|
func ExampleHexdump() {
|
||||||
buf, _ := msg().Pack()
|
buf, _ := msg().Pack()
|
||||||
h := hexdump(buf)
|
h := hexdump(buf)
|
||||||
fmt.Println(string(h))
|
fmt.Println(string(h))
|
||||||
|
|
|
@ -74,7 +74,6 @@ func TestRequestShouldIntercept(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTo6(t *testing.T) {
|
func TestTo6(t *testing.T) {
|
||||||
|
|
||||||
v6, err := To6("64:ff9b::/96", "64.64.64.64")
|
v6, err := To6("64:ff9b::/96", "64.64.64.64")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
@ -216,7 +215,7 @@ func TestDNS64(t *testing.T) {
|
||||||
RecursionDesired: true,
|
RecursionDesired: true,
|
||||||
Opcode: dns.OpcodeQuery,
|
Opcode: dns.OpcodeQuery,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
},
|
},
|
||||||
initResp: &dns.Msg{ //success, no answers
|
initResp: &dns.Msg{ //success, no answers
|
||||||
MsgHdr: dns.MsgHdr{
|
MsgHdr: dns.MsgHdr{
|
||||||
|
@ -226,7 +225,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
Ns: []dns.RR{test.SOA("example.com. 70 IN SOA foo bar 1 1 1 1 1")},
|
Ns: []dns.RR{test.SOA("example.com. 70 IN SOA foo bar 1 1 1 1 1")},
|
||||||
},
|
},
|
||||||
aResp: &dns.Msg{
|
aResp: &dns.Msg{
|
||||||
|
@ -237,7 +236,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeA, Qclass: dns.ClassINET}},
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
test.A("example.com. 60 IN A 192.0.2.42"),
|
test.A("example.com. 60 IN A 192.0.2.42"),
|
||||||
test.A("example.com. 5000 IN A 192.0.2.43"),
|
test.A("example.com. 5000 IN A 192.0.2.43"),
|
||||||
|
@ -252,7 +251,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
test.AAAA("example.com. 60 IN AAAA 64:ff9b::192.0.2.42"),
|
test.AAAA("example.com. 60 IN AAAA 64:ff9b::192.0.2.42"),
|
||||||
// override RR ttl to SOA ttl, since it's lower
|
// override RR ttl to SOA ttl, since it's lower
|
||||||
|
@ -269,7 +268,7 @@ func TestDNS64(t *testing.T) {
|
||||||
RecursionDesired: true,
|
RecursionDesired: true,
|
||||||
Opcode: dns.OpcodeQuery,
|
Opcode: dns.OpcodeQuery,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
},
|
},
|
||||||
initResp: &dns.Msg{ //success, no answers
|
initResp: &dns.Msg{ //success, no answers
|
||||||
MsgHdr: dns.MsgHdr{
|
MsgHdr: dns.MsgHdr{
|
||||||
|
@ -279,7 +278,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
Ns: []dns.RR{test.SOA("example.com. 3600 IN SOA foo bar 1 7200 900 1209600 86400")},
|
Ns: []dns.RR{test.SOA("example.com. 3600 IN SOA foo bar 1 7200 900 1209600 86400")},
|
||||||
},
|
},
|
||||||
aResp: &dns.Msg{
|
aResp: &dns.Msg{
|
||||||
|
@ -290,7 +289,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeA, Qclass: dns.ClassINET}},
|
||||||
Ns: []dns.RR{test.SOA("example.com. 3600 IN SOA foo bar 1 7200 900 1209600 86400")},
|
Ns: []dns.RR{test.SOA("example.com. 3600 IN SOA foo bar 1 7200 900 1209600 86400")},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -302,7 +301,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
Ns: []dns.RR{test.SOA("example.com. 3600 IN SOA foo bar 1 7200 900 1209600 86400")},
|
Ns: []dns.RR{test.SOA("example.com. 3600 IN SOA foo bar 1 7200 900 1209600 86400")},
|
||||||
Answer: []dns.RR{}, // just to make comparison happy
|
Answer: []dns.RR{}, // just to make comparison happy
|
||||||
},
|
},
|
||||||
|
@ -316,7 +315,7 @@ func TestDNS64(t *testing.T) {
|
||||||
RecursionDesired: true,
|
RecursionDesired: true,
|
||||||
Opcode: dns.OpcodeQuery,
|
Opcode: dns.OpcodeQuery,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
},
|
},
|
||||||
initResp: &dns.Msg{ // failure
|
initResp: &dns.Msg{ // failure
|
||||||
MsgHdr: dns.MsgHdr{
|
MsgHdr: dns.MsgHdr{
|
||||||
|
@ -326,7 +325,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeRefused,
|
Rcode: dns.RcodeRefused,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
},
|
},
|
||||||
aResp: &dns.Msg{
|
aResp: &dns.Msg{
|
||||||
MsgHdr: dns.MsgHdr{
|
MsgHdr: dns.MsgHdr{
|
||||||
|
@ -336,7 +335,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeA, Qclass: dns.ClassINET}},
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
test.A("example.com. 60 IN A 192.0.2.42"),
|
test.A("example.com. 60 IN A 192.0.2.42"),
|
||||||
test.A("example.com. 5000 IN A 192.0.2.43"),
|
test.A("example.com. 5000 IN A 192.0.2.43"),
|
||||||
|
@ -351,7 +350,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
test.AAAA("example.com. 60 IN AAAA 64:ff9b::192.0.2.42"),
|
test.AAAA("example.com. 60 IN AAAA 64:ff9b::192.0.2.42"),
|
||||||
test.AAAA("example.com. 600 IN AAAA 64:ff9b::192.0.2.43"),
|
test.AAAA("example.com. 600 IN AAAA 64:ff9b::192.0.2.43"),
|
||||||
|
@ -367,7 +366,7 @@ func TestDNS64(t *testing.T) {
|
||||||
RecursionDesired: true,
|
RecursionDesired: true,
|
||||||
Opcode: dns.OpcodeQuery,
|
Opcode: dns.OpcodeQuery,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
},
|
},
|
||||||
initResp: &dns.Msg{ // failure
|
initResp: &dns.Msg{ // failure
|
||||||
MsgHdr: dns.MsgHdr{
|
MsgHdr: dns.MsgHdr{
|
||||||
|
@ -377,7 +376,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeNameError,
|
Rcode: dns.RcodeNameError,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
Ns: []dns.RR{test.SOA("example.com. 3600 IN SOA foo bar 1 7200 900 1209600 86400")},
|
Ns: []dns.RR{test.SOA("example.com. 3600 IN SOA foo bar 1 7200 900 1209600 86400")},
|
||||||
},
|
},
|
||||||
resp: &dns.Msg{
|
resp: &dns.Msg{
|
||||||
|
@ -388,7 +387,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeNameError,
|
Rcode: dns.RcodeNameError,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
Ns: []dns.RR{test.SOA("example.com. 3600 IN SOA foo bar 1 7200 900 1209600 86400")},
|
Ns: []dns.RR{test.SOA("example.com. 3600 IN SOA foo bar 1 7200 900 1209600 86400")},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -401,7 +400,7 @@ func TestDNS64(t *testing.T) {
|
||||||
RecursionDesired: true,
|
RecursionDesired: true,
|
||||||
Opcode: dns.OpcodeQuery,
|
Opcode: dns.OpcodeQuery,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
},
|
},
|
||||||
|
|
||||||
initResp: &dns.Msg{
|
initResp: &dns.Msg{
|
||||||
|
@ -412,7 +411,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
test.AAAA("example.com. 60 IN AAAA ::1"),
|
test.AAAA("example.com. 60 IN AAAA ::1"),
|
||||||
test.AAAA("example.com. 5000 IN AAAA ::2"),
|
test.AAAA("example.com. 5000 IN AAAA ::2"),
|
||||||
|
@ -427,7 +426,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
test.AAAA("example.com. 60 IN AAAA ::1"),
|
test.AAAA("example.com. 60 IN AAAA ::1"),
|
||||||
test.AAAA("example.com. 5000 IN AAAA ::2"),
|
test.AAAA("example.com. 5000 IN AAAA ::2"),
|
||||||
|
@ -443,7 +442,7 @@ func TestDNS64(t *testing.T) {
|
||||||
RecursionDesired: true,
|
RecursionDesired: true,
|
||||||
Opcode: dns.OpcodeQuery,
|
Opcode: dns.OpcodeQuery,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
},
|
},
|
||||||
initResp: &dns.Msg{ //success, no answers
|
initResp: &dns.Msg{ //success, no answers
|
||||||
MsgHdr: dns.MsgHdr{
|
MsgHdr: dns.MsgHdr{
|
||||||
|
@ -453,7 +452,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
Ns: []dns.RR{test.SOA("example.com. 70 IN SOA foo bar 1 1 1 1 1")},
|
Ns: []dns.RR{test.SOA("example.com. 70 IN SOA foo bar 1 1 1 1 1")},
|
||||||
},
|
},
|
||||||
aResp: &dns.Msg{
|
aResp: &dns.Msg{
|
||||||
|
@ -465,7 +464,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeA, Qclass: dns.ClassINET}},
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
test.A("example.com. 60 IN A 192.0.2.42"),
|
test.A("example.com. 60 IN A 192.0.2.42"),
|
||||||
test.A("example.com. 5000 IN A 192.0.2.43"),
|
test.A("example.com. 5000 IN A 192.0.2.43"),
|
||||||
|
@ -481,7 +480,7 @@ func TestDNS64(t *testing.T) {
|
||||||
Rcode: dns.RcodeSuccess,
|
Rcode: dns.RcodeSuccess,
|
||||||
Response: true,
|
Response: true,
|
||||||
},
|
},
|
||||||
Question: []dns.Question{{"example.com.", dns.TypeAAAA, dns.ClassINET}},
|
Question: []dns.Question{{Name: "example.com.", Qtype: dns.TypeAAAA, Qclass: dns.ClassINET}},
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
test.AAAA("example.com. 60 IN AAAA 64:ff9b::192.0.2.42"),
|
test.AAAA("example.com. 60 IN AAAA 64:ff9b::192.0.2.42"),
|
||||||
// override RR ttl to SOA ttl, since it's lower
|
// override RR ttl to SOA ttl, since it's lower
|
||||||
|
|
|
@ -6,14 +6,11 @@ import (
|
||||||
"github.com/coredns/caddy"
|
"github.com/coredns/caddy"
|
||||||
"github.com/coredns/coredns/core/dnsserver"
|
"github.com/coredns/coredns/core/dnsserver"
|
||||||
"github.com/coredns/coredns/plugin"
|
"github.com/coredns/coredns/plugin"
|
||||||
clog "github.com/coredns/coredns/plugin/pkg/log"
|
|
||||||
"github.com/coredns/coredns/plugin/pkg/upstream"
|
"github.com/coredns/coredns/plugin/pkg/upstream"
|
||||||
)
|
)
|
||||||
|
|
||||||
const pluginName = "dns64"
|
const pluginName = "dns64"
|
||||||
|
|
||||||
var log = clog.NewWithPlugin(pluginName)
|
|
||||||
|
|
||||||
func init() { plugin.Register(pluginName, setup) }
|
func init() { plugin.Register(pluginName, setup) }
|
||||||
|
|
||||||
func setup(c *caddy.Controller) error {
|
func setup(c *caddy.Controller) error {
|
||||||
|
|
|
@ -43,7 +43,6 @@ func periodicClean(c *cache.Cache, stop <-chan struct{}) {
|
||||||
|
|
||||||
case <-stop:
|
case <-stop:
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,6 @@ func dnssecParse(c *caddy.Controller) ([]string, []*DNSKEY, int, bool, error) {
|
||||||
zones = plugin.OriginsFromArgsOrServerBlock(c.RemainingArgs(), c.ServerBlockKeys)
|
zones = plugin.OriginsFromArgsOrServerBlock(c.RemainingArgs(), c.ServerBlockKeys)
|
||||||
|
|
||||||
for c.NextBlock() {
|
for c.NextBlock() {
|
||||||
|
|
||||||
switch x := c.Val(); x {
|
switch x := c.Val(); x {
|
||||||
case "key":
|
case "key":
|
||||||
k, e := keyParse(c)
|
k, e := keyParse(c)
|
||||||
|
@ -79,7 +78,6 @@ func dnssecParse(c *caddy.Controller) ([]string, []*DNSKEY, int, bool, error) {
|
||||||
default:
|
default:
|
||||||
return nil, nil, 0, false, c.Errf("unknown property '%s'", x)
|
return nil, nil, 0, false, c.Errf("unknown property '%s'", x)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if we have both KSKs and ZSKs.
|
// Check if we have both KSKs and ZSKs.
|
||||||
|
|
|
@ -23,7 +23,7 @@ type Dnstap struct {
|
||||||
// TapMessage sends the message m to the dnstap interface.
|
// TapMessage sends the message m to the dnstap interface.
|
||||||
func (h Dnstap) TapMessage(m *tap.Message) {
|
func (h Dnstap) TapMessage(m *tap.Message) {
|
||||||
t := tap.Dnstap_MESSAGE
|
t := tap.Dnstap_MESSAGE
|
||||||
h.io.Dnstap(tap.Dnstap{Type: &t, Message: m})
|
h.io.Dnstap(&tap.Dnstap{Type: &t, Message: m})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h Dnstap) tapQuery(w dns.ResponseWriter, query *dns.Msg, queryTime time.Time) {
|
func (h Dnstap) tapQuery(w dns.ResponseWriter, query *dns.Msg, queryTime time.Time) {
|
||||||
|
|
|
@ -18,7 +18,6 @@ func testCase(t *testing.T, tapq, tapr *tap.Message, q, r *dns.Msg) {
|
||||||
h := Dnstap{
|
h := Dnstap{
|
||||||
Next: test.HandlerFunc(func(_ context.Context,
|
Next: test.HandlerFunc(func(_ context.Context,
|
||||||
w dns.ResponseWriter, _ *dns.Msg) (int, error) {
|
w dns.ResponseWriter, _ *dns.Msg) (int, error) {
|
||||||
|
|
||||||
return 0, w.WriteMsg(r)
|
return 0, w.WriteMsg(r)
|
||||||
}),
|
}),
|
||||||
io: &w,
|
io: &w,
|
||||||
|
@ -34,7 +33,7 @@ type writer struct {
|
||||||
queue []*tap.Message
|
queue []*tap.Message
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *writer) Dnstap(e tap.Dnstap) {
|
func (w *writer) Dnstap(e *tap.Dnstap) {
|
||||||
if len(w.queue) == 0 {
|
if len(w.queue) == 0 {
|
||||||
w.t.Error("Message not expected")
|
w.t.Error("Message not expected")
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ const (
|
||||||
|
|
||||||
// tapper interface is used in testing to mock the Dnstap method.
|
// tapper interface is used in testing to mock the Dnstap method.
|
||||||
type tapper interface {
|
type tapper interface {
|
||||||
Dnstap(tap.Dnstap)
|
Dnstap(*tap.Dnstap)
|
||||||
}
|
}
|
||||||
|
|
||||||
// dio implements the Tapper interface.
|
// dio implements the Tapper interface.
|
||||||
|
@ -26,7 +26,7 @@ type dio struct {
|
||||||
endpoint string
|
endpoint string
|
||||||
proto string
|
proto string
|
||||||
enc *encoder
|
enc *encoder
|
||||||
queue chan tap.Dnstap
|
queue chan *tap.Dnstap
|
||||||
dropped uint32
|
dropped uint32
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
flushTimeout time.Duration
|
flushTimeout time.Duration
|
||||||
|
@ -38,7 +38,7 @@ func newIO(proto, endpoint string) *dio {
|
||||||
return &dio{
|
return &dio{
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
proto: proto,
|
proto: proto,
|
||||||
queue: make(chan tap.Dnstap, queueSize),
|
queue: make(chan *tap.Dnstap, queueSize),
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
flushTimeout: flushTimeout,
|
flushTimeout: flushTimeout,
|
||||||
tcpTimeout: tcpTimeout,
|
tcpTimeout: tcpTimeout,
|
||||||
|
@ -67,7 +67,7 @@ func (d *dio) connect() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dnstap enqueues the payload for log.
|
// Dnstap enqueues the payload for log.
|
||||||
func (d *dio) Dnstap(payload tap.Dnstap) {
|
func (d *dio) Dnstap(payload *tap.Dnstap) {
|
||||||
select {
|
select {
|
||||||
case d.queue <- payload:
|
case d.queue <- payload:
|
||||||
default:
|
default:
|
||||||
|
@ -104,7 +104,7 @@ func (d *dio) serve() {
|
||||||
d.enc.close()
|
d.enc.close()
|
||||||
return
|
return
|
||||||
case payload := <-d.queue:
|
case payload := <-d.queue:
|
||||||
if err := d.write(&payload); err != nil {
|
if err := d.write(payload); err != nil {
|
||||||
d.dial()
|
d.dial()
|
||||||
}
|
}
|
||||||
case <-timeout.C:
|
case <-timeout.C:
|
||||||
|
|
|
@ -65,7 +65,7 @@ func TestTransport(t *testing.T) {
|
||||||
dio.flushTimeout = 30 * time.Millisecond
|
dio.flushTimeout = 30 * time.Millisecond
|
||||||
dio.connect()
|
dio.connect()
|
||||||
|
|
||||||
dio.Dnstap(tmsg)
|
dio.Dnstap(&tmsg)
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
l.Close()
|
l.Close()
|
||||||
|
@ -99,7 +99,7 @@ func TestRace(t *testing.T) {
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
tmsg := tap.Dnstap_MESSAGE
|
tmsg := tap.Dnstap_MESSAGE
|
||||||
dio.Dnstap(tap.Dnstap{Type: &tmsg})
|
dio.Dnstap(&tap.Dnstap{Type: &tmsg})
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ func TestReconnect(t *testing.T) {
|
||||||
dio.connect()
|
dio.connect()
|
||||||
defer dio.close()
|
defer dio.close()
|
||||||
|
|
||||||
dio.Dnstap(tmsg)
|
dio.Dnstap(&tmsg)
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ func TestReconnect(t *testing.T) {
|
||||||
|
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
dio.Dnstap(tmsg)
|
dio.Dnstap(&tmsg)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,6 @@ func split255(s string) []string {
|
||||||
} else {
|
} else {
|
||||||
sx = append(sx, s[p:])
|
sx = append(sx, s[p:])
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
p, i = p+255, i+255
|
p, i = p+255, i+255
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,9 @@ import (
|
||||||
//
|
//
|
||||||
// Note that a service can double/triple as a TXT record or MX record.
|
// Note that a service can double/triple as a TXT record or MX record.
|
||||||
func (s *Service) HostType() (what uint16, normalized net.IP) {
|
func (s *Service) HostType() (what uint16, normalized net.IP) {
|
||||||
|
|
||||||
ip := net.ParseIP(s.Host)
|
ip := net.ParseIP(s.Host)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
|
||||||
case ip == nil:
|
case ip == nil:
|
||||||
if len(s.Text) == 0 {
|
if len(s.Text) == 0 {
|
||||||
return dns.TypeCNAME, nil
|
return dns.TypeCNAME, nil
|
||||||
|
|
|
@ -40,7 +40,7 @@ func etcdParse(c *caddy.Controller) (*Etcd, error) {
|
||||||
|
|
||||||
etc.Upstream = upstream.New()
|
etc.Upstream = upstream.New()
|
||||||
|
|
||||||
for c.Next() {
|
if c.Next() {
|
||||||
etc.Zones = plugin.OriginsFromArgsOrServerBlock(c.RemainingArgs(), c.ServerBlockKeys)
|
etc.Zones = plugin.OriginsFromArgsOrServerBlock(c.RemainingArgs(), c.ServerBlockKeys)
|
||||||
for c.NextBlock() {
|
for c.NextBlock() {
|
||||||
switch c.Val() {
|
switch c.Val() {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
|
|
||||||
// ClosestEncloser returns the closest encloser for qname.
|
// ClosestEncloser returns the closest encloser for qname.
|
||||||
func (z *Zone) ClosestEncloser(qname string) (*tree.Elem, bool) {
|
func (z *Zone) ClosestEncloser(qname string) (*tree.Elem, bool) {
|
||||||
|
|
||||||
offset, end := dns.NextLabel(qname, 0)
|
offset, end := dns.NextLabel(qname, 0)
|
||||||
for !end {
|
for !end {
|
||||||
elem, _ := z.Tree.Search(qname)
|
elem, _ := z.Tree.Search(qname)
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
// Make sure the external miekg/dns dependency is up to date
|
// Make sure the external miekg/dns dependency is up to date
|
||||||
|
|
||||||
func TestInclude(t *testing.T) {
|
func TestInclude(t *testing.T) {
|
||||||
|
|
||||||
name, rm, err := test.TempFile(".", "foo\tIN\tA\t127.0.0.1\n")
|
name, rm, err := test.TempFile(".", "foo\tIN\tA\t127.0.0.1\n")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to create tmpfile %q: %s", name, err)
|
t.Fatalf("Unable to create tmpfile %q: %s", name, err)
|
||||||
|
|
|
@ -151,7 +151,6 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
|
||||||
|
|
||||||
// If we see NS records, it means the name as been delegated, and we should return the delegation.
|
// If we see NS records, it means the name as been delegated, and we should return the delegation.
|
||||||
if nsrrs := elem.Type(dns.TypeNS); nsrrs != nil {
|
if nsrrs := elem.Type(dns.TypeNS); nsrrs != nil {
|
||||||
|
|
||||||
// If the query is specifically for DS and the qname matches the delegated name, we should
|
// If the query is specifically for DS and the qname matches the delegated name, we should
|
||||||
// return the DS in the answer section and leave the rest empty, i.e. just continue the loop
|
// return the DS in the answer section and leave the rest empty, i.e. just continue the loop
|
||||||
// and continue searching.
|
// and continue searching.
|
||||||
|
@ -179,7 +178,6 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
|
||||||
|
|
||||||
// Found entire name.
|
// Found entire name.
|
||||||
if found && shot {
|
if found && shot {
|
||||||
|
|
||||||
if rrs := elem.Type(dns.TypeCNAME); len(rrs) > 0 && qtype != dns.TypeCNAME {
|
if rrs := elem.Type(dns.TypeCNAME); len(rrs) > 0 && qtype != dns.TypeCNAME {
|
||||||
ctx = context.WithValue(ctx, dnsserver.LoopKey{}, loop+1)
|
ctx = context.WithValue(ctx, dnsserver.LoopKey{}, loop+1)
|
||||||
return z.externalLookup(ctx, state, elem, rrs)
|
return z.externalLookup(ctx, state, elem, rrs)
|
||||||
|
@ -208,7 +206,6 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
|
||||||
}
|
}
|
||||||
|
|
||||||
return rrs, ap.ns(do), additional, Success
|
return rrs, ap.ns(do), additional, Success
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Haven't found the original name.
|
// Haven't found the original name.
|
||||||
|
@ -248,7 +245,6 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
|
||||||
sigs := wildElem.TypeForWildcard(dns.TypeRRSIG, qname)
|
sigs := wildElem.TypeForWildcard(dns.TypeRRSIG, qname)
|
||||||
sigs = rrutil.SubTypeSignature(sigs, qtype)
|
sigs = rrutil.SubTypeSignature(sigs, qtype)
|
||||||
rrs = append(rrs, sigs...)
|
rrs = append(rrs, sigs...)
|
||||||
|
|
||||||
}
|
}
|
||||||
return rrs, auth, nil, Success
|
return rrs, auth, nil, Success
|
||||||
}
|
}
|
||||||
|
@ -290,7 +286,6 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Out:
|
Out:
|
||||||
return nil, ret, nil, rcode
|
return nil, ret, nil, rcode
|
||||||
|
@ -325,7 +320,6 @@ func (a Apex) ns(do bool) []dns.RR {
|
||||||
|
|
||||||
// externalLookup adds signatures and tries to resolve CNAMEs that point to external names.
|
// externalLookup adds signatures and tries to resolve CNAMEs that point to external names.
|
||||||
func (z *Zone) externalLookup(ctx context.Context, state request.Request, elem *tree.Elem, rrs []dns.RR) ([]dns.RR, []dns.RR, []dns.RR, Result) {
|
func (z *Zone) externalLookup(ctx context.Context, state request.Request, elem *tree.Elem, rrs []dns.RR) ([]dns.RR, []dns.RR, []dns.RR, Result) {
|
||||||
|
|
||||||
qtype := state.QType()
|
qtype := state.QType()
|
||||||
do := state.Do()
|
do := state.Do()
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,6 @@ Restart:
|
||||||
retryTicker.Stop()
|
retryTicker.Stop()
|
||||||
expireTicker.Stop()
|
expireTicker.Stop()
|
||||||
goto Restart
|
goto Restart
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +191,6 @@ Restart:
|
||||||
func jitter(n int) time.Duration {
|
func jitter(n int) time.Duration {
|
||||||
r := rand.Intn(n)
|
r := rand.Intn(n)
|
||||||
return time.Duration(r) * time.Millisecond
|
return time.Duration(r) * time.Millisecond
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxSerialIncrement is the maximum difference between two serial numbers. If the difference between
|
// MaxSerialIncrement is the maximum difference between two serial numbers. If the difference between
|
||||||
|
|
|
@ -139,7 +139,6 @@ func fileParse(c *caddy.Controller) (Zones, error) {
|
||||||
return Zones{}, plugin.Error("file", openErr)
|
return Zones{}, plugin.Error("file", openErr)
|
||||||
}
|
}
|
||||||
log.Warningf("Failed to open %q: trying again in %s", openErr, reload)
|
log.Warningf("Failed to open %q: trying again in %s", openErr, reload)
|
||||||
|
|
||||||
}
|
}
|
||||||
return Zones{Z: z, Names: names}, nil
|
return Zones{Z: z, Names: names}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,6 @@ Tests:
|
||||||
}
|
}
|
||||||
continue Tests
|
continue Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,6 @@ func (f *Forward) Name() string { return "forward" }
|
||||||
|
|
||||||
// ServeDNS implements plugin.Handler.
|
// ServeDNS implements plugin.Handler.
|
||||||
func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
||||||
|
|
||||||
state := request.Request{W: w, Req: r}
|
state := request.Request{W: w, Req: r}
|
||||||
if !f.match(state) {
|
if !f.match(state) {
|
||||||
return plugin.NextOrFailure(f.Name(), f.Next, ctx, w, r)
|
return plugin.NextOrFailure(f.Name(), f.Next, ctx, w, r)
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMetadata(t *testing.T) {
|
func TestMetadata(t *testing.T) {
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
label string
|
label string
|
||||||
expectedValue string
|
expectedValue string
|
||||||
|
@ -37,7 +36,6 @@ func TestMetadata(t *testing.T) {
|
||||||
|
|
||||||
knownIPAddr := "81.2.69.142" // This IP should be be part of the CDIR address range used to create the database fixtures.
|
knownIPAddr := "81.2.69.142" // This IP should be be part of the CDIR address range used to create the database fixtures.
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
|
|
||||||
t.Run(fmt.Sprintf("%s/%s", tc.label, "direct"), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%s/%s", tc.label, "direct"), func(t *testing.T) {
|
||||||
geoIP, err := newGeoIP(cityDBPath, false)
|
geoIP, err := newGeoIP(cityDBPath, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -89,5 +87,4 @@ func testMetadata(t *testing.T, state request.Request, geoIP *GeoIP, label, expe
|
||||||
t.Errorf("expected value for label %q should be %q, got %q instead",
|
t.Errorf("expected value for label %q should be %q, got %q instead",
|
||||||
label, expectedValue, value)
|
label, expectedValue, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ func newProxy(addr string, tlsConfig *tls.Config) (*Proxy, error) {
|
||||||
if tlsConfig != nil {
|
if tlsConfig != nil {
|
||||||
p.dialOpts = append(p.dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)))
|
p.dialOpts = append(p.dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)))
|
||||||
} else {
|
} else {
|
||||||
p.dialOpts = append(p.dialOpts, grpc.WithInsecure())
|
p.dialOpts = append(p.dialOpts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := grpc.Dial(p.addr, p.dialOpts...)
|
conn, err := grpc.Dial(p.addr, p.dialOpts...)
|
||||||
|
|
|
@ -96,7 +96,6 @@ func parseStanza(c *caddy.Controller) (*GRPC, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseBlock(c *caddy.Controller, g *GRPC) error {
|
func parseBlock(c *caddy.Controller, g *GRPC) error {
|
||||||
|
|
||||||
switch c.Val() {
|
switch c.Val() {
|
||||||
case "except":
|
case "except":
|
||||||
ignore := c.RemainingArgs()
|
ignore := c.RemainingArgs()
|
||||||
|
|
|
@ -78,7 +78,5 @@ func TestHeader(t *testing.T) {
|
||||||
t.Errorf("Test %d: Expected flag state=%t, but got %t", i, test.expected, test.got(m))
|
t.Errorf("Test %d: Expected flag state=%t, but got %t", i, test.expected, test.got(m))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,5 +46,4 @@ func parse(c *caddy.Controller) ([]Rule, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, c.ArgErr()
|
return nil, c.ArgErr()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ func (e *External) a(ctx context.Context, services []msg.Service, state request.
|
||||||
dup := make(map[string]struct{})
|
dup := make(map[string]struct{})
|
||||||
|
|
||||||
for _, s := range services {
|
for _, s := range services {
|
||||||
|
|
||||||
what, ip := s.HostType()
|
what, ip := s.HostType()
|
||||||
|
|
||||||
switch what {
|
switch what {
|
||||||
|
@ -48,7 +47,6 @@ func (e *External) aaaa(ctx context.Context, services []msg.Service, state reque
|
||||||
dup := make(map[string]struct{})
|
dup := make(map[string]struct{})
|
||||||
|
|
||||||
for _, s := range services {
|
for _, s := range services {
|
||||||
|
|
||||||
what, ip := s.HostType()
|
what, ip := s.HostType()
|
||||||
|
|
||||||
switch what {
|
switch what {
|
||||||
|
@ -127,7 +125,6 @@ func (e *External) srv(ctx context.Context, services []msg.Service, state reques
|
||||||
what, ip := s.HostType()
|
what, ip := s.HostType()
|
||||||
|
|
||||||
switch what {
|
switch what {
|
||||||
|
|
||||||
case dns.TypeCNAME:
|
case dns.TypeCNAME:
|
||||||
addr := dns.Fqdn(s.Host)
|
addr := dns.Fqdn(s.Host)
|
||||||
srv := s.NewSRV(state.QName(), weight)
|
srv := s.NewSRV(state.QName(), weight)
|
||||||
|
|
|
@ -83,7 +83,6 @@ func TestTransferAXFR(t *testing.T) {
|
||||||
t.Errorf("%+v", rec)
|
t.Errorf("%+v", rec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTransferIXFR(t *testing.T) {
|
func TestTransferIXFR(t *testing.T) {
|
||||||
|
@ -127,7 +126,6 @@ func TestTransferIXFR(t *testing.T) {
|
||||||
t.Errorf("%+v", rec)
|
t.Errorf("%+v", rec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// difference shows what we're missing when comparing two RR slices
|
// difference shows what we're missing when comparing two RR slices
|
||||||
|
|
|
@ -755,5 +755,3 @@ func (dns *dnsControl) updateExtModifed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var errObj = errors.New("obj was not of the correct type")
|
var errObj = errors.New("obj was not of the correct type")
|
||||||
|
|
||||||
const defaultResyncPeriod = 0
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ var dnsEmptyServiceTestCases = []test.Case{
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestServeDNSEmptyService(t *testing.T) {
|
func TestServeDNSEmptyService(t *testing.T) {
|
||||||
|
|
||||||
k := New([]string{"cluster.local."})
|
k := New([]string{"cluster.local."})
|
||||||
k.APIConn = &APIConnServeTest{}
|
k.APIConn = &APIConnServeTest{}
|
||||||
k.opts.ignoreEmptyService = true
|
k.opts.ignoreEmptyService = true
|
||||||
|
|
|
@ -28,7 +28,6 @@ var podModeDisabledCases = []test.Case{
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestServeDNSModeDisabled(t *testing.T) {
|
func TestServeDNSModeDisabled(t *testing.T) {
|
||||||
|
|
||||||
k := New([]string{"cluster.local."})
|
k := New([]string{"cluster.local."})
|
||||||
k.APIConn = &APIConnServeTest{}
|
k.APIConn = &APIConnServeTest{}
|
||||||
k.Next = test.NextHandler(dns.RcodeSuccess, nil)
|
k.Next = test.NextHandler(dns.RcodeSuccess, nil)
|
||||||
|
|
|
@ -63,7 +63,6 @@ var podModeInsecureCases = []test.Case{
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestServeDNSModeInsecure(t *testing.T) {
|
func TestServeDNSModeInsecure(t *testing.T) {
|
||||||
|
|
||||||
k := New([]string{"cluster.local."})
|
k := New([]string{"cluster.local."})
|
||||||
k.APIConn = &APIConnServeTest{}
|
k.APIConn = &APIConnServeTest{}
|
||||||
k.Next = test.NextHandler(dns.RcodeSuccess, nil)
|
k.Next = test.NextHandler(dns.RcodeSuccess, nil)
|
||||||
|
|
|
@ -49,7 +49,6 @@ var podModeVerifiedCases = []test.Case{
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestServeDNSModeVerified(t *testing.T) {
|
func TestServeDNSModeVerified(t *testing.T) {
|
||||||
|
|
||||||
k := New([]string{"cluster.local."})
|
k := New([]string{"cluster.local."})
|
||||||
k.APIConn = &APIConnServeTest{}
|
k.APIConn = &APIConnServeTest{}
|
||||||
k.Next = test.NextHandler(dns.RcodeSuccess, nil)
|
k.Next = test.NextHandler(dns.RcodeSuccess, nil)
|
||||||
|
|
|
@ -494,7 +494,6 @@ var notSyncedTestCases = []test.Case{
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNotSyncedServeDNS(t *testing.T) {
|
func TestNotSyncedServeDNS(t *testing.T) {
|
||||||
|
|
||||||
k := New([]string{"cluster.local."})
|
k := New([]string{"cluster.local."})
|
||||||
k.APIConn = &APIConnServeTest{
|
k.APIConn = &APIConnServeTest{
|
||||||
notSynced: true,
|
notSynced: true,
|
||||||
|
|
|
@ -96,7 +96,6 @@ var (
|
||||||
func (k *Kubernetes) Services(ctx context.Context, state request.Request, exact bool, opt plugin.Options) (svcs []msg.Service, err error) {
|
func (k *Kubernetes) Services(ctx context.Context, state request.Request, exact bool, opt plugin.Options) (svcs []msg.Service, err error) {
|
||||||
// We're looking again at types, which we've already done in ServeDNS, but there are some types k8s just can't answer.
|
// We're looking again at types, which we've already done in ServeDNS, but there are some types k8s just can't answer.
|
||||||
switch state.QType() {
|
switch state.QType() {
|
||||||
|
|
||||||
case dns.TypeTXT:
|
case dns.TypeTXT:
|
||||||
// 1 label + zone, label must be "dns-version".
|
// 1 label + zone, label must be "dns-version".
|
||||||
t, _ := dnsutil.TrimZone(state.Name(), state.Zone)
|
t, _ := dnsutil.TrimZone(state.Name(), state.Zone)
|
||||||
|
@ -216,7 +215,6 @@ func (k *Kubernetes) getClientConfig() (*rest.Config, error) {
|
||||||
}
|
}
|
||||||
cc.ContentType = "application/vnd.kubernetes.protobuf"
|
cc.ContentType = "application/vnd.kubernetes.protobuf"
|
||||||
return cc, err
|
return cc, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitKubeCache initializes a new Kubernetes cache.
|
// InitKubeCache initializes a new Kubernetes cache.
|
||||||
|
@ -542,7 +540,6 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
|
||||||
|
|
||||||
for _, eps := range ep.Subsets {
|
for _, eps := range ep.Subsets {
|
||||||
for _, addr := range eps.Addresses {
|
for _, addr := range eps.Addresses {
|
||||||
|
|
||||||
// See comments in parse.go parseRequest about the endpoint handling.
|
// See comments in parse.go parseRequest about the endpoint handling.
|
||||||
if r.endpoint != "" {
|
if r.endpoint != "" {
|
||||||
if !match(r.endpoint, endpointHostname(addr, k.endpointNameMode)) {
|
if !match(r.endpoint, endpointHostname(addr, k.endpointNameMode)) {
|
||||||
|
|
|
@ -60,7 +60,6 @@ var kubeApexCases = []test.Case{
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestServeDNSApex(t *testing.T) {
|
func TestServeDNSApex(t *testing.T) {
|
||||||
|
|
||||||
k := New([]string{"cluster.local."})
|
k := New([]string{"cluster.local."})
|
||||||
k.APIConn = &APIConnServeTest{}
|
k.APIConn = &APIConnServeTest{}
|
||||||
k.Next = test.NextHandler(dns.RcodeSuccess, nil)
|
k.Next = test.NextHandler(dns.RcodeSuccess, nil)
|
||||||
|
|
|
@ -99,7 +99,6 @@ func (APIConnTest) GetNamespaceByName(name string) (*object.Namespace, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNsAddrs(t *testing.T) {
|
func TestNsAddrs(t *testing.T) {
|
||||||
|
|
||||||
k := New([]string{"inter.webs.test."})
|
k := New([]string{"inter.webs.test."})
|
||||||
k.APIConn = &APIConnTest{}
|
k.APIConn = &APIConnTest{}
|
||||||
k.localIPs = []net.IP{net.ParseIP("10.244.0.20")}
|
k.localIPs = []net.IP{net.ParseIP("10.244.0.20")}
|
||||||
|
@ -108,7 +107,6 @@ func TestNsAddrs(t *testing.T) {
|
||||||
|
|
||||||
if len(cdrs) != 3 {
|
if len(cdrs) != 3 {
|
||||||
t.Fatalf("Expected 3 results, got %v", len(cdrs))
|
t.Fatalf("Expected 3 results, got %v", len(cdrs))
|
||||||
|
|
||||||
}
|
}
|
||||||
cdr := cdrs[0]
|
cdr := cdrs[0]
|
||||||
expected := "10.0.0.111"
|
expected := "10.0.0.111"
|
||||||
|
@ -140,7 +138,6 @@ func TestNsAddrs(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNsAddrsExternal(t *testing.T) {
|
func TestNsAddrsExternal(t *testing.T) {
|
||||||
|
|
||||||
k := New([]string{"example.com."})
|
k := New([]string{"example.com."})
|
||||||
k.APIConn = &APIConnTest{}
|
k.APIConn = &APIConnTest{}
|
||||||
k.localIPs = []net.IP{net.ParseIP("10.244.0.20")}
|
k.localIPs = []net.IP{net.ParseIP("10.244.0.20")}
|
||||||
|
@ -150,7 +147,6 @@ func TestNsAddrsExternal(t *testing.T) {
|
||||||
|
|
||||||
if len(cdrs) != 0 {
|
if len(cdrs) != 0 {
|
||||||
t.Fatalf("Expected 0 results, got %v", len(cdrs))
|
t.Fatalf("Expected 0 results, got %v", len(cdrs))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an external IP to one of the services ...
|
// Add an external IP to one of the services ...
|
||||||
|
@ -159,7 +155,6 @@ func TestNsAddrsExternal(t *testing.T) {
|
||||||
|
|
||||||
if len(cdrs) != 1 {
|
if len(cdrs) != 1 {
|
||||||
t.Fatalf("Expected 1 results, got %v", len(cdrs))
|
t.Fatalf("Expected 1 results, got %v", len(cdrs))
|
||||||
|
|
||||||
}
|
}
|
||||||
cdr := cdrs[0]
|
cdr := cdrs[0]
|
||||||
expected := "1.2.3.4"
|
expected := "1.2.3.4"
|
||||||
|
@ -170,5 +165,4 @@ func TestNsAddrsExternal(t *testing.T) {
|
||||||
if cdr.Header().Name != expected {
|
if cdr.Header().Name != expected {
|
||||||
t.Errorf("Expected record name to be %q, got %q", expected, cdr.Header().Name)
|
t.Errorf("Expected record name to be %q, got %q", expected, cdr.Header().Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,6 @@ func ToService(obj meta.Object) (meta.Object, error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
s.ExternalIPs[li+i] = lb.Hostname
|
s.ExternalIPs[li+i] = lb.Hostname
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*svc = api.Service{}
|
*svc = api.Service{}
|
||||||
|
|
|
@ -66,7 +66,6 @@ func parseRequest(name, zone string) (r recordRequest, err error) {
|
||||||
// Because of ambiguity we check the labels left: 1: an endpoint. 2: port and protocol.
|
// Because of ambiguity we check the labels left: 1: an endpoint. 2: port and protocol.
|
||||||
// Anything else is a query that is too long to answer and can safely be delegated to return an nxdomain.
|
// Anything else is a query that is too long to answer and can safely be delegated to return an nxdomain.
|
||||||
switch last {
|
switch last {
|
||||||
|
|
||||||
case 0: // endpoint only
|
case 0: // endpoint only
|
||||||
r.endpoint = segs[last]
|
r.endpoint = segs[last]
|
||||||
case 1: // service and port
|
case 1: // service and port
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
|
|
||||||
// Reverse implements the ServiceBackend interface.
|
// Reverse implements the ServiceBackend interface.
|
||||||
func (k *Kubernetes) Reverse(ctx context.Context, state request.Request, exact bool, opt plugin.Options) ([]msg.Service, error) {
|
func (k *Kubernetes) Reverse(ctx context.Context, state request.Request, exact bool, opt plugin.Options) ([]msg.Service, error) {
|
||||||
|
|
||||||
ip := dnsutil.ExtractAddressFromReverse(state.Name())
|
ip := dnsutil.ExtractAddressFromReverse(state.Name())
|
||||||
if ip == "" {
|
if ip == "" {
|
||||||
_, e := k.Records(ctx, state, exact)
|
_, e := k.Records(ctx, state, exact)
|
||||||
|
|
|
@ -38,7 +38,6 @@ func (APIConnReverseTest) SvcIndex(svc string) []*object.Service {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return svcs
|
return svcs
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (APIConnReverseTest) SvcIndexReverse(ip string) []*object.Service {
|
func (APIConnReverseTest) SvcIndexReverse(ip string) []*object.Service {
|
||||||
|
@ -150,7 +149,6 @@ func (APIConnReverseTest) GetNamespaceByName(name string) (*object.Namespace, er
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReverse(t *testing.T) {
|
func TestReverse(t *testing.T) {
|
||||||
|
|
||||||
k := New([]string{"cluster.local.", "0.10.in-addr.arpa.", "168.192.in-addr.arpa.", "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa.", "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa."})
|
k := New([]string{"cluster.local.", "0.10.in-addr.arpa.", "168.192.in-addr.arpa.", "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa.", "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa."})
|
||||||
k.APIConn = &APIConnReverseTest{}
|
k.APIConn = &APIConnReverseTest{}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,6 @@ func kubernetesParse(c *caddy.Controller) (*Kubernetes, error) {
|
||||||
|
|
||||||
// ParseStanza parses a kubernetes stanza
|
// ParseStanza parses a kubernetes stanza
|
||||||
func ParseStanza(c *caddy.Controller) (*Kubernetes, error) {
|
func ParseStanza(c *caddy.Controller) (*Kubernetes, error) {
|
||||||
|
|
||||||
k8s := New([]string{""})
|
k8s := New([]string{""})
|
||||||
k8s.autoPathSearch = searchFromResolvConf()
|
k8s.autoPathSearch = searchFromResolvConf()
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,6 @@ func (k *Kubernetes) Transfer(zone string, serial uint32) (<-chan []dns.RR, erro
|
||||||
}
|
}
|
||||||
svcBase := []string{zonePath, Svc, svc.Namespace, svc.Name}
|
svcBase := []string{zonePath, Svc, svc.Namespace, svc.Name}
|
||||||
switch svc.Type {
|
switch svc.Type {
|
||||||
|
|
||||||
case api.ServiceTypeClusterIP, api.ServiceTypeNodePort, api.ServiceTypeLoadBalancer:
|
case api.ServiceTypeClusterIP, api.ServiceTypeNodePort, api.ServiceTypeLoadBalancer:
|
||||||
clusterIP := net.ParseIP(svc.ClusterIPs[0])
|
clusterIP := net.ParseIP(svc.ClusterIPs[0])
|
||||||
if clusterIP != nil {
|
if clusterIP != nil {
|
||||||
|
|
|
@ -91,7 +91,6 @@ func TestLoadBalance(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Test %d: Expected no error, but got %s", i, err)
|
t.Errorf("Test %d: Expected no error, but got %s", i, err)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cname, address, mx, sorted := countRecords(rec.Msg.Answer)
|
cname, address, mx, sorted := countRecords(rec.Msg.Answer)
|
||||||
|
|
|
@ -35,7 +35,6 @@ func parse(c *caddy.Controller) error {
|
||||||
case 1:
|
case 1:
|
||||||
if args[0] != "round_robin" {
|
if args[0] != "round_robin" {
|
||||||
return fmt.Errorf("unknown policy: %s", args[0])
|
return fmt.Errorf("unknown policy: %s", args[0])
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@ func (l Logger) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc, err
|
return rc, err
|
||||||
|
|
||||||
}
|
}
|
||||||
return plugin.NextOrFailure(l.Name(), l.Next, ctx, w, r)
|
return plugin.NextOrFailure(l.Name(), l.Next, ctx, w, r)
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,6 @@ func TestLogParse(t *testing.T) {
|
||||||
i, len(test.expectedLogRules), len(actualLogRules))
|
i, len(test.expectedLogRules), len(actualLogRules))
|
||||||
}
|
}
|
||||||
for j, actualLogRule := range actualLogRules {
|
for j, actualLogRule := range actualLogRules {
|
||||||
|
|
||||||
if actualLogRule.NameScope != test.expectedLogRules[j].NameScope {
|
if actualLogRule.NameScope != test.expectedLogRules[j].NameScope {
|
||||||
t.Errorf("Test %d expected %dth LogRule NameScope for '%s' to be %s , but got %s",
|
t.Errorf("Test %d expected %dth LogRule NameScope for '%s' to be %s , but got %s",
|
||||||
i, j, test.inputLogRules, test.expectedLogRules[j].NameScope, actualLogRule.NameScope)
|
i, j, test.inputLogRules, test.expectedLogRules[j].NameScope, actualLogRule.NameScope)
|
||||||
|
|
|
@ -27,7 +27,6 @@ func ContextWithMetadata(ctx context.Context) context.Context {
|
||||||
|
|
||||||
// ServeDNS implements the plugin.Handler interface.
|
// ServeDNS implements the plugin.Handler interface.
|
||||||
func (m *Metadata) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
func (m *Metadata) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
||||||
|
|
||||||
ctx = ContextWithMetadata(ctx)
|
ctx = ContextWithMetadata(ctx)
|
||||||
|
|
||||||
state := request.Request{W: w, Req: r}
|
state := request.Request{W: w, Req: r}
|
||||||
|
|
|
@ -64,7 +64,6 @@ func IsLabel(label string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Labels returns all metadata keys stored in the context. These label names should be named
|
// Labels returns all metadata keys stored in the context. These label names should be named
|
||||||
|
|
|
@ -125,7 +125,6 @@ func (h Host) NormalizeExact() []string {
|
||||||
}
|
}
|
||||||
for i := range hosts {
|
for i := range hosts {
|
||||||
hosts[i] = Name(hosts[i]).Normalize()
|
hosts[i] = Name(hosts[i]).Normalize()
|
||||||
|
|
||||||
}
|
}
|
||||||
return hosts
|
return hosts
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,6 @@ func TestNameMatches(t *testing.T) {
|
||||||
if actual != m.expected {
|
if actual != m.expected {
|
||||||
t.Errorf("Expected %v for %s/%s, got %v", m.expected, m.parent, m.child, actual)
|
t.Errorf("Expected %v for %s/%s, got %v", m.expected, m.parent, m.child, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ func Split(n *net.IPNet) []string {
|
||||||
func nets(network *net.IPNet, newPrefixLen int) []*net.IPNet {
|
func nets(network *net.IPNet, newPrefixLen int) []*net.IPNet {
|
||||||
prefixLen, _ := network.Mask.Size()
|
prefixLen, _ := network.Mask.Size()
|
||||||
maxSubnets := int(math.Exp2(float64(newPrefixLen)) / math.Exp2(float64(prefixLen)))
|
maxSubnets := int(math.Exp2(float64(newPrefixLen)) / math.Exp2(float64(prefixLen)))
|
||||||
nets := []*net.IPNet{{network.IP, net.CIDRMask(newPrefixLen, 8*len(network.IP))}}
|
nets := []*net.IPNet{{IP: network.IP, Mask: net.CIDRMask(newPrefixLen, 8*len(network.IP))}}
|
||||||
|
|
||||||
for i := 1; i < maxSubnets; i++ {
|
for i := 1; i < maxSubnets; i++ {
|
||||||
next, exceeds := cidr.NextSubnet(nets[len(nets)-1], newPrefixLen)
|
next, exceeds := cidr.NextSubnet(nets[len(nets)-1], newPrefixLen)
|
||||||
|
|
|
@ -19,7 +19,6 @@ func TestMultiWriteMsg(t *testing.T) {
|
||||||
|
|
||||||
if len(record.Msgs) != 2 {
|
if len(record.Msgs) != 2 {
|
||||||
t.Fatalf("Expected 2 messages to be written, but instead found %d\n", len(record.Msgs))
|
t.Fatalf("Expected 2 messages to be written, but instead found %d\n", len(record.Msgs))
|
||||||
|
|
||||||
}
|
}
|
||||||
if record.Len != responseTestMsg.Len()*2 {
|
if record.Len != responseTestMsg.Len()*2 {
|
||||||
t.Fatalf("Expected the bytes written counter to be %d, but instead found %d\n", responseTestMsg.Len()*2, record.Len)
|
t.Fatalf("Expected the bytes written counter to be %d, but instead found %d\n", responseTestMsg.Len()*2, record.Len)
|
||||||
|
|
|
@ -66,6 +66,5 @@ func TestIsReverse(t *testing.T) {
|
||||||
if got != tc.expected {
|
if got != tc.expected {
|
||||||
t.Errorf("Test %d, got %d, expected %d for %s", i, got, tc.expected, tc.name)
|
t.Errorf("Test %d, got %d, expected %d for %s", i, got, tc.expected, tc.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ func stripZone(host string) string {
|
||||||
func HostPortOrFile(s ...string) ([]string, error) {
|
func HostPortOrFile(s ...string) ([]string, error) {
|
||||||
var servers []string
|
var servers []string
|
||||||
for _, h := range s {
|
for _, h := range s {
|
||||||
|
|
||||||
trans, host := Transport(h)
|
trans, host := Transport(h)
|
||||||
|
|
||||||
addr, _, err := net.SplitHostPort(host)
|
addr, _, err := net.SplitHostPort(host)
|
||||||
|
|
|
@ -32,5 +32,4 @@ func (r *Rand) Perm(n int) []int {
|
||||||
v := r.r.Perm(n)
|
v := r.r.Perm(n)
|
||||||
r.m.Unlock()
|
r.m.Unlock()
|
||||||
return v
|
return v
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,6 +271,7 @@ func (r replacer) Replace(ctx context.Context, state request.Request, rr *dnstes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s := string(b)
|
s := string(b)
|
||||||
|
//nolint:staticcheck
|
||||||
bufPool.Put(b[:0])
|
bufPool.Put(b[:0])
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,7 +276,6 @@ func BenchmarkReplacer(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkReplacer_CommonLogFormat(b *testing.B) {
|
func BenchmarkReplacer_CommonLogFormat(b *testing.B) {
|
||||||
|
|
||||||
w := dnstest.NewRecorder(&test.ResponseWriter{})
|
w := dnstest.NewRecorder(&test.ResponseWriter{})
|
||||||
r := new(dns.Msg)
|
r := new(dns.Msg)
|
||||||
r.SetQuestion("example.org.", dns.TypeHINFO)
|
r.SetQuestion("example.org.", dns.TypeHINFO)
|
||||||
|
|
|
@ -57,7 +57,6 @@ func setup(c *caddy.Controller) error {
|
||||||
return plugin.Error("pprof", c.Errf("unknown property '%s'", c.Val()))
|
return plugin.Error("pprof", c.Errf("unknown property '%s'", c.Val()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c.OnStartup(h.Startup)
|
c.OnStartup(h.Startup)
|
||||||
|
|
|
@ -180,7 +180,6 @@ func newEdns0VariableRule(mode, action, code, variable string) (*edns0VariableRu
|
||||||
|
|
||||||
// ruleData returns the data specified by the variable.
|
// ruleData returns the data specified by the variable.
|
||||||
func (rule *edns0VariableRule) ruleData(ctx context.Context, state request.Request) ([]byte, error) {
|
func (rule *edns0VariableRule) ruleData(ctx context.Context, state request.Request) ([]byte, error) {
|
||||||
|
|
||||||
switch rule.variable {
|
switch rule.variable {
|
||||||
case queryName:
|
case queryName:
|
||||||
return []byte(state.QName()), nil
|
return []byte(state.QName()), nil
|
||||||
|
|
|
@ -367,7 +367,6 @@ func parseAnswerRules(name string, args []string) (auto bool, rules ResponseRule
|
||||||
if last == "" && args[arg] != AnswerMatch {
|
if last == "" && args[arg] != AnswerMatch {
|
||||||
if last == "" {
|
if last == "" {
|
||||||
return false, nil, fmt.Errorf("exceeded the number of arguments for a non-answer rule argument for %s rule", name)
|
return false, nil, fmt.Errorf("exceeded the number of arguments for a non-answer rule argument for %s rule", name)
|
||||||
|
|
||||||
}
|
}
|
||||||
return false, nil, fmt.Errorf("exceeded the number of arguments for %s answer rule for %s rule", last, name)
|
return false, nil, fmt.Errorf("exceeded the number of arguments for %s answer rule for %s rule", last, name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ func TestRewriteIllegalName(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRewriteNamePrefixSuffix(t *testing.T) {
|
func TestRewriteNamePrefixSuffix(t *testing.T) {
|
||||||
|
|
||||||
ctx, close := context.WithCancel(context.TODO())
|
ctx, close := context.WithCancel(context.TODO())
|
||||||
defer close()
|
defer close()
|
||||||
|
|
||||||
|
@ -76,7 +75,6 @@ func TestRewriteNamePrefixSuffix(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRewriteNameNoRewrite(t *testing.T) {
|
func TestRewriteNameNoRewrite(t *testing.T) {
|
||||||
|
|
||||||
ctx, close := context.WithCancel(context.TODO())
|
ctx, close := context.WithCancel(context.TODO())
|
||||||
defer close()
|
defer close()
|
||||||
|
|
||||||
|
@ -119,7 +117,6 @@ func TestRewriteNameNoRewrite(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRewriteNamePrefixSuffixNoAutoAnswer(t *testing.T) {
|
func TestRewriteNamePrefixSuffixNoAutoAnswer(t *testing.T) {
|
||||||
|
|
||||||
ctx, close := context.WithCancel(context.TODO())
|
ctx, close := context.WithCancel(context.TODO())
|
||||||
defer close()
|
defer close()
|
||||||
|
|
||||||
|
@ -162,7 +159,6 @@ func TestRewriteNamePrefixSuffixNoAutoAnswer(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRewriteNamePrefixSuffixAutoAnswer(t *testing.T) {
|
func TestRewriteNamePrefixSuffixAutoAnswer(t *testing.T) {
|
||||||
|
|
||||||
ctx, close := context.WithCancel(context.TODO())
|
ctx, close := context.WithCancel(context.TODO())
|
||||||
defer close()
|
defer close()
|
||||||
|
|
||||||
|
@ -211,7 +207,6 @@ func TestRewriteNamePrefixSuffixAutoAnswer(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRewriteNameExactAnswer(t *testing.T) {
|
func TestRewriteNameExactAnswer(t *testing.T) {
|
||||||
|
|
||||||
ctx, close := context.WithCancel(context.TODO())
|
ctx, close := context.WithCancel(context.TODO())
|
||||||
defer close()
|
defer close()
|
||||||
|
|
||||||
|
@ -260,7 +255,6 @@ func TestRewriteNameExactAnswer(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRewriteNameRegexAnswer(t *testing.T) {
|
func TestRewriteNameRegexAnswer(t *testing.T) {
|
||||||
|
|
||||||
ctx, close := context.WithCancel(context.TODO())
|
ctx, close := context.WithCancel(context.TODO())
|
||||||
defer close()
|
defer close()
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ var tests = []struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestResponseReverter(t *testing.T) {
|
func TestResponseReverter(t *testing.T) {
|
||||||
|
|
||||||
rules := []Rule{}
|
rules := []Rule{}
|
||||||
r, _ := newNameRule("stop", "regex", `(core)\.(dns)\.(rocks)`, "{2}.{1}.{3}", "answer", "name", `(dns)\.(core)\.(rocks)`, "{2}.{1}.{3}")
|
r, _ := newNameRule("stop", "regex", `(core)\.(dns)\.(rocks)`, "{2}.{1}.{3}", "answer", "name", `(dns)\.(core)\.(rocks)`, "{2}.{1}.{3}")
|
||||||
rules = append(rules, r)
|
rules = append(rules, r)
|
||||||
|
@ -98,7 +97,6 @@ var valueTests = []struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValueResponseReverter(t *testing.T) {
|
func TestValueResponseReverter(t *testing.T) {
|
||||||
|
|
||||||
rules := []Rule{}
|
rules := []Rule{}
|
||||||
r, err := newNameRule("stop", "regex", `(.*)\.domain\.uk`, "{1}.cluster.local", "answer", "name", `(.*)\.cluster\.local`, "{1}.domain.uk", "answer", "value", `(.*)\.cluster\.local`, "{1}.domain.uk")
|
r, err := newNameRule("stop", "regex", `(.*)\.domain\.uk`, "{1}.cluster.local", "answer", "name", `(.*)\.cluster\.local`, "{1}.domain.uk", "answer", "value", `(.*)\.cluster\.local`, "{1}.domain.uk")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParse(t *testing.T) {
|
func TestParse(t *testing.T) {
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
inputFileRules string
|
inputFileRules string
|
||||||
shouldErr bool
|
shouldErr bool
|
||||||
|
@ -49,5 +48,4 @@ func TestParse(t *testing.T) {
|
||||||
t.Errorf("Test %d got wrong error for invalid response rewrite: '%v'\n---\n%s", i, err.Error(), test.inputFileRules)
|
t.Errorf("Test %d got wrong error for invalid response rewrite: '%v'\n---\n%s", i, err.Error(), test.inputFileRules)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
|
|
||||||
// ipToWire writes IP address to wire/binary format, 4 or 16 bytes depends on IPV4 or IPV6.
|
// ipToWire writes IP address to wire/binary format, 4 or 16 bytes depends on IPV4 or IPV6.
|
||||||
func ipToWire(family int, ipAddr string) ([]byte, error) {
|
func ipToWire(family int, ipAddr string) ([]byte, error) {
|
||||||
|
|
||||||
switch family {
|
switch family {
|
||||||
case 1:
|
case 1:
|
||||||
return net.ParseIP(ipAddr).To4(), nil
|
return net.ParseIP(ipAddr).To4(), nil
|
||||||
|
@ -28,7 +27,6 @@ func uint16ToWire(data uint16) []byte {
|
||||||
|
|
||||||
// portToWire writes port to wire/binary format, 2 bytes
|
// portToWire writes port to wire/binary format, 2 bytes
|
||||||
func portToWire(portStr string) ([]byte, error) {
|
func portToWire(portStr string) ([]byte, error) {
|
||||||
|
|
||||||
port, err := strconv.ParseUint(portStr, 10, 16)
|
port, err := strconv.ParseUint(portStr, 10, 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -212,7 +212,6 @@ func maybeUnescape(s string) (string, error) {
|
||||||
|
|
||||||
func updateZoneFromRRS(rrs *route53.ResourceRecordSet, z *file.Zone) error {
|
func updateZoneFromRRS(rrs *route53.ResourceRecordSet, z *file.Zone) error {
|
||||||
for _, rr := range rrs.ResourceRecords {
|
for _, rr := range rrs.ResourceRecords {
|
||||||
|
|
||||||
n, err := maybeUnescape(aws.StringValue(rrs.Name))
|
n, err := maybeUnescape(aws.StringValue(rrs.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to unescape `%s' name: %v", aws.StringValue(rrs.Name), err)
|
return fmt.Errorf("failed to unescape `%s' name: %v", aws.StringValue(rrs.Name), err)
|
||||||
|
@ -273,7 +272,6 @@ func (h *Route53) updateZones(ctx context.Context) error {
|
||||||
(*z[i]).z = newZ
|
(*z[i]).z = newZ
|
||||||
h.zMu.Unlock()
|
h.zMu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
}(zName, z)
|
}(zName, z)
|
||||||
}
|
}
|
||||||
// Collect errors (if any). This will also sync on all zones updates
|
// Collect errors (if any). This will also sync on all zones updates
|
||||||
|
|
|
@ -109,7 +109,6 @@ func TestRoute53(t *testing.T) {
|
||||||
|
|
||||||
m.Authoritative = true
|
m.Authoritative = true
|
||||||
rcode = dns.RcodeSuccess
|
rcode = dns.RcodeSuccess
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m.SetRcode(r, rcode)
|
m.SetRcode(r, rcode)
|
||||||
|
|
|
@ -126,10 +126,12 @@ func setup(c *caddy.Controller) error {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
h, err := New(ctx, client, keys, refresh)
|
h, err := New(ctx, client, keys, refresh)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
cancel()
|
||||||
return plugin.Error("route53", c.Errf("failed to create route53 plugin: %v", err))
|
return plugin.Error("route53", c.Errf("failed to create route53 plugin: %v", err))
|
||||||
}
|
}
|
||||||
h.Fall = fall
|
h.Fall = fall
|
||||||
if err := h.Run(ctx); err != nil {
|
if err := h.Run(ctx); err != nil {
|
||||||
|
cancel()
|
||||||
return plugin.Error("route53", c.Errf("failed to initialize route53 plugin: %v", err))
|
return plugin.Error("route53", c.Errf("failed to initialize route53 plugin: %v", err))
|
||||||
}
|
}
|
||||||
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
|
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
|
||||||
|
|
|
@ -64,7 +64,6 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
|
||||||
z := make(map[string]*file.Zone)
|
z := make(map[string]*file.Zone)
|
||||||
names := []string{}
|
names := []string{}
|
||||||
for c.Next() {
|
for c.Next() {
|
||||||
|
|
||||||
if c.Val() == "secondary" {
|
if c.Val() == "secondary" {
|
||||||
// secondary [origin]
|
// secondary [origin]
|
||||||
origins := plugin.OriginsFromArgsOrServerBlock(c.RemainingArgs(), c.ServerBlockKeys)
|
origins := plugin.OriginsFromArgsOrServerBlock(c.RemainingArgs(), c.ServerBlockKeys)
|
||||||
|
@ -74,8 +73,7 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for c.NextBlock() {
|
for c.NextBlock() {
|
||||||
|
var f []string
|
||||||
f := []string{}
|
|
||||||
|
|
||||||
switch c.Val() {
|
switch c.Val() {
|
||||||
case "transfer":
|
case "transfer":
|
||||||
|
|
|
@ -32,7 +32,6 @@ func templateParse(c *caddy.Controller) (handler Handler, err error) {
|
||||||
handler.Templates = make([]template, 0)
|
handler.Templates = make([]template, 0)
|
||||||
|
|
||||||
for c.Next() {
|
for c.Next() {
|
||||||
|
|
||||||
if !c.NextArg() {
|
if !c.NextArg() {
|
||||||
return handler, c.ArgErr()
|
return handler, c.ArgErr()
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ func TestSetup(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetupParse(t *testing.T) {
|
func TestSetupParse(t *testing.T) {
|
||||||
|
|
||||||
serverBlockKeys := []string{"domain.com.:8053", "dynamic.domain.com.:8053"}
|
serverBlockKeys := []string{"domain.com.:8053", "dynamic.domain.com.:8053"}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
|
|
@ -285,7 +285,6 @@ func SortAndCheck(resp *dns.Msg, tc Case) error {
|
||||||
}
|
}
|
||||||
if err := Section(tc, Ns, resp.Ns); err != nil {
|
if err := Section(tc, Ns, resp.Ns); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
||||||
}
|
}
|
||||||
return Section(tc, Extra, resp.Extra)
|
return Section(tc, Extra, resp.Extra)
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,6 @@ func Scrape(url string) []*MetricFamily {
|
||||||
// ScrapeMetricAsInt provides a sum of all metrics collected for the name and label provided.
|
// ScrapeMetricAsInt provides a sum of all metrics collected for the name and label provided.
|
||||||
// if the metric is not a numeric value, it will be counted a 0.
|
// if the metric is not a numeric value, it will be counted a 0.
|
||||||
func ScrapeMetricAsInt(addr string, name string, label string, nometricvalue int) int {
|
func ScrapeMetricAsInt(addr string, name string, label string, nometricvalue int) int {
|
||||||
|
|
||||||
valueToInt := func(m metric) int {
|
valueToInt := func(m metric) int {
|
||||||
v := m.Value
|
v := m.Value
|
||||||
r, err := strconv.Atoi(v)
|
r, err := strconv.Atoi(v)
|
||||||
|
@ -141,7 +140,6 @@ func MetricValueLabel(name, label string, mfs []*MetricFamily) (string, map[stri
|
||||||
return m.(metric).Value, m.(metric).Labels
|
return m.(metric).Value, m.(metric).Labels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,9 @@ import (
|
||||||
|
|
||||||
type badwriter struct {
|
type badwriter struct {
|
||||||
dns.ResponseWriter
|
dns.ResponseWriter
|
||||||
count int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *badwriter) WriteMsg(res *dns.Msg) error { return fmt.Errorf("failed to write msg") }
|
func (w *badwriter) WriteMsg(_ *dns.Msg) error { return fmt.Errorf("failed to write msg") }
|
||||||
|
|
||||||
func TestWriteMessageFailed(t *testing.T) {
|
func TestWriteMessageFailed(t *testing.T) {
|
||||||
transfer := newTestTransfer()
|
transfer := newTestTransfer()
|
||||||
|
|
|
@ -98,7 +98,6 @@ func TestParse(t *testing.T) {
|
||||||
for k, zone := range x.Zones {
|
for k, zone := range x.Zones {
|
||||||
if tc.exp.xfrs[j].Zones[k] != zone {
|
if tc.exp.xfrs[j].Zones[k] != zone {
|
||||||
t.Errorf("Test %d expected zone %v, got %v", i, tc.exp.xfrs[j].Zones[k], zone)
|
t.Errorf("Test %d expected zone %v, got %v", i, tc.exp.xfrs[j].Zones[k], zone)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check to
|
// Check to
|
||||||
|
@ -108,7 +107,6 @@ func TestParse(t *testing.T) {
|
||||||
for k, to := range x.to {
|
for k, to := range x.to {
|
||||||
if tc.exp.xfrs[j].to[k] != to {
|
if tc.exp.xfrs[j].to[k] != to {
|
||||||
t.Errorf("Test %d expected %v in 'to', got %v", i, tc.exp.xfrs[j].to[k], to)
|
t.Errorf("Test %d expected %v in 'to', got %v", i, tc.exp.xfrs[j].to[k], to)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,6 @@ func (t *Transfer) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
|
||||||
return dns.RcodeServerFailure, err
|
return dns.RcodeServerFailure, err
|
||||||
}
|
}
|
||||||
l += len(rrs)
|
l += len(rrs)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(ch) // Even though we close the channel here, we still have
|
close(ch) // Even though we close the channel here, we still have
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParse(t *testing.T) {
|
func TestParse(t *testing.T) {
|
||||||
|
|
||||||
secrets := map[string]string{
|
secrets := map[string]string{
|
||||||
"name.key.": "test-key",
|
"name.key.": "test-key",
|
||||||
"name2.key.": "test-key-2",
|
"name2.key.": "test-key-2",
|
||||||
|
@ -150,7 +149,6 @@ key "name2.key." {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,6 +241,5 @@ func TestParseKeyFileErrors(t *testing.T) {
|
||||||
if err.Error() != testcase.err {
|
if err.Error() != testcase.err {
|
||||||
t.Errorf("Test %d: Expected error: %q, got %q", i, testcase.err, err.Error())
|
t.Errorf("Test %d: Expected error: %q, got %q", i, testcase.err, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,7 +313,6 @@ func (r *Request) Class() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
return dns.Class(r.Req.Question[0].Qclass).String()
|
return dns.Class(r.Req.Question[0].Qclass).String()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// QClass returns the class of the question in the request.
|
// QClass returns the class of the question in the request.
|
||||||
|
@ -327,7 +326,6 @@ func (r *Request) QClass() uint16 {
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.Req.Question[0].Qclass
|
return r.Req.Question[0].Qclass
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear clears all caching from Request s.
|
// Clear clears all caching from Request s.
|
||||||
|
|
|
@ -44,6 +44,5 @@ func TestFileLoop(t *testing.T) {
|
||||||
// For now: document current behavior in this test.
|
// For now: document current behavior in this test.
|
||||||
if r.Rcode != dns.RcodeServerFailure {
|
if r.Rcode != dns.RcodeServerFailure {
|
||||||
t.Errorf("Rcode should be dns.RcodeServerFailure: %d", r.Rcode)
|
t.Errorf("Rcode should be dns.RcodeServerFailure: %d", r.Rcode)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGrpc(t *testing.T) {
|
func TestGrpc(t *testing.T) {
|
||||||
|
@ -24,7 +25,7 @@ func TestGrpc(t *testing.T) {
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
conn, err := grpc.DialContext(ctx, tcp, grpc.WithInsecure(), grpc.WithBlock())
|
conn, err := grpc.DialContext(ctx, tcp, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Expected no error but got: %s", err)
|
t.Fatalf("Expected no error but got: %s", err)
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue