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
d9b7c947
Commit
d9b7c947
authored
Mar 25, 2016
by
Miek Gieben
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #44 from miekg/buffer-sizes
Add state.SizeAndDo()
parents
e8982dc9
16e50ec5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
30 deletions
+31
-30
middleware/proxy/lookup.go
middleware/proxy/lookup.go
+4
-2
middleware/proxy/reverseproxy.go
middleware/proxy/reverseproxy.go
+0
-1
middleware/state.go
middleware/state.go
+27
-27
No files found.
middleware/proxy/lookup.go
View file @
d9b7c947
...
...
@@ -55,8 +55,10 @@ func New(hosts []string) Proxy {
func
(
p
Proxy
)
Lookup
(
state
middleware
.
State
,
name
string
,
tpe
uint16
)
(
*
dns
.
Msg
,
error
)
{
req
:=
new
(
dns
.
Msg
)
req
.
SetQuestion
(
name
,
tpe
)
// TODO(miek):
// USE STATE FOR DNSSEC ETCD BUFSIZE BLA BLA
opt
:=
state
.
SizeAndDo
()
req
.
Extra
=
[]
dns
.
RR
{
opt
}
return
p
.
lookup
(
state
,
req
)
}
...
...
middleware/proxy/reverseproxy.go
View file @
d9b7c947
...
...
@@ -12,7 +12,6 @@ type ReverseProxy struct {
}
func
(
p
ReverseProxy
)
ServeDNS
(
w
dns
.
ResponseWriter
,
r
*
dns
.
Msg
,
extra
[]
dns
.
RR
)
error
{
// TODO(miek): use extra to EDNS0.
var
(
reply
*
dns
.
Msg
err
error
...
...
middleware/state.go
View file @
d9b7c947
...
...
@@ -19,17 +19,12 @@ type State struct {
}
// Now returns the current timestamp in the specified format.
func
(
s
State
)
Now
(
format
string
)
string
{
return
time
.
Now
()
.
Format
(
format
)
}
func
(
s
State
)
Now
(
format
string
)
string
{
return
time
.
Now
()
.
Format
(
format
)
}
// NowDate returns the current date/time that can be used
// in other time functions.
func
(
s
State
)
NowDate
()
time
.
Time
{
return
time
.
Now
()
}
// NowDate returns the current date/time that can be used in other time functions.
func
(
s
State
)
NowDate
()
time
.
Time
{
return
time
.
Now
()
}
// Header gets the
value of a header
.
// Header gets the
heaser of the request in State
.
func
(
s
State
)
Header
()
*
dns
.
RR_Header
{
// TODO(miek)
return
nil
...
...
@@ -107,36 +102,41 @@ func (s State) Size() int {
return
dns
.
MinMsgSize
}
// Type returns the type of the question as a string.
func
(
s
State
)
Type
()
string
{
return
dns
.
Type
(
s
.
Req
.
Question
[
0
]
.
Qtype
)
.
String
()
// 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.
func
(
s
State
)
SizeAndDo
()
*
dns
.
OPT
{
size
:=
s
.
Size
()
Do
:=
s
.
Do
()
o
:=
new
(
dns
.
OPT
)
o
.
Hdr
.
Name
=
"."
o
.
Hdr
.
Rrtype
=
dns
.
TypeOPT
o
.
SetUDPSize
(
uint16
(
size
))
if
Do
{
o
.
SetDo
()
}
return
o
}
// Type returns the type of the question as a string.
func
(
s
State
)
Type
()
string
{
return
dns
.
Type
(
s
.
Req
.
Question
[
0
]
.
Qtype
)
.
String
()
}
// QType returns the type of the question as a uint16.
func
(
s
State
)
QType
()
uint16
{
return
s
.
Req
.
Question
[
0
]
.
Qtype
}
func
(
s
State
)
QType
()
uint16
{
return
s
.
Req
.
Question
[
0
]
.
Qtype
}
// Name returns the name of the question in the request. Note
// this name will always have a closing dot and will be lower cased.
func
(
s
State
)
Name
()
string
{
return
strings
.
ToLower
(
dns
.
Name
(
s
.
Req
.
Question
[
0
]
.
Name
)
.
String
())
}
func
(
s
State
)
Name
()
string
{
return
strings
.
ToLower
(
dns
.
Name
(
s
.
Req
.
Question
[
0
]
.
Name
)
.
String
())
}
// QName returns the name of the question in the request.
func
(
s
State
)
QName
()
string
{
return
dns
.
Name
(
s
.
Req
.
Question
[
0
]
.
Name
)
.
String
()
}
func
(
s
State
)
QName
()
string
{
return
dns
.
Name
(
s
.
Req
.
Question
[
0
]
.
Name
)
.
String
()
}
// Class returns the class of the question in the request.
func
(
s
State
)
Class
()
string
{
return
dns
.
Class
(
s
.
Req
.
Question
[
0
]
.
Qclass
)
.
String
()
}
func
(
s
State
)
Class
()
string
{
return
dns
.
Class
(
s
.
Req
.
Question
[
0
]
.
Qclass
)
.
String
()
}
// QClass returns the class of the question in the request.
func
(
s
State
)
QClass
()
uint16
{
return
s
.
Req
.
Question
[
0
]
.
Qclass
}
func
(
s
State
)
QClass
()
uint16
{
return
s
.
Req
.
Question
[
0
]
.
Qclass
}
// ErrorMessage returns an error message suitable for sending
// back to the client.
...
...
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