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
547a4ab2
You need to sign in or sign up before continuing.
Commit
547a4ab2
authored
Mar 29, 2016
by
Miek Gieben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More stuff
parent
48f7d55f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
24 deletions
+58
-24
middleware/file/dnssec_test.go
middleware/file/dnssec_test.go
+2
-0
middleware/file/file.go
middleware/file/file.go
+6
-6
middleware/file/lookup.go
middleware/file/lookup.go
+50
-18
No files found.
middleware/file/dnssec_test.go
View file @
547a4ab2
...
@@ -53,6 +53,8 @@ var dnssecTestCases = []coretest.Case{
...
@@ -53,6 +53,8 @@ var dnssecTestCases = []coretest.Case{
{
{
Qname
:
"a.miek.nl."
,
Qtype
:
dns
.
TypeSRV
,
Do
:
true
,
Qname
:
"a.miek.nl."
,
Qtype
:
dns
.
TypeSRV
,
Do
:
true
,
Ns
:
[]
dns
.
RR
{
Ns
:
[]
dns
.
RR
{
coretest
.
NSEC
(
"a.miek.nl. 14400 IN NSEC archive.miek.nl. A AAAA RRSIG NSEC"
),
coretest
.
RRSIG
(
"a.miek.nl. 14400 IN RRSIG NSEC 8 3 14400 20160426031301 20160327031301 12051 miek.nl. GqnF6cutipmSHEao="
),
coretest
.
RRSIG
(
"miek.nl. 1800 IN RRSIG SOA 8 2 1800 20160426031301 20160327031301 12051 miek.nl. FIrzy07acBbtyQczy1dc="
),
coretest
.
RRSIG
(
"miek.nl. 1800 IN RRSIG SOA 8 2 1800 20160426031301 20160327031301 12051 miek.nl. FIrzy07acBbtyQczy1dc="
),
coretest
.
SOA
(
"miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"
),
coretest
.
SOA
(
"miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"
),
},
},
...
...
middleware/file/file.go
View file @
547a4ab2
...
@@ -39,7 +39,7 @@ func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
...
@@ -39,7 +39,7 @@ func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
return
xfr
.
ServeDNS
(
ctx
,
w
,
r
)
return
xfr
.
ServeDNS
(
ctx
,
w
,
r
)
}
}
rr
s
,
extra
,
result
:=
z
.
Lookup
(
qname
,
state
.
QType
(),
state
.
Do
())
an
,
n
s
,
extra
,
result
:=
z
.
Lookup
(
qname
,
state
.
QType
(),
state
.
Do
())
m
:=
new
(
dns
.
Msg
)
m
:=
new
(
dns
.
Msg
)
m
.
SetReply
(
r
)
m
.
SetReply
(
r
)
...
@@ -48,17 +48,17 @@ func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
...
@@ -48,17 +48,17 @@ func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
switch
result
{
switch
result
{
case
Success
:
case
Success
:
// case?
// case?
m
.
Answer
=
rrs
m
.
Answer
=
an
m
.
Extra
=
extra
m
.
Extra
=
extra
// Ns section
// Ns section
case
NameError
:
case
NameError
:
m
.
Ns
=
ns
m
.
Rcode
=
dns
.
RcodeNameError
m
.
Rcode
=
dns
.
RcodeNameError
fallthrough
fallthrough
case
NoData
:
case
NoData
:
// case?
m
.
Ns
=
ns
m
.
Ns
=
rrs
case
ServerFailure
:
default
:
return
dns
.
RcodeServerFailure
,
nil
// TODO
}
}
m
,
_
=
state
.
Scrub
(
m
)
m
,
_
=
state
.
Scrub
(
m
)
w
.
WriteMsg
(
m
)
w
.
WriteMsg
(
m
)
...
...
middleware/file/lookup.go
View file @
547a4ab2
package
file
package
file
import
"github.com/miekg/dns"
import
(
"github.com/miekg/coredns/middleware/file/tree"
"github.com/miekg/dns"
)
// Result is the result of a Lookup
// Result is the result of a Lookup
type
Result
int
type
Result
int
...
@@ -8,18 +11,17 @@ type Result int
...
@@ -8,18 +11,17 @@ type Result int
const
(
const
(
Success
Result
=
iota
Success
Result
=
iota
NameError
NameError
NoData
// aint no offical NoData return code.
NoData
ServerFailure
)
)
// Lookup looks up qname and qtype in the zone, when do is true DNSSEC are included as well.
// Lookup looks up qname and qtype in the zone, when do is true DNSSEC are included as well.
// T
wo sets of records are returned, one for the answer
and one for the additional section.
// T
hree sets of records are returned, one for the answer, one for authority
and one for the additional section.
func
(
z
*
Zone
)
Lookup
(
qname
string
,
qtype
uint16
,
do
bool
)
([]
dns
.
RR
,
[]
dns
.
RR
,
Result
)
{
func
(
z
*
Zone
)
Lookup
(
qname
string
,
qtype
uint16
,
do
bool
)
([]
dns
.
RR
,
[]
dns
.
RR
,
[]
dns
.
RR
,
Result
)
{
var
rr
dns
.
RR
var
rr
dns
.
RR
mk
,
known
:=
dns
.
TypeToRR
[
qtype
]
mk
,
known
:=
dns
.
TypeToRR
[
qtype
]
if
!
known
{
if
!
known
{
an
,
ad
,
_
:=
z
.
lookupSOA
(
do
)
return
nil
,
nil
,
nil
,
ServerFailure
return
an
,
ad
,
NameError
// Uhm...? rr = new(RFC3597) ??
}
else
{
}
else
{
rr
=
mk
()
rr
=
mk
()
}
}
...
@@ -32,8 +34,7 @@ func (z *Zone) Lookup(qname string, qtype uint16, do bool) ([]dns.RR, []dns.RR,
...
@@ -32,8 +34,7 @@ func (z *Zone) Lookup(qname string, qtype uint16, do bool) ([]dns.RR, []dns.RR,
rr
.
Header
()
.
Name
=
qname
rr
.
Header
()
.
Name
=
qname
elem
:=
z
.
Tree
.
Get
(
rr
)
elem
:=
z
.
Tree
.
Get
(
rr
)
if
elem
==
nil
{
if
elem
==
nil
{
an
,
ad
,
_
:=
z
.
lookupSOA
(
do
)
return
z
.
nameError
(
elem
,
rr
,
do
)
return
an
,
ad
,
NameError
}
}
rrs
:=
elem
.
Types
(
dns
.
TypeCNAME
)
rrs
:=
elem
.
Types
(
dns
.
TypeCNAME
)
...
@@ -44,8 +45,7 @@ func (z *Zone) Lookup(qname string, qtype uint16, do bool) ([]dns.RR, []dns.RR,
...
@@ -44,8 +45,7 @@ func (z *Zone) Lookup(qname string, qtype uint16, do bool) ([]dns.RR, []dns.RR,
rrs
=
elem
.
Types
(
qtype
)
rrs
=
elem
.
Types
(
qtype
)
if
len
(
rrs
)
==
0
{
if
len
(
rrs
)
==
0
{
an
,
ad
,
_
:=
z
.
lookupSOA
(
do
)
return
z
.
noData
(
elem
,
do
)
return
an
,
ad
,
NoData
}
}
if
do
{
if
do
{
sigs
:=
elem
.
Types
(
dns
.
TypeRRSIG
)
sigs
:=
elem
.
Types
(
dns
.
TypeRRSIG
)
...
@@ -54,21 +54,53 @@ func (z *Zone) Lookup(qname string, qtype uint16, do bool) ([]dns.RR, []dns.RR,
...
@@ -54,21 +54,53 @@ func (z *Zone) Lookup(qname string, qtype uint16, do bool) ([]dns.RR, []dns.RR,
rrs
=
append
(
rrs
,
sigs
...
)
rrs
=
append
(
rrs
,
sigs
...
)
}
}
}
}
return
rrs
,
nil
,
Success
return
rrs
,
nil
,
nil
,
Success
}
func
(
z
*
Zone
)
noData
(
elem
*
tree
.
Elem
,
do
bool
)
([]
dns
.
RR
,
[]
dns
.
RR
,
[]
dns
.
RR
,
Result
)
{
soa
,
_
,
_
,
_
:=
z
.
lookupSOA
(
do
)
nsec
:=
z
.
lookupNSEC
(
elem
,
do
)
return
nil
,
append
(
soa
,
nsec
...
),
nil
,
Success
}
}
func
(
z
*
Zone
)
lookupSOA
(
do
bool
)
(
[]
dns
.
RR
,
[]
dns
.
RR
,
Result
)
{
func
(
z
*
Zone
)
nameError
(
elem
*
tree
.
Elem
,
rr
dns
.
RR
,
do
bool
)
([]
dns
.
RR
,
[]
dns
.
RR
,
[]
dns
.
RR
,
Result
)
{
if
do
{
if
do
{
ret
:=
append
([]
dns
.
RR
{
z
.
SOA
},
z
.
SIG
...
)
ret
:=
append
([]
dns
.
RR
{
z
.
SOA
},
z
.
SIG
...
)
return
ret
,
nil
,
Success
return
nil
,
ret
,
nil
,
Success
}
}
return
[]
dns
.
RR
{
z
.
SOA
},
nil
,
Success
// NSECs!
return
nil
,
[]
dns
.
RR
{
z
.
SOA
},
nil
,
Success
}
func
(
z
*
Zone
)
lookupSOA
(
do
bool
)
([]
dns
.
RR
,
[]
dns
.
RR
,
[]
dns
.
RR
,
Result
)
{
if
do
{
ret
:=
append
([]
dns
.
RR
{
z
.
SOA
},
z
.
SIG
...
)
return
ret
,
nil
,
nil
,
Success
}
return
[]
dns
.
RR
{
z
.
SOA
},
nil
,
nil
,
Success
}
// lookupNSEC looks up nsec and sigs.
func
(
z
*
Zone
)
lookupNSEC
(
elem
*
tree
.
Elem
,
do
bool
)
[]
dns
.
RR
{
if
!
do
{
return
nil
}
nsec
:=
elem
.
Types
(
dns
.
TypeNSEC
)
if
do
{
sigs
:=
elem
.
Types
(
dns
.
TypeRRSIG
)
sigs
=
signatureForSubType
(
sigs
,
dns
.
TypeNSEC
)
if
len
(
sigs
)
>
0
{
nsec
=
append
(
nsec
,
sigs
...
)
}
}
return
nsec
}
}
func
(
z
*
Zone
)
lookupCNAME
(
rrs
[]
dns
.
RR
,
rr
dns
.
RR
,
do
bool
)
([]
dns
.
RR
,
[]
dns
.
RR
,
Result
)
{
func
(
z
*
Zone
)
lookupCNAME
(
rrs
[]
dns
.
RR
,
rr
dns
.
RR
,
do
bool
)
([]
dns
.
RR
,
[]
dns
.
RR
,
[]
dns
.
RR
,
Result
)
{
elem
:=
z
.
Tree
.
Get
(
rr
)
elem
:=
z
.
Tree
.
Get
(
rr
)
if
elem
==
nil
{
if
elem
==
nil
{
return
rrs
,
nil
,
Success
return
rrs
,
nil
,
nil
,
Success
}
}
extra
:=
cnameForType
(
elem
.
All
(),
rr
.
Header
()
.
Rrtype
)
extra
:=
cnameForType
(
elem
.
All
(),
rr
.
Header
()
.
Rrtype
)
if
do
{
if
do
{
...
@@ -78,7 +110,7 @@ func (z *Zone) lookupCNAME(rrs []dns.RR, rr dns.RR, do bool) ([]dns.RR, []dns.RR
...
@@ -78,7 +110,7 @@ func (z *Zone) lookupCNAME(rrs []dns.RR, rr dns.RR, do bool) ([]dns.RR, []dns.RR
extra
=
append
(
extra
,
sigs
...
)
extra
=
append
(
extra
,
sigs
...
)
}
}
}
}
return
rrs
,
extra
,
Success
return
rrs
,
nil
,
extra
,
Success
}
}
func
cnameForType
(
targets
[]
dns
.
RR
,
origQtype
uint16
)
[]
dns
.
RR
{
func
cnameForType
(
targets
[]
dns
.
RR
,
origQtype
uint16
)
[]
dns
.
RR
{
...
...
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