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
8cf1c897
Commit
8cf1c897
authored
Mar 26, 2016
by
Miek Gieben
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #47 from miekg/edns0-client-bufsize
Add Scrub function
parents
a832ab69
90f73c50
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
5 deletions
+40
-5
middleware/etcd/handler.go
middleware/etcd/handler.go
+1
-1
middleware/proxy/reverseproxy.go
middleware/proxy/reverseproxy.go
+2
-1
middleware/state.go
middleware/state.go
+37
-3
No files found.
middleware/etcd/handler.go
View file @
8cf1c897
...
...
@@ -72,7 +72,7 @@ func (e Etcd) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
}
m
=
dedup
(
m
)
m
,
_
=
state
.
Scrub
(
m
)
state
.
W
.
WriteMsg
(
m
)
return
0
,
nil
}
...
...
middleware/proxy/reverseproxy.go
View file @
8cf1c897
...
...
@@ -3,6 +3,7 @@ package proxy
import
(
"github.com/miekg/coredns/middleware"
"github.com/miekg/dns"
)
...
...
@@ -18,7 +19,7 @@ func (p ReverseProxy) ServeDNS(w dns.ResponseWriter, r *dns.Msg, extra []dns.RR)
)
state
:=
middleware
.
State
{
W
:
w
,
Req
:
r
}
//
tls+tcp ?
//
We forward the original request, no need to fiddle with EDNS0 opt sizes.
if
state
.
Proto
()
==
"tcp"
{
reply
,
err
=
middleware
.
Exchange
(
p
.
Client
.
TCP
,
r
,
p
.
Host
)
}
else
{
...
...
middleware/state.go
View file @
8cf1c897
...
...
@@ -102,9 +102,9 @@ func (s State) Size() int {
return
dns
.
MinMsgSize
}
// SizeAndDo returns a ready made OPT record that the reflects the intent
//
from the state. This can be added to upstream requests that will then
//
hopefully return a message that is understandable by the original
client.
// SizeAndDo returns a ready made OPT record that the reflects the intent
from
//
state. This can be added to upstream requests that will then hopefully
//
return a message that is fits the buffer in the
client.
func
(
s
State
)
SizeAndDo
()
*
dns
.
OPT
{
size
:=
s
.
Size
()
Do
:=
s
.
Do
()
...
...
@@ -119,6 +119,40 @@ func (s State) SizeAndDo() *dns.OPT {
return
o
}
// Result is the result of Fit.
type
Result
int
const
(
// ScrubIgnored is returned when Scrub did nothing to the message.
ScrubIgnored
Result
=
iota
// ScrubDone is returned when the reply has been scrubbed.
ScrubDone
)
// Scrub scrubs the reply message so that it will fit the client's buffer. If even after dropping
// the additional section, it still does not fit the TC bit will be set on the message. Note,
// the TC bit will be set regardless of protocol, even TCP message will get the bit, the client
// should then retry with pigeons.
// TODO(referral).
func
(
s
State
)
Scrub
(
reply
*
dns
.
Msg
)
(
*
dns
.
Msg
,
Result
)
{
size
:=
s
.
Size
()
l
:=
reply
.
Len
()
if
size
>=
l
{
return
reply
,
ScrubIgnored
}
// If not delegation, drop additional section.
// TODO(miek): check for delegation
reply
.
Extra
=
nil
l
=
reply
.
Len
()
if
size
>=
l
{
return
reply
,
ScrubDone
}
// Still?!! does not fit.
reply
.
Truncated
=
true
return
reply
,
ScrubDone
}
// Type returns the type of the question as a string.
func
(
s
State
)
Type
()
string
{
return
dns
.
Type
(
s
.
Req
.
Question
[
0
]
.
Qtype
)
.
String
()
}
...
...
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