-
Notifications
You must be signed in to change notification settings - Fork 250
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
Ednsopt #91
base: master
Are you sure you want to change the base?
Ednsopt #91
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="
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.
@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
@@ -218,6 +224,27 @@ func createProxyConfig(options Options) proxy.Config { | |||
} | |||
} | |||
|
|||
if len(options.EDNSOpt) > 0 { | |||
config.EDNSOpts = make(map[uint16][]byte) |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else
branch is not needed here, just put the code below without it
Add a new --ednsopt option to add arbitrary EDNS options.