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
51e1442b
Commit
51e1442b
authored
Apr 18, 2018
by
Chris O'Haver
Committed by
GitHub
Apr 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin/kubernetes: check for bare zone query (#1692)
* check for bare zone query * check for bare type query
parent
9a7e487a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
1 deletion
+49
-1
plugin/kubernetes/handler_test.go
plugin/kubernetes/handler_test.go
+14
-0
plugin/kubernetes/kubernetes.go
plugin/kubernetes/kubernetes.go
+3
-0
plugin/kubernetes/kubernetes_apex_test.go
plugin/kubernetes/kubernetes_apex_test.go
+21
-0
plugin/kubernetes/parse.go
plugin/kubernetes/parse.go
+4
-0
plugin/kubernetes/parse_test.go
plugin/kubernetes/parse_test.go
+7
-1
No files found.
plugin/kubernetes/handler_test.go
View file @
51e1442b
...
...
@@ -231,6 +231,20 @@ var dnsTestCases = []test.Case{
test
.
AAAA
(
"5678-abcd--1.hdls1.testns.svc.cluster.local. 5 IN AAAA 5678:abcd::1"
),
},
},
{
Qname
:
"svc.cluster.local."
,
Qtype
:
dns
.
TypeA
,
Rcode
:
dns
.
RcodeSuccess
,
Ns
:
[]
dns
.
RR
{
test
.
SOA
(
"cluster.local. 303 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"
),
},
},
{
Qname
:
"pod.cluster.local."
,
Qtype
:
dns
.
TypeA
,
Rcode
:
dns
.
RcodeSuccess
,
Ns
:
[]
dns
.
RR
{
test
.
SOA
(
"cluster.local. 303 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"
),
},
},
}
func
TestServeDNS
(
t
*
testing
.
T
)
{
...
...
plugin/kubernetes/kubernetes.go
View file @
51e1442b
...
...
@@ -273,6 +273,9 @@ func (k *Kubernetes) Records(state request.Request, exact bool) ([]msg.Service,
if
e
!=
nil
{
return
nil
,
e
}
if
r
.
podOrSvc
==
""
{
return
nil
,
nil
}
if
dnsutil
.
IsReverse
(
state
.
Name
())
>
0
{
return
nil
,
errNoItems
...
...
plugin/kubernetes/kubernetes_apex_test.go
View file @
51e1442b
...
...
@@ -35,6 +35,27 @@ var kubeApexCases = []test.Case{
test
.
A
(
"ns.dns.cluster.local. 303 IN A 127.0.0.1"
),
},
},
{
Qname
:
"cluster.local."
,
Qtype
:
dns
.
TypeA
,
Rcode
:
dns
.
RcodeSuccess
,
Ns
:
[]
dns
.
RR
{
test
.
SOA
(
"cluster.local. 303 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"
),
},
},
{
Qname
:
"cluster.local."
,
Qtype
:
dns
.
TypeAAAA
,
Rcode
:
dns
.
RcodeSuccess
,
Ns
:
[]
dns
.
RR
{
test
.
SOA
(
"cluster.local. 303 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"
),
},
},
{
Qname
:
"cluster.local."
,
Qtype
:
dns
.
TypeSRV
,
Rcode
:
dns
.
RcodeSuccess
,
Ns
:
[]
dns
.
RR
{
test
.
SOA
(
"cluster.local. 303 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"
),
},
},
}
func
TestServeDNSApex
(
t
*
testing
.
T
)
{
...
...
plugin/kubernetes/parse.go
View file @
51e1442b
...
...
@@ -35,6 +35,10 @@ func parseRequest(state request.Request) (r recordRequest, err error) {
// Federations are handled in the federation plugin. And aren't parsed here.
base
,
_
:=
dnsutil
.
TrimZone
(
state
.
Name
(),
state
.
Zone
)
// return NODATA for apex queries
if
base
==
""
||
base
==
Svc
||
base
==
Pod
{
return
r
,
nil
}
segs
:=
dns
.
SplitDomainName
(
base
)
r
.
port
=
"*"
...
...
plugin/kubernetes/parse_test.go
View file @
51e1442b
...
...
@@ -19,6 +19,12 @@ func TestParseRequest(t *testing.T) {
{
"*.any.*.any.svc.inter.webs.test."
,
"*.any..*.any.svc"
},
// A request of endpoint
{
"1-2-3-4.webs.mynamespace.svc.inter.webs.test."
,
"*.*.1-2-3-4.webs.mynamespace.svc"
},
// bare zone
{
"inter.webs.test."
,
"....."
},
// bare svc type
{
"svc.inter.webs.test."
,
"....."
},
// bare pod type
{
"pod.inter.webs.test."
,
"....."
},
}
for
i
,
tc
:=
range
tests
{
m
:=
new
(
dns
.
Msg
)
...
...
@@ -53,4 +59,4 @@ func TestParseInvalidRequest(t *testing.T) {
}
}
const
zone
=
"inter
n
.webs.tests."
const
zone
=
"inter.webs.tests."
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