Skip to content
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

[#9449] IPv6 address changes in 3.7 #1018

Merged
merged 6 commits into from Jul 1, 2018
Merged

[#9449] IPv6 address changes in 3.7 #1018

merged 6 commits into from Jul 1, 2018

Conversation

hawkowl
Copy link
Member

@hawkowl hawkowl commented May 20, 2018

@codecov
Copy link

codecov bot commented May 20, 2018

Codecov Report

Merging #1018 into trunk will decrease coverage by 0.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##            trunk    #1018      +/-   ##
==========================================
- Coverage   91.65%   91.64%   -0.02%     
==========================================
  Files         844      844              
  Lines      150582   150618      +36     
  Branches    13148    13154       +6     
==========================================
+ Hits       138016   138033      +17     
- Misses      10465    10481      +16     
- Partials     2101     2104       +3

@hawkowl hawkowl changed the title [WIP] [#9449] IPv6 address changes in 3.7 [#9449] IPv6 address changes in 3.7 May 22, 2018
Copy link
Member

@glyph glyph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really like it if the language in some of these comments were tightened up, and explicit references to the specific API change in 3.7 were added so it's a little clearer what information we're preserving and why. Scope IDs are a weird beast and it's good to be precise when talking about them - the scope ID in an IPv6 address is very much not quite the same thing as a physical network interface (although they do frequently correspond, and sometimes interface names are valid scope IDs).

Should the .misc be a non-.misc that says something about 3.7 compatibility, or is this something that's obscure enough that most people won't notice?

One thing I'm also curious about, though, is why you're so interested in preserving the scope ID within the address literal portion of the 4-tuple, given that the scope ID is already present as an integer at the end of that 4-tuple.

However, I'm willing to take it on faith that there's a good compatibility reason you needed to do this, and things break on 3.7 without it. The test coverage is sufficient and the logic looks correct. So if you could just please add this info, correct any "interface -> scopeID" language where appropriate, and then land that would be great.

@@ -189,7 +189,7 @@ def changePassPhrase(options):
'Enter file in which the key is (%s): ' % filename)
try:
key = keys.Key.fromFile(options['filename'])
except keys.EncryptedKeyError as e:
except keys.EncryptedKeyError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems… extraneous, but I'll allow it :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failing txchecker because it hates me >:C

"""
Return a 2-tuple of socket IP and port for IPv4 and a 4-tuple of
socket IP, port, flowInfo, and scopeID. With IPv6 addresses, this
preserves the interface portion.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of "socket IP, port, flowInfo, and scopeID", none of those things are obviously called "interface". Can you clarify just a little as to what is being preserved, and why this is important (or what wouldn't preserve it?) I think for future maintainers understanding that this is papering over a 3.6 / 3.7 difference is probably pretty important.

@@ -580,16 +580,24 @@ def handleAccept(self, rc, evt):
rAddr = (nativeString(rAddr[0]), rAddr[1])
assert family == self.addressFamily

# Build a proper IPv6 address structure, if it exists
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By "proper" I think you mean "including scope ID, if necessary"?

@@ -429,7 +462,12 @@ def _setRealAddress(self, address):
and the 'host' portion will always be an IP address, not a DNS
name.
"""
self.realAddress = address
if len(address) == 4:
# IPv6, make sure we have the interface portion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ITYM "scope ID"

"""
if len(addr) == 4:
# IPv6
host = socket.getnameinfo(addr, socket.NI_NUMERICHOST)[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you really want socket.NI_NUMERICHOST | socket.NI_NUMERICSERV; you don't need to do service-name lookup, so this is asking the OS to do some pointless I/O on a part of the address you'll immediately throw away.

@hawkowl hawkowl merged commit 776c4d6 into trunk Jul 1, 2018
@hawkowl hawkowl deleted the 9449-numerichost branch July 1, 2018 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants