plugin/template: Add client IP data (#4034)

Signed-off-by: Maxime Guyot <maxime@root314.com>
This commit is contained in:
Maxime Guyot
2020-08-10 10:38:18 +02:00
committed by GitHub
parent 7d5f5b87a4
commit b3d08f9b21
3 changed files with 30 additions and 1 deletions

View File

@@ -48,6 +48,7 @@ type templateData struct {
Type string
Message *dns.Msg
Question *dns.Question
Remote string
md map[string]metadata.Func
}
@@ -145,7 +146,7 @@ func executeRRTemplate(server, section string, template *gotmpl.Template, data *
func (t template) match(ctx context.Context, state request.Request) (*templateData, bool, bool) {
q := state.Req.Question[0]
data := &templateData{md: metadata.ValueFuncs(ctx)}
data := &templateData{md: metadata.ValueFuncs(ctx), Remote: state.IP()}
zone := plugin.Zones(t.zones).Matches(state.Name())
if zone == "" {