New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugin/template: Add client IP data #4034
Conversation
953d48f
to
75a7301
Compare
Codecov Report
@@ Coverage Diff @@
## master #4034 +/- ##
==========================================
+ Coverage 57.06% 57.08% +0.01%
==========================================
Files 222 222
Lines 11281 11281
==========================================
+ Hits 6438 6440 +2
+ Misses 4351 4350 -1
+ Partials 492 491 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks cool, although it would be nice to say it might be the IP of an intermediate (at which point it becomes pretty pointless for the original client).
In the log plugin we call this (for better or worse) remote. i think we should have this consistent between plugin, by either renaming it here; or adding |
Signed-off-by: Maxime Guyot <maxime@root314.com>
Good points. I've replaced
$ dig @127.0.0.1 TXT example.com +short
"127.0.0.1"
$ dig @::1 TXT example.com +short
"::1" The log module documents |
[ Quoting <notifications@github.com> in "Re: [coredns/coredns] plugin/templa..." ]
Good points. I've replaced .IP to .Remote in the latest commit and re-tested
this locally:
. {
log
template IN ANY {
answer "{{ .Name }} 60 {{ .Class }} {{ .Type }} {{ .Remote }}"
}
}
$ dig @127.0.0.1 TXT example.com +short
"127.0.0.1"
$ dig @::1 TXT example.com +short
"::1"
cool
The log module documents {{remote}} as client's IP address, for IPv6 addresses
these are enclosed in brackets: [::1], since the brackets enclosing doesn't
happen here I've skipped that from the description in this PR.
interesting, should we make it do that? I think we should, because
`{{ .Remote }} {{ .Port }}` doesn't allow you to see there is a port number
(if .Port even exists - dunno)
/Miek
…--
Miek Gieben
|
Are brackets enclosed IPv6 IPs supported in AAAA records? (I couldn't find an example of that in the codebase). |
[ Quoting <notifications@github.com> in "Re: [coredns/coredns] plugin/templa..." ]
{{ .Port }} does not exist, but would not be too hard to add.
Are brackets enclosed IPv6 IPs supported in AAAA records? (I couldn't find an
example of that in the codebase).
oh sorry, this is aaaa, then no. Thought we where somehow returning a text representation
of the record.
|
Signed-off-by: Maxime Guyot <maxime@root314.com>
1. Why is this pull request needed and what does it do?
This PR adds a
{{ .Remote }}
data in the template module.I have tested it with the following minimal
Corefile
(kind of emulating the whoami plugin):In terms of use case, the client IP can be useful to make decisions.
2. Which issues (if any) are related?
None
3. Which documentation changes (if any) need to be made?
plugin/template/README.md
included in the PR4. Does this introduce a backward incompatible change or deprecation?
Adding a field should be backwards compatible.