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
e3435566
Commit
e3435566
authored
Jan 28, 2019
by
Thomas Mangin
Committed by
Miek Gieben
Jan 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin/hosts: fix for ipv4-in-ipv6 (#2506)
* fix for ipv4-in-ipv6 * update comment as requested
parent
d571fbe0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
plugin/hosts/hosts_test.go
plugin/hosts/hosts_test.go
+15
-1
plugin/hosts/hostsfile.go
plugin/hosts/hostsfile.go
+3
-1
No files found.
plugin/hosts/hosts_test.go
View file @
e3435566
...
...
@@ -44,6 +44,12 @@ var hostsTestCases = []test.Case{
test
.
A
(
"example.org. 3600 IN A 10.0.0.1"
),
},
},
{
Qname
:
"example.com."
,
Qtype
:
dns
.
TypeA
,
Answer
:
[]
dns
.
RR
{
test
.
A
(
"example.com. 3600 IN A 10.0.0.2"
),
},
},
{
Qname
:
"localhost."
,
Qtype
:
dns
.
TypeAAAA
,
Answer
:
[]
dns
.
RR
{
...
...
@@ -56,6 +62,12 @@ var hostsTestCases = []test.Case{
test
.
PTR
(
"1.0.0.10.in-addr.arpa. 3600 PTR example.org."
),
},
},
{
Qname
:
"2.0.0.10.in-addr.arpa."
,
Qtype
:
dns
.
TypePTR
,
Answer
:
[]
dns
.
RR
{
test
.
PTR
(
"2.0.0.10.in-addr.arpa. 3600 PTR example.com."
),
},
},
{
Qname
:
"1.0.0.127.in-addr.arpa."
,
Qtype
:
dns
.
TypePTR
,
Answer
:
[]
dns
.
RR
{
...
...
@@ -76,4 +88,6 @@ var hostsTestCases = []test.Case{
const
hostsExample
=
`
127.0.0.1 localhost localhost.domain
::1 localhost localhost.domain
10.0.0.1 example.org`
10.0.0.1 example.org
::FFFF:10.0.0.2 example.com
`
plugin/hosts/hostsfile.go
View file @
e3435566
...
...
@@ -185,8 +185,10 @@ func (h *Hostsfile) parse(r io.Reader, override *hostsMap) *hostsMap {
}
// ipVersion returns what IP version was used textually
// For why the string is parsed end to start,
// see IPv4-Compatible IPv6 addresses - RFC 4291 section 2.5.5
func
ipVersion
(
s
string
)
int
{
for
i
:=
0
;
i
<
len
(
s
);
i
++
{
for
i
:=
len
(
s
)
-
1
;
i
>=
0
;
i
--
{
switch
s
[
i
]
{
case
'.'
:
return
4
...
...
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