-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Export EDNS0 interface #1041
Export EDNS0 interface #1041
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1041 +/- ##
=========================================
- Coverage 55.05% 54.95% -0.1%
=========================================
Files 41 41
Lines 9879 9906 +27
=========================================
+ Hits 5439 5444 +5
- Misses 3419 3441 +22
Partials 1021 1021
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.
thanks for picking this up, mostly looks OK.
edns.go
Outdated
b := make([]byte, 4) | ||
func (e *EDNS0_SUBNET) Len() int { | ||
l := 4 | ||
switch e.Family { |
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.
think this can be more easily done with an if
if e.Family == 1 { return 4 }
and then handle the Family == 2
case. Note sure what the RFC says about other families.
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.
I reviewed the RFC. It says
The format of the address part depends on the value of FAMILY. This
document only defines the format for FAMILY 1 (IPv4) and FAMILY 2
(IPv6), which are as follows:
Sounds to me like FAMILY only controls the format of ADDRESS, but SOURCE PREFIX-LENGTH and SCOPE PREFIX-LENGTH retain their meaning. In any case, only IPv4 and IPv6 are defined, to which this generalisation holds.
Therefore, I simplified the code to
return 4 + int((e.SourceNetmask + 8 - 1) / 8)
```
Replace all the private methods in the EDNS0 with public methods. Additionally, as suggested in issue miekg#857, made Pack receive a pre-allocated byte array, introduce a Len method, and have Pack and Unpack return the number of octets written and read (respectively) if there was no error. Closes miekg#857
This reverts commit a98e771. This is breaking people
Replace all the private methods in the EDNS0 with public methods. Additionally, as suggested in issue miekg#857, made Pack receive a pre-allocated byte array, introduce a Len method, and have Pack and Unpack return the number of octets written and read (respectively) if there was no error. Closes miekg#857
This reverts commit a98e771. This is breaking people
Replace all the private methods in the EDNS0 with public methods.
Additionally, as suggested in issue #857, made Pack receive a
pre-allocated byte array, introduce a Len method, and have Pack
and Unpack return the number of octets written and read (respectively)
if there was no error.
Closes #857