Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
c2dbb714
Commit
c2dbb714
authored
Jul 10, 2022
by
Ondřej Benkovský
Committed by
GitHub
Jul 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add golangci-lint linter (#5499)
parent
abc5ac80
Changes
104
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
104 changed files
with
83 additions
and
184 deletions
+83
-184
.github/workflows/golangci-lint.yml
.github/workflows/golangci-lint.yml
+16
-0
.golangci.yml
.golangci.yml
+13
-0
core/dnsserver/address.go
core/dnsserver/address.go
+0
-1
core/dnsserver/address_test.go
core/dnsserver/address_test.go
+0
-4
core/dnsserver/onstartup_test.go
core/dnsserver/onstartup_test.go
+0
-1
core/dnsserver/register.go
core/dnsserver/register.go
+0
-4
core/dnsserver/register_test.go
core/dnsserver/register_test.go
+0
-1
core/dnsserver/server.go
core/dnsserver/server.go
+0
-2
core/dnsserver/server_grpc.go
core/dnsserver/server_grpc.go
+0
-1
core/dnsserver/server_https.go
core/dnsserver/server_https.go
+0
-2
plugin/acl/acl.go
plugin/acl/acl.go
+0
-1
plugin/auto/walk.go
plugin/auto/walk.go
+0
-1
plugin/autopath/autopath.go
plugin/autopath/autopath.go
+0
-1
plugin/azure/azure.go
plugin/azure/azure.go
+0
-2
plugin/azure/setup.go
plugin/azure/setup.go
+4
-0
plugin/backend_lookup.go
plugin/backend_lookup.go
+0
-6
plugin/bind/setup.go
plugin/bind/setup.go
+0
-1
plugin/cache/cache_test.go
plugin/cache/cache_test.go
+1
-1
plugin/chaos/setup.go
plugin/chaos/setup.go
+1
-1
plugin/clouddns/clouddns.go
plugin/clouddns/clouddns.go
+0
-1
plugin/clouddns/clouddns_test.go
plugin/clouddns/clouddns_test.go
+0
-1
plugin/clouddns/setup.go
plugin/clouddns/setup.go
+3
-0
plugin/debug/pcap_test.go
plugin/debug/pcap_test.go
+1
-1
plugin/dns64/dns64_test.go
plugin/dns64/dns64_test.go
+22
-23
plugin/dns64/setup.go
plugin/dns64/setup.go
+0
-3
plugin/dnssec/cache.go
plugin/dnssec/cache.go
+0
-1
plugin/dnssec/setup.go
plugin/dnssec/setup.go
+0
-2
plugin/dnstap/handler.go
plugin/dnstap/handler.go
+1
-1
plugin/dnstap/handler_test.go
plugin/dnstap/handler_test.go
+1
-2
plugin/dnstap/io.go
plugin/dnstap/io.go
+5
-5
plugin/dnstap/io_test.go
plugin/dnstap/io_test.go
+4
-4
plugin/etcd/msg/service.go
plugin/etcd/msg/service.go
+0
-1
plugin/etcd/msg/type.go
plugin/etcd/msg/type.go
+0
-2
plugin/etcd/setup.go
plugin/etcd/setup.go
+1
-1
plugin/file/closest.go
plugin/file/closest.go
+0
-1
plugin/file/include_test.go
plugin/file/include_test.go
+0
-1
plugin/file/lookup.go
plugin/file/lookup.go
+0
-6
plugin/file/secondary.go
plugin/file/secondary.go
+0
-2
plugin/file/setup.go
plugin/file/setup.go
+0
-1
plugin/file/tree/less_test.go
plugin/file/tree/less_test.go
+0
-1
plugin/forward/forward.go
plugin/forward/forward.go
+0
-1
plugin/geoip/geoip_test.go
plugin/geoip/geoip_test.go
+0
-3
plugin/grpc/proxy.go
plugin/grpc/proxy.go
+2
-1
plugin/grpc/setup.go
plugin/grpc/setup.go
+0
-1
plugin/header/header_test.go
plugin/header/header_test.go
+0
-2
plugin/header/setup.go
plugin/header/setup.go
+0
-1
plugin/k8s_external/msg_to_dns.go
plugin/k8s_external/msg_to_dns.go
+0
-3
plugin/k8s_external/transfer_test.go
plugin/k8s_external/transfer_test.go
+0
-2
plugin/kubernetes/controller.go
plugin/kubernetes/controller.go
+0
-2
plugin/kubernetes/handler_ignore_emptyservice_test.go
plugin/kubernetes/handler_ignore_emptyservice_test.go
+0
-1
plugin/kubernetes/handler_pod_disabled_test.go
plugin/kubernetes/handler_pod_disabled_test.go
+0
-1
plugin/kubernetes/handler_pod_insecure_test.go
plugin/kubernetes/handler_pod_insecure_test.go
+0
-1
plugin/kubernetes/handler_pod_verified_test.go
plugin/kubernetes/handler_pod_verified_test.go
+0
-1
plugin/kubernetes/handler_test.go
plugin/kubernetes/handler_test.go
+0
-1
plugin/kubernetes/kubernetes.go
plugin/kubernetes/kubernetes.go
+0
-3
plugin/kubernetes/kubernetes_apex_test.go
plugin/kubernetes/kubernetes_apex_test.go
+0
-1
plugin/kubernetes/ns_test.go
plugin/kubernetes/ns_test.go
+0
-6
plugin/kubernetes/object/service.go
plugin/kubernetes/object/service.go
+0
-1
plugin/kubernetes/parse.go
plugin/kubernetes/parse.go
+0
-1
plugin/kubernetes/reverse.go
plugin/kubernetes/reverse.go
+0
-1
plugin/kubernetes/reverse_test.go
plugin/kubernetes/reverse_test.go
+0
-2
plugin/kubernetes/setup.go
plugin/kubernetes/setup.go
+0
-1
plugin/kubernetes/xfr.go
plugin/kubernetes/xfr.go
+0
-1
plugin/loadbalance/loadbalance_test.go
plugin/loadbalance/loadbalance_test.go
+0
-1
plugin/loadbalance/setup.go
plugin/loadbalance/setup.go
+0
-1
plugin/log/log.go
plugin/log/log.go
+0
-1
plugin/log/setup_test.go
plugin/log/setup_test.go
+0
-1
plugin/metadata/metadata.go
plugin/metadata/metadata.go
+0
-1
plugin/metadata/provider.go
plugin/metadata/provider.go
+0
-1
plugin/normalize.go
plugin/normalize.go
+0
-1
plugin/normalize_test.go
plugin/normalize_test.go
+0
-1
plugin/pkg/cidr/cidr.go
plugin/pkg/cidr/cidr.go
+1
-1
plugin/pkg/dnstest/multirecorder_test.go
plugin/pkg/dnstest/multirecorder_test.go
+0
-1
plugin/pkg/dnsutil/reverse_test.go
plugin/pkg/dnsutil/reverse_test.go
+0
-1
plugin/pkg/parse/host.go
plugin/pkg/parse/host.go
+0
-1
plugin/pkg/rand/rand.go
plugin/pkg/rand/rand.go
+0
-1
plugin/pkg/replacer/replacer.go
plugin/pkg/replacer/replacer.go
+1
-0
plugin/pkg/replacer/replacer_test.go
plugin/pkg/replacer/replacer_test.go
+0
-1
plugin/pprof/setup.go
plugin/pprof/setup.go
+0
-1
plugin/rewrite/edns0.go
plugin/rewrite/edns0.go
+0
-1
plugin/rewrite/name.go
plugin/rewrite/name.go
+0
-1
plugin/rewrite/name_test.go
plugin/rewrite/name_test.go
+0
-6
plugin/rewrite/reverter_test.go
plugin/rewrite/reverter_test.go
+0
-2
plugin/rewrite/setup_test.go
plugin/rewrite/setup_test.go
+0
-2
plugin/rewrite/wire.go
plugin/rewrite/wire.go
+0
-2
plugin/route53/route53.go
plugin/route53/route53.go
+0
-2
plugin/route53/route53_test.go
plugin/route53/route53_test.go
+0
-1
plugin/route53/setup.go
plugin/route53/setup.go
+2
-0
plugin/secondary/setup.go
plugin/secondary/setup.go
+1
-3
plugin/template/setup.go
plugin/template/setup.go
+0
-1
plugin/template/setup_test.go
plugin/template/setup_test.go
+0
-1
plugin/test/helpers.go
plugin/test/helpers.go
+0
-1
plugin/test/scrape.go
plugin/test/scrape.go
+0
-2
plugin/transfer/failed_write_test.go
plugin/transfer/failed_write_test.go
+1
-2
plugin/transfer/setup_test.go
plugin/transfer/setup_test.go
+0
-2
plugin/transfer/transfer.go
plugin/transfer/transfer.go
+0
-1
plugin/tsig/setup_test.go
plugin/tsig/setup_test.go
+0
-3
request/request.go
request/request.go
+0
-2
test/file_loop_test.go
test/file_loop_test.go
+0
-1
test/grpc_test.go
test/grpc_test.go
+2
-1
test/metric_naming_test.go
test/metric_naming_test.go
+0
-1
test/presubmit_test.go
test/presubmit_test.go
+0
-1
test/readme_test.go
test/readme_test.go
+0
-1
test/secondary_test.go
test/secondary_test.go
+0
-1
No files found.
.github/workflows/golangci-lint.yml
0 → 100644
View file @
c2dbb714
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
.golangci.yml
0 → 100644
View file @
c2dbb714
run
:
timeout
:
5m
linters
:
disable-all
:
true
enable
:
-
deadcode
-
govet
-
ineffassign
-
staticcheck
-
structcheck
-
typecheck
-
varcheck
-
whitespace
core/dnsserver/address.go
View file @
c2dbb714
...
@@ -49,7 +49,6 @@ func newOverlapZone() *zoneOverlap {
...
@@ -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
...
...
core/dnsserver/address_test.go
View file @
c2dbb714
...
@@ -43,7 +43,6 @@ func TestSplitProtocolHostPort(t *testing.T) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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
)
}
}
}
}
}
}
}
}
}
}
}
}
core/dnsserver/onstartup_test.go
View file @
c2dbb714
...
@@ -5,7 +5,6 @@ import (
...
@@ -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
...
...
core/dnsserver/register.go
View file @
c2dbb714
...
@@ -138,7 +138,6 @@ func (h *dnsContext) InspectServerBlocks(sourceFile string, serverBlocks []caddy
...
@@ -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) {
...
@@ -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 {
...
@@ -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
...
...
core/dnsserver/register_test.go
View file @
c2dbb714
...
@@ -114,7 +114,6 @@ func TestGroupingServers(t *testing.T) {
...
@@ -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
)
}
}
}
}
}
}
...
...
core/dnsserver/server.go
View file @
c2dbb714
...
@@ -51,7 +51,6 @@ type Server struct {
...
@@ -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) {
...
@@ -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
{})
...
...
core/dnsserver/server_grpc.go
View file @
c2dbb714
...
@@ -82,7 +82,6 @@ func (s *ServergRPC) ServePacket(p net.PacketConn) error { return nil }
...
@@ -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
...
...
core/dnsserver/server_https.go
View file @
c2dbb714
...
@@ -104,7 +104,6 @@ func (s *ServerHTTPS) ServePacket(p net.PacketConn) error { return nil }
...
@@ -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 {
...
@@ -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
)
...
...
plugin/acl/acl.go
View file @
c2dbb714
...
@@ -88,7 +88,6 @@ RulesCheckLoop:
...
@@ -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
()
...
...
plugin/auto/walk.go
View file @
c2dbb714
...
@@ -12,7 +12,6 @@ import (
...
@@ -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
)
...
...
plugin/autopath/autopath.go
View file @
c2dbb714
...
@@ -135,7 +135,6 @@ func (a *AutoPath) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
...
@@ -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
)
...
...
plugin/azure/azure.go
View file @
c2dbb714
...
@@ -134,7 +134,6 @@ func (h *Azure) updateZones(ctx context.Context) error {
...
@@ -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
...
@@ -297,7 +296,6 @@ func updateZoneFromPrivateResourceSet(recordSet privatedns.RecordSetListResultPa
Target
:
dns
.
Fqdn
(
*
CNAME
)}
Target
:
dns
.
Fqdn
(
*
CNAME
)}
newZ
.
Insert
(
cname
)
newZ
.
Insert
(
cname
)
}
}
}
}
}
}
...
...
plugin/azure/setup.go
View file @
c2dbb714
...
@@ -29,20 +29,24 @@ func setup(c *caddy.Controller) error {
...
@@ -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
)
}
}
...
...
plugin/backend_lookup.go
View file @
c2dbb714
...
@@ -23,7 +23,6 @@ func A(ctx context.Context, b ServiceBackend, zone string, state request.Request
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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
...
@@ -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,
...
@@ -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
{
...
...
plugin/bind/setup.go
View file @
c2dbb714
...
@@ -12,7 +12,6 @@ import (
...
@@ -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
{}
...
...
plugin/cache/cache_test.go
View file @
c2dbb714
...
@@ -609,7 +609,7 @@ func TestCacheWildcardMetadata(t *testing.T) {
...
@@ -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"
)
...
...
plugin/chaos/setup.go
View file @
c2dbb714
...
@@ -30,7 +30,7 @@ func parse(c *caddy.Controller) (string, []string, error) {
...
@@ -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
...
...
plugin/clouddns/clouddns.go
View file @
c2dbb714
...
@@ -204,7 +204,6 @@ func (h *CloudDNS) updateZones(ctx context.Context) error {
...
@@ -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
...
...
plugin/clouddns/clouddns_test.go
View file @
c2dbb714
...
@@ -152,7 +152,6 @@ func TestCloudDNS(t *testing.T) {
...
@@ -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
)
...
...
plugin/clouddns/setup.go
View file @
c2dbb714
...
@@ -81,16 +81,19 @@ func setup(c *caddy.Controller) error {
...
@@ -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
))
}
}
...
...
plugin/debug/pcap_test.go
View file @
c2dbb714
...
@@ -32,7 +32,7 @@ func TestNoDebug(t *testing.T) {
...
@@ -32,7 +32,7 @@ func TestNoDebug(t *testing.T) {
}
}
}
}
func
Example
Log
Hexdump
()
{
func
ExampleHexdump
()
{
buf
,
_
:=
msg
()
.
Pack
()
buf
,
_
:=
msg
()
.
Pack
()
h
:=
hexdump
(
buf
)
h
:=
hexdump
(
buf
)
fmt
.
Println
(
string
(
h
))
fmt
.
Println
(
string
(
h
))
...
...
plugin/dns64/dns64_test.go
View file @
c2dbb714
...
@@ -74,7 +74,6 @@ func TestRequestShouldIntercept(t *testing.T) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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
...
...
plugin/dns64/setup.go
View file @
c2dbb714
...
@@ -6,14 +6,11 @@ import (
...
@@ -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
{
...
...
plugin/dnssec/cache.go
View file @
c2dbb714
...
@@ -43,7 +43,6 @@ func periodicClean(c *cache.Cache, stop <-chan struct{}) {
...
@@ -43,7 +43,6 @@ func periodicClean(c *cache.Cache, stop <-chan struct{}) {
case
<-
stop
:
case
<-
stop
:
return
return
}
}
}
}
}
}
plugin/dnssec/setup.go
View file @
c2dbb714
...
@@ -58,7 +58,6 @@ func dnssecParse(c *caddy.Controller) ([]string, []*DNSKEY, int, bool, error) {
...
@@ -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) {
...
@@ -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.
...
...
plugin/dnstap/handler.go
View file @
c2dbb714
...
@@ -23,7 +23,7 @@ type Dnstap struct {
...
@@ -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
)
{
...
...
plugin/dnstap/handler_test.go
View file @
c2dbb714
...
@@ -18,7 +18,6 @@ func testCase(t *testing.T, tapq, tapr *tap.Message, q, r *dns.Msg) {
...
@@ -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 {
...
@@ -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"
)
}
}
...
...
plugin/dnstap/io.go
View file @
c2dbb714
...
@@ -18,7 +18,7 @@ const (
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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() {
...
@@ -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
:
...
...
plugin/dnstap/io_test.go
View file @
c2dbb714
...
@@ -65,7 +65,7 @@ func TestTransport(t *testing.T) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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
()
}
}
plugin/etcd/msg/service.go
View file @
c2dbb714
...
@@ -154,7 +154,6 @@ func split255(s string) []string {
...
@@ -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
}
}
...
...
plugin/etcd/msg/type.go
View file @
c2dbb714
...
@@ -15,11 +15,9 @@ import (
...
@@ -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
...
...
plugin/etcd/setup.go
View file @
c2dbb714
...
@@ -40,7 +40,7 @@ func etcdParse(c *caddy.Controller) (*Etcd, error) {
...
@@ -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
()
{
...
...
plugin/file/closest.go
View file @
c2dbb714
...
@@ -8,7 +8,6 @@ import (
...
@@ -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
)
...
...
plugin/file/include_test.go
View file @
c2dbb714
...
@@ -10,7 +10,6 @@ import (
...
@@ -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
\t
IN
\t
A
\t
127.0.0.1
\n
"
)
name
,
rm
,
err
:=
test
.
TempFile
(
"."
,
"foo
\t
IN
\t
A
\t
127.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
)
...
...
plugin/file/lookup.go
View file @
c2dbb714
...
@@ -151,7 +151,6 @@ func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string)
...
@@ -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)
...
@@ -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)
...
@@ -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)
...
@@ -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)
...
@@ -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 {
...
@@ -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
()
...
...
plugin/file/secondary.go
View file @
c2dbb714
...
@@ -183,7 +183,6 @@ Restart:
...
@@ -183,7 +183,6 @@ Restart:
retryTicker
.
Stop
()
retryTicker
.
Stop
()
expireTicker
.
Stop
()
expireTicker
.
Stop
()
goto
Restart
goto
Restart
}
}
}
}
}
}
...
@@ -192,7 +191,6 @@ 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
...
...
plugin/file/setup.go
View file @
c2dbb714
...
@@ -139,7 +139,6 @@ func fileParse(c *caddy.Controller) (Zones, error) {
...
@@ -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
}
}
plugin/file/tree/less_test.go
View file @
c2dbb714
...
@@ -75,7 +75,6 @@ Tests:
...
@@ -75,7 +75,6 @@ Tests:
}
}
continue
Tests
continue
Tests
}
}
}
}
}
}
}
}
plugin/forward/forward.go
View file @
c2dbb714
...
@@ -74,7 +74,6 @@ func (f *Forward) Name() string { return "forward" }
...
@@ -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
)
...
...
plugin/geoip/geoip_test.go
View file @
c2dbb714
...
@@ -14,7 +14,6 @@ import (
...
@@ -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) {
...
@@ -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
...
@@ -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
)
}
}
}
}
plugin/grpc/proxy.go
View file @
c2dbb714
...
@@ -12,6 +12,7 @@ import (
...
@@ -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) {
...
@@ -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
.
With
Insecure
(
))
p
.
dialOpts
=
append
(
p
.
dialOpts
,
grpc
.
With
TransportCredentials
(
insecure
.
NewCredentials
()
))
}
}
conn
,
err
:=
grpc
.
Dial
(
p
.
addr
,
p
.
dialOpts
...
)
conn
,
err
:=
grpc
.
Dial
(
p
.
addr
,
p
.
dialOpts
...
)
...
...
plugin/grpc/setup.go
View file @
c2dbb714
...
@@ -96,7 +96,6 @@ func parseStanza(c *caddy.Controller) (*GRPC, error) {
...
@@ -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
()
...
...
plugin/header/header_test.go
View file @
c2dbb714
...
@@ -78,7 +78,5 @@ func TestHeader(t *testing.T) {
...
@@ -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
}
}
}
}
}
}
plugin/header/setup.go
View file @
c2dbb714
...
@@ -46,5 +46,4 @@ func parse(c *caddy.Controller) ([]Rule, error) {
...
@@ -46,5 +46,4 @@ func parse(c *caddy.Controller) ([]Rule, error) {
}
}
}
}
return
nil
,
c
.
ArgErr
()
return
nil
,
c
.
ArgErr
()
}
}
plugin/k8s_external/msg_to_dns.go
View file @
c2dbb714
...
@@ -15,7 +15,6 @@ func (e *External) a(ctx context.Context, services []msg.Service, state request.
...
@@ -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
...
@@ -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
...
@@ -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
)
...
...
plugin/k8s_external/transfer_test.go
View file @
c2dbb714
...
@@ -83,7 +83,6 @@ func TestTransferAXFR(t *testing.T) {
...
@@ -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) {
...
@@ -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
...
...
plugin/kubernetes/controller.go
View file @
c2dbb714
...
@@ -755,5 +755,3 @@ func (dns *dnsControl) updateExtModifed() {
...
@@ -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
plugin/kubernetes/handler_ignore_emptyservice_test.go
View file @
c2dbb714
...
@@ -30,7 +30,6 @@ var dnsEmptyServiceTestCases = []test.Case{
...
@@ -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
...
...
plugin/kubernetes/handler_pod_disabled_test.go
View file @
c2dbb714
...
@@ -28,7 +28,6 @@ var podModeDisabledCases = []test.Case{
...
@@ -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
)
...
...
plugin/kubernetes/handler_pod_insecure_test.go
View file @
c2dbb714
...
@@ -63,7 +63,6 @@ var podModeInsecureCases = []test.Case{
...
@@ -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
)
...
...
plugin/kubernetes/handler_pod_verified_test.go
View file @
c2dbb714
...
@@ -49,7 +49,6 @@ var podModeVerifiedCases = []test.Case{
...
@@ -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
)
...
...
plugin/kubernetes/handler_test.go
View file @
c2dbb714
...
@@ -494,7 +494,6 @@ var notSyncedTestCases = []test.Case{
...
@@ -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
,
...
...
plugin/kubernetes/kubernetes.go
View file @
c2dbb714
...
@@ -96,7 +96,6 @@ var (
...
@@ -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) {
...
@@ -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.
...
@@ -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
))
{
...
...
plugin/kubernetes/kubernetes_apex_test.go
View file @
c2dbb714
...
@@ -60,7 +60,6 @@ var kubeApexCases = []test.Case{
...
@@ -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
)
...
...
plugin/kubernetes/ns_test.go
View file @
c2dbb714
...
@@ -99,7 +99,6 @@ func (APIConnTest) GetNamespaceByName(name string) (*object.Namespace, error) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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
)
}
}
}
}
plugin/kubernetes/object/service.go
View file @
c2dbb714
...
@@ -68,7 +68,6 @@ func ToService(obj meta.Object) (meta.Object, error) {
...
@@ -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
{}
...
...
plugin/kubernetes/parse.go
View file @
c2dbb714
...
@@ -66,7 +66,6 @@ func parseRequest(name, zone string) (r recordRequest, err error) {
...
@@ -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
...
...
plugin/kubernetes/reverse.go
View file @
c2dbb714
...
@@ -12,7 +12,6 @@ import (
...
@@ -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
)
...
...
plugin/kubernetes/reverse_test.go
View file @
c2dbb714
...
@@ -38,7 +38,6 @@ func (APIConnReverseTest) SvcIndex(svc string) []*object.Service {
...
@@ -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
...
@@ -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
{}
...
...
plugin/kubernetes/setup.go
View file @
c2dbb714
...
@@ -87,7 +87,6 @@ func kubernetesParse(c *caddy.Controller) (*Kubernetes, error) {
...
@@ -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
()
...
...
plugin/kubernetes/xfr.go
View file @
c2dbb714
...
@@ -63,7 +63,6 @@ func (k *Kubernetes) Transfer(zone string, serial uint32) (<-chan []dns.RR, erro
...
@@ -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
{
...
...
plugin/loadbalance/loadbalance_test.go
View file @
c2dbb714
...
@@ -91,7 +91,6 @@ func TestLoadBalance(t *testing.T) {
...
@@ -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
)
...
...
plugin/loadbalance/setup.go
View file @
c2dbb714
...
@@ -35,7 +35,6 @@ func parse(c *caddy.Controller) error {
...
@@ -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
}
}
...
...
plugin/log/log.go
View file @
c2dbb714
...
@@ -50,7 +50,6 @@ func (l Logger) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
...
@@ -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
)
}
}
...
...
plugin/log/setup_test.go
View file @
c2dbb714
...
@@ -165,7 +165,6 @@ func TestLogParse(t *testing.T) {
...
@@ -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
)
...
...
plugin/metadata/metadata.go
View file @
c2dbb714
...
@@ -27,7 +27,6 @@ func ContextWithMetadata(ctx context.Context) context.Context {
...
@@ -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
}
...
...
plugin/metadata/provider.go
View file @
c2dbb714
...
@@ -64,7 +64,6 @@ func IsLabel(label string) bool {
...
@@ -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
...
...
plugin/normalize.go
View file @
c2dbb714
...
@@ -125,7 +125,6 @@ func (h Host) NormalizeExact() []string {
...
@@ -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
}
}
...
...
plugin/normalize_test.go
View file @
c2dbb714
...
@@ -52,7 +52,6 @@ func TestNameMatches(t *testing.T) {
...
@@ -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
)
}
}
}
}
}
}
...
...
plugin/pkg/cidr/cidr.go
View file @
c2dbb714
...
@@ -38,7 +38,7 @@ func Split(n *net.IPNet) []string {
...
@@ -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
)
...
...
plugin/pkg/dnstest/multirecorder_test.go
View file @
c2dbb714
...
@@ -19,7 +19,6 @@ func TestMultiWriteMsg(t *testing.T) {
...
@@ -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
)
...
...
plugin/pkg/dnsutil/reverse_test.go
View file @
c2dbb714
...
@@ -66,6 +66,5 @@ func TestIsReverse(t *testing.T) {
...
@@ -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
)
}
}
}
}
}
}
plugin/pkg/parse/host.go
View file @
c2dbb714
...
@@ -32,7 +32,6 @@ func stripZone(host string) string {
...
@@ -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
)
...
...
plugin/pkg/rand/rand.go
View file @
c2dbb714
...
@@ -32,5 +32,4 @@ func (r *Rand) Perm(n int) []int {
...
@@ -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
}
}
plugin/pkg/replacer/replacer.go
View file @
c2dbb714
...
@@ -271,6 +271,7 @@ func (r replacer) Replace(ctx context.Context, state request.Request, rr *dnstes
...
@@ -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
}
}
plugin/pkg/replacer/replacer_test.go
View file @
c2dbb714
...
@@ -276,7 +276,6 @@ func BenchmarkReplacer(b *testing.B) {
...
@@ -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
)
...
...
plugin/pprof/setup.go
View file @
c2dbb714
...
@@ -57,7 +57,6 @@ func setup(c *caddy.Controller) error {
...
@@ -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
)
...
...
plugin/rewrite/edns0.go
View file @
c2dbb714
...
@@ -180,7 +180,6 @@ func newEdns0VariableRule(mode, action, code, variable string) (*edns0VariableRu
...
@@ -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
...
...
plugin/rewrite/name.go
View file @
c2dbb714
...
@@ -367,7 +367,6 @@ func parseAnswerRules(name string, args []string) (auto bool, rules ResponseRule
...
@@ -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
)
}
}
...
...
plugin/rewrite/name_test.go
View file @
c2dbb714
...
@@ -33,7 +33,6 @@ func TestRewriteIllegalName(t *testing.T) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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
()
...
...
plugin/rewrite/reverter_test.go
View file @
c2dbb714
...
@@ -31,7 +31,6 @@ var tests = []struct {
...
@@ -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 {
...
@@ -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
{
...
...
plugin/rewrite/setup_test.go
View file @
c2dbb714
...
@@ -8,7 +8,6 @@ import (
...
@@ -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) {
...
@@ -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
)
}
}
}
}
}
}
plugin/rewrite/wire.go
View file @
c2dbb714
...
@@ -9,7 +9,6 @@ import (
...
@@ -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 {
...
@@ -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
...
...
plugin/route53/route53.go
View file @
c2dbb714
...
@@ -212,7 +212,6 @@ func maybeUnescape(s string) (string, error) {
...
@@ -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 {
...
@@ -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
...
...
plugin/route53/route53_test.go
View file @
c2dbb714
...
@@ -109,7 +109,6 @@ func TestRoute53(t *testing.T) {
...
@@ -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
)
...
...
plugin/route53/setup.go
View file @
c2dbb714
...
@@ -126,10 +126,12 @@ func setup(c *caddy.Controller) error {
...
@@ -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
{
...
...
plugin/secondary/setup.go
View file @
c2dbb714
...
@@ -64,7 +64,6 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
...
@@ -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) {
...
@@ -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"
:
...
...
plugin/template/setup.go
View file @
c2dbb714
...
@@ -32,7 +32,6 @@ func templateParse(c *caddy.Controller) (handler Handler, err error) {
...
@@ -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
()
}
}
...
...
plugin/template/setup_test.go
View file @
c2dbb714
...
@@ -24,7 +24,6 @@ func TestSetup(t *testing.T) {
...
@@ -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
{
...
...
plugin/test/helpers.go
View file @
c2dbb714
...
@@ -285,7 +285,6 @@ func SortAndCheck(resp *dns.Msg, tc Case) error {
...
@@ -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
)
}
}
...
...
plugin/test/scrape.go
View file @
c2dbb714
...
@@ -80,7 +80,6 @@ func Scrape(url string) []*MetricFamily {
...
@@ -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
...
@@ -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
}
}
}
}
}
}
}
}
}
}
...
...
plugin/transfer/failed_write_test.go
View file @
c2dbb714
...
@@ -12,10 +12,9 @@ import (
...
@@ -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
()
...
...
plugin/transfer/setup_test.go
View file @
c2dbb714
...
@@ -98,7 +98,6 @@ func TestParse(t *testing.T) {
...
@@ -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) {
...
@@ -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
)
}
}
}
}
}
}
...
...
plugin/transfer/transfer.go
View file @
c2dbb714
...
@@ -167,7 +167,6 @@ func (t *Transfer) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
...
@@ -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
...
...
plugin/tsig/setup_test.go
View file @
c2dbb714
...
@@ -12,7 +12,6 @@ import (
...
@@ -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." {
...
@@ -150,7 +149,6 @@ key "name2.key." {
break
break
}
}
}
}
}
}
}
}
...
@@ -243,6 +241,5 @@ func TestParseKeyFileErrors(t *testing.T) {
...
@@ -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
())
}
}
}
}
}
}
request/request.go
View file @
c2dbb714
...
@@ -313,7 +313,6 @@ func (r *Request) Class() string {
...
@@ -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 {
...
@@ -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.
...
...
test/file_loop_test.go
View file @
c2dbb714
...
@@ -44,6 +44,5 @@ func TestFileLoop(t *testing.T) {
...
@@ -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
)
}
}
}
}
test/grpc_test.go
View file @
c2dbb714
...
@@ -9,6 +9,7 @@ import (
...
@@ -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) {
...
@@ -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
.
With
Insecure
(
),
grpc
.
WithBlock
())
conn
,
err
:=
grpc
.
DialContext
(
ctx
,
tcp
,
grpc
.
With
TransportCredentials
(
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
)
}
}
...
...
test/metric_naming_test.go
View file @
c2dbb714
This diff is collapsed.
Click to expand it.
test/presubmit_test.go
View file @
c2dbb714
This diff is collapsed.
Click to expand it.
test/readme_test.go
View file @
c2dbb714
This diff is collapsed.
Click to expand it.
test/secondary_test.go
View file @
c2dbb714
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment