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
e954332b
Commit
e954332b
authored
Mar 20, 2016
by
Miek Gieben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow rewriting of the the name of the query as well. And improve
the docs a little.
parent
41d5d40a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
middleware/name.go
middleware/name.go
+10
-1
middleware/rewrite/rewrite.go
middleware/rewrite/rewrite.go
+9
-5
middleware/rewrite/rewrite.md
middleware/rewrite/rewrite.md
+5
-1
No files found.
middleware/name.go
View file @
e954332b
package
middleware
import
"strings"
import
(
"strings"
"github.com/miekg/dns"
)
// Name represents a domain name.
type
Name
string
...
...
@@ -13,3 +17,8 @@ type Name string
func
(
n
Name
)
Matches
(
other
string
)
bool
{
return
strings
.
HasSuffix
(
string
(
n
),
other
)
}
// Normalize lowercases and makes n fully qualified.
func
(
n
Name
)
Normalize
()
string
{
return
strings
.
ToLower
(
dns
.
Fqdn
(
string
(
n
)))
}
middleware/rewrite/rewrite.go
View file @
e954332b
...
...
@@ -69,27 +69,31 @@ func NewSimpleRule(from, to string) SimpleRule {
// It's only a type if uppercase is used.
if
from
!=
strings
.
ToUpper
(
from
)
{
tpf
=
0
from
=
middleware
.
Name
(
from
)
.
Normalize
()
}
if
to
!=
strings
.
ToUpper
(
to
)
{
tpt
=
0
to
=
middleware
.
Name
(
to
)
.
Normalize
()
}
// lowercase and fully qualify the others here? TODO(miek)
return
SimpleRule
{
From
:
from
,
To
:
to
,
fromType
:
tpf
,
toType
:
tpt
}
}
// Rewrite rewrites the the current request.
func
(
s
SimpleRule
)
Rewrite
(
r
*
dns
.
Msg
)
Result
{
// type rewrite
if
s
.
fromType
>
0
&&
s
.
toType
>
0
{
if
r
.
Question
[
0
]
.
Qtype
==
s
.
fromType
{
r
.
Question
[
0
]
.
Qtype
=
s
.
toType
return
RewriteDone
}
return
RewriteIgnored
}
// if the question name matches the full name, or subset rewrite that
// s.Question[0].Name
// name rewite
if
s
.
From
==
r
.
Question
[
0
]
.
Name
{
r
.
Question
[
0
]
.
Name
=
s
.
To
return
RewriteDone
}
return
RewriteIgnored
}
...
...
middleware/rewrite/rewrite.md
View file @
e954332b
...
...
@@ -16,9 +16,13 @@ rewrite from to
If from
*and*
to look like a DNS type (
`A`
,
`MX`
, etc.) the type of the message will be rewriten,
i.e. to rewrite ANY queries to HINFO, use
`rewrite ANY HINFO`
.
If it does not look like a type a name is assumed and the qname in the message is rewritten.
If it does not look like a type a name is assumed and the qname in the message is rewritten, this
needs to be a full match of the name
`rewrite miek.nl example.org`
.
Advanced users may open a block and make a complex rewrite rule:
TODO(miek): this has not yet been implemented.
> Everything below this line has not been implemented, yet.
~~~
rewrite [basename] {
...
...
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