Commit b3a92f16 authored by Francois Tur's avatar Francois Tur Committed by Paul Greenberg

- compliance with metadata contract. If metadata value is empty, ignore...

- compliance with metadata contract. If metadata value is empty, ignore rewrite - like if metadata does not exist. (#1953)
parent 77454624
......@@ -203,7 +203,10 @@ func (rule *edns0VariableRule) ruleData(ctx context.Context, state request.Reque
fetcher := metadata.ValueFunc(ctx, rule.variable[1:len(rule.variable)-1])
if fetcher != nil {
return []byte(fetcher()), nil
value := fetcher()
if len(value) > 0 {
return []byte(value), nil
}
}
return nil, fmt.Errorf("unable to extract data for variable %s", rule.variable)
......
......@@ -523,8 +523,8 @@ func TestRewriteEDNS0LocalVariable(t *testing.T) {
{
[]dns.EDNS0{},
[]string{"local", "set", "0xffee", "{test/empty}"},
[]dns.EDNS0{&dns.EDNS0_LOCAL{Code: 0xffee, Data: []byte("")}},
true,
nil,
false,
},
{
[]dns.EDNS0{},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment