Conversation
Codecov Report
@@ Coverage Diff @@
## master #91 +/- ##
==========================================
- Coverage 71.20% 70.54% -0.66%
==========================================
Files 30 30
Lines 2035 2054 +19
==========================================
Hits 1449 1449
- Misses 415 433 +18
- Partials 171 172 +1
Continue to review full report at Codecov.
|
To add a new edns option with code 4242: $ echo -n "This is a binary string" | base64 VGhpcyBpcyBhIGJpbmFyeSBzdHJpbmc= ./dnsproxy -u 1.1.1.1 --ednsopt "4242:VGhpcyBpcyBhIGJpbmFyeSBzdHJpbmc="
ameshkov
left a comment
There was a problem hiding this comment.
@klyr first of all, thank you for the contribution! This feature does make sense to me.
Could you please add a unit-test for this?
I'd suggest this as a setup:
- Add a "fake" upstream (Upstream implementation that records request and responds immediately with anything)
- Create a proxy with EDNSOpt configured
- Call Resolve method
- Check that EDNS was received by the fake upstream
| } | ||
|
|
||
| if len(options.EDNSOpt) > 0 { | ||
| config.EDNSOpts = make(map[uint16][]byte) |
There was a problem hiding this comment.
Could you please move this code to a separate function and also add a unit-test for it?
|
|
||
| // Set EDNSOpts | ||
| func (p *Proxy) processEDNSOpts(d *DNSContext) { | ||
| var o (*dns.OPT) = nil |
There was a problem hiding this comment.
var o *dns.OPT is a better looking variant
| kv := strings.Split(s, ":") | ||
| if len(kv) != 2 { | ||
| log.Fatalf("parse error for '%s', --ednsopt must be of the form: option-code:base64encodeddata (ex: --ednsopt 8:SGVsbG8gd29ybGQK)", s) | ||
| } else { |
There was a problem hiding this comment.
else branch is not needed here, just put the code below without it
Add a new --ednsopt option to add arbitrary EDNS options.