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
ff9b4bcb
Commit
ff9b4bcb
authored
Feb 24, 2021
by
coredns-auto-go-fmt[bot]
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto go fmt
parent
d07a3ac6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
23 deletions
+25
-23
plugin/rewrite/name.go
plugin/rewrite/name.go
+8
-6
plugin/rewrite/reverter.go
plugin/rewrite/reverter.go
+6
-6
plugin/rewrite/reverter_test.go
plugin/rewrite/reverter_test.go
+1
-1
plugin/rewrite/ttl.go
plugin/rewrite/ttl.go
+10
-10
No files found.
plugin/rewrite/name.go
View file @
ff9b4bcb
...
@@ -140,7 +140,7 @@ func newNameRule(nextAction string, args ...string) (Rule, error) {
...
@@ -140,7 +140,7 @@ func newNameRule(nextAction string, args ...string) (Rule, error) {
}
}
//if len(args) > 3 && len(args) != 7 {
//if len(args) > 3 && len(args) != 7 {
if
len
(
args
)
>
3
&&
(
len
(
args
)
-
3
)
%
4
!=
0
{
if
len
(
args
)
>
3
&&
(
len
(
args
)
-
3
)
%
4
!=
0
{
return
nil
,
fmt
.
Errorf
(
"response rewrites must consist only of a name rule with 3 arguments and one or more answer rules with 3 arguments each"
)
return
nil
,
fmt
.
Errorf
(
"response rewrites must consist only of a name rule with 3 arguments and one or more answer rules with 3 arguments each"
)
}
}
...
@@ -199,7 +199,7 @@ func newNameRule(nextAction string, args ...string) (Rule, error) {
...
@@ -199,7 +199,7 @@ func newNameRule(nextAction string, args ...string) (Rule, error) {
}
}
}
}
//if len(args) == 7 {
//if len(args) == 7 {
if
(
len
(
args
)
-
3
)
%
4
==
0
{
if
(
len
(
args
)
-
3
)
%
4
==
0
{
if
matchType
==
RegexMatch
{
if
matchType
==
RegexMatch
{
rewriteQuestionFromPattern
,
err
:=
isValidRegexPattern
(
rewriteQuestionFrom
,
rewriteQuestionTo
)
rewriteQuestionFromPattern
,
err
:=
isValidRegexPattern
(
rewriteQuestionFrom
,
rewriteQuestionTo
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -209,9 +209,9 @@ func newNameRule(nextAction string, args ...string) (Rule, error) {
...
@@ -209,9 +209,9 @@ func newNameRule(nextAction string, args ...string) (Rule, error) {
responseRuleCount
:=
(
len
(
args
)
-
3
)
/
4
responseRuleCount
:=
(
len
(
args
)
-
3
)
/
4
responseRules
:=
make
([]
ResponseRule
,
responseRuleCount
)
responseRules
:=
make
([]
ResponseRule
,
responseRuleCount
)
for
i
:=
0
;
i
<
responseRuleCount
;
i
++
{
for
i
:=
0
;
i
<
responseRuleCount
;
i
++
{
startIdx
:=
3
+
(
i
*
4
)
startIdx
:=
3
+
(
i
*
4
)
responseRule
,
err
:=
newResponseRule
(
args
[
startIdx
:
startIdx
+
4
])
responseRule
,
err
:=
newResponseRule
(
args
[
startIdx
:
startIdx
+
4
])
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -231,7 +231,7 @@ func newNameRule(nextAction string, args ...string) (Rule, error) {
...
@@ -231,7 +231,7 @@ func newNameRule(nextAction string, args ...string) (Rule, error) {
}
}
// newResponseRule creates a new "answer name" or "answer value" response rule.
// newResponseRule creates a new "answer name" or "answer value" response rule.
func
newResponseRule
(
args
[]
string
)
(
responseRule
*
ResponseRule
,
err
error
){
func
newResponseRule
(
args
[]
string
)
(
responseRule
*
ResponseRule
,
err
error
)
{
if
args
[
0
]
!=
"answer"
{
if
args
[
0
]
!=
"answer"
{
return
nil
,
fmt
.
Errorf
(
"exceeded the number of arguments for a regex name rule"
)
return
nil
,
fmt
.
Errorf
(
"exceeded the number of arguments for a regex name rule"
)
}
}
...
@@ -266,7 +266,9 @@ func (rule *substringNameRule) Mode() string { return rule.NextAction }
...
@@ -266,7 +266,9 @@ func (rule *substringNameRule) Mode() string { return rule.NextAction }
func
(
rule
*
regexNameRule
)
Mode
()
string
{
return
rule
.
NextAction
}
func
(
rule
*
regexNameRule
)
Mode
()
string
{
return
rule
.
NextAction
}
// GetResponseRules returns rules to rewrite the response with. Currently not implemented.
// GetResponseRules returns rules to rewrite the response with. Currently not implemented.
func
(
rule
*
exactNameRule
)
GetResponseRules
()
[]
ResponseRule
{
return
[]
ResponseRule
{
rule
.
ResponseRule
}
}
func
(
rule
*
exactNameRule
)
GetResponseRules
()
[]
ResponseRule
{
return
[]
ResponseRule
{
rule
.
ResponseRule
}
}
// GetResponseRules returns rules to rewrite the response with. Currently not implemented.
// GetResponseRules returns rules to rewrite the response with. Currently not implemented.
func
(
rule
*
prefixNameRule
)
GetResponseRules
()
[]
ResponseRule
{
return
[]
ResponseRule
{}
}
func
(
rule
*
prefixNameRule
)
GetResponseRules
()
[]
ResponseRule
{
return
[]
ResponseRule
{}
}
...
...
plugin/rewrite/reverter.go
View file @
ff9b4bcb
...
@@ -60,12 +60,12 @@ func (r *ResponseReverter) WriteMsg(res1 *dns.Msg) error {
...
@@ -60,12 +60,12 @@ func (r *ResponseReverter) WriteMsg(res1 *dns.Msg) error {
func
rewriteResourceRecord
(
res
*
dns
.
Msg
,
rr
dns
.
RR
,
r
*
ResponseReverter
)
{
func
rewriteResourceRecord
(
res
*
dns
.
Msg
,
rr
dns
.
RR
,
r
*
ResponseReverter
)
{
var
(
var
(
isNameRewritten
bool
isNameRewritten
bool
isTTLRewritten
bool
isTTLRewritten
bool
isValueRewritten
bool
isValueRewritten
bool
name
=
rr
.
Header
()
.
Name
name
=
rr
.
Header
()
.
Name
ttl
=
rr
.
Header
()
.
Ttl
ttl
=
rr
.
Header
()
.
Ttl
value
string
value
string
)
)
for
_
,
rule
:=
range
r
.
ResponseRules
{
for
_
,
rule
:=
range
r
.
ResponseRules
{
...
...
plugin/rewrite/reverter_test.go
View file @
ff9b4bcb
...
@@ -77,7 +77,7 @@ var valueTests = []struct {
...
@@ -77,7 +77,7 @@ var valueTests = []struct {
to
string
to
string
toType
uint16
toType
uint16
noRevert
bool
noRevert
bool
expectValue
string
expectValue
string
expectAnswerType
uint16
expectAnswerType
uint16
expectAddlName
string
expectAddlName
string
}{
}{
...
...
plugin/rewrite/ttl.go
View file @
ff9b4bcb
...
@@ -13,32 +13,32 @@ import (
...
@@ -13,32 +13,32 @@ import (
)
)
type
exactTTLRule
struct
{
type
exactTTLRule
struct
{
NextAction
string
NextAction
string
From
string
From
string
ResponseRules
[]
ResponseRule
ResponseRules
[]
ResponseRule
}
}
type
prefixTTLRule
struct
{
type
prefixTTLRule
struct
{
NextAction
string
NextAction
string
Prefix
string
Prefix
string
ResponseRules
[]
ResponseRule
ResponseRules
[]
ResponseRule
}
}
type
suffixTTLRule
struct
{
type
suffixTTLRule
struct
{
NextAction
string
NextAction
string
Suffix
string
Suffix
string
ResponseRules
[]
ResponseRule
ResponseRules
[]
ResponseRule
}
}
type
substringTTLRule
struct
{
type
substringTTLRule
struct
{
NextAction
string
NextAction
string
Substring
string
Substring
string
ResponseRules
[]
ResponseRule
ResponseRules
[]
ResponseRule
}
}
type
regexTTLRule
struct
{
type
regexTTLRule
struct
{
NextAction
string
NextAction
string
Pattern
*
regexp
.
Regexp
Pattern
*
regexp
.
Regexp
ResponseRules
[]
ResponseRule
ResponseRules
[]
ResponseRule
}
}
...
...
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