Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Validate ipv6 support #172

Merged
merged 15 commits into from Nov 18, 2015
Merged

Validate ipv6 support #172

merged 15 commits into from Nov 18, 2015

Conversation

fredthomsen
Copy link
Contributor

No description provided.

@Lukasa
Copy link
Member

Lukasa commented Oct 16, 2015

So far you're encountering test failures, but I'm keeping an eye on the progress. Thanks for doing this work @fredthomsen!

@fredthomsen
Copy link
Contributor Author

Had some trouble getting some things to split proper and ended up with a regex. Just wanted to get your thoughts,

@Lukasa
Copy link
Member

Lukasa commented Oct 18, 2015

Hmmm, I have pretty mixed feelings about using a regex here. @sigmavirus24, do you have anything useful for this floating around?

@sigmavirus24
Copy link
Contributor

I have a very complicated regular expression that is built up progressively in rfc3986 and is based on the ABNF from RFC 3986

Sent from my Android device with K-9 Mail. Please excuse my brevity.

@sigmavirus24
Copy link
Contributor

@Lukasa
Copy link
Member

Lukasa commented Oct 19, 2015

So, should we either vendor or require that package?

@sigmavirus24
Copy link
Contributor

Sorry I never answered you @Lukasa.

You can do either. rfc3986 is vendorable. It has stricter support for parsing URIs according to RFC 3986 than the urlparse library does. You can actually replace that with rfc3986 if you want.

@Lukasa
Copy link
Member

Lukasa commented Oct 23, 2015

It feels like we should do that then. @fredthomsen, does that sound like something you want to take on?

@fredthomsen
Copy link
Contributor Author

Yes. I'll handle this. I'll grab some help from you if needed.

On Fri, Oct 23, 2015 at 12:22 PM, Cory Benfield notifications@github.com
wrote:

It feels like we should do that then. @fredthomsen
https://github.com/fredthomsen, does that sound like something you want
to take on?


Reply to this email directly or view it on GitHub
#172 (comment).

-Fred Thomsen

@sigmavirus24
Copy link
Contributor

👍 @fredthomsen

@fredthomsen
Copy link
Contributor Author

When making something vendorable, what is the appropriate thing to do in terms of license files, author files, etc? I see other vendorable packages we include have no such files. Also I assume I should pull from the latest release of rfc3986 which would be 0.3.0.

@Lukasa
Copy link
Member

Lukasa commented Nov 10, 2015

Generally speaking, when vendoring packages you should pull specific releases, include their copyright files in with them, and also add them to a NOTICES file at the root of this repo.

In the case of the other projects, I didn't do that because their license and copyright statements are exactly the same as for this project.

@fredthomsen
Copy link
Contributor Author

Seems like this library needs a full URI instead of just an IP to do it's job.

`

uri = uri_reference('1.2.3.4')
uri.is_valid()
True
uri.host
uri.port
uri.path
u'1.2.3.4
`

and IPv6 addresses can't be parsed without brackets which is the same as the point above.

hyper.packages.rfc3986.exceptions.InvalidPort: The port ("dcba::1234") is not valid.

I can work around the first problem by prepending schemes; however, the second is that IPv6 addresses will require brackets even when no port is present which seems like a strange restriction to enforce. Is there another way to leverage this module or was there something else you two had in mind when you wanted to incorporate this?

@Lukasa
Copy link
Member

Lukasa commented Nov 16, 2015

I think it's ok to require that the IP addresses be surrounded by square brackets. That's an easy enough check to do before passing the IP to the library.

@sigmavirus24
Copy link
Contributor

You can also create a URIReference directly if you only want to validate the host. Just note that the parameter in the reference you're looking for is called authority (which encompasses the userinfo, host, and port).

@fredthomsen
Copy link
Contributor Author

@sigmavirus24 thanks for the help, I took that approach. @Lukasa, I updated the test cases accordingly to reflect what you said. Pushed the changes, but I am having some issues with pypy failures.

host, port = hostname.split(':')
return host, int(port)
host, port = to_host_port_tuple(hostname)
return host, port
Copy link
Member

Choose a reason for hiding this comment

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

We may as well condense this to a single logical line now.

else:
port = int(uri.port)

return ((host, port))
Copy link
Member

Choose a reason for hiding this comment

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

We don't need the double parens here.

@sigmavirus24
Copy link
Contributor

@fredthomsen the pypy failures are because you need to add a line to the list of packages otherwise it won't be installed properly.

@fredthomsen
Copy link
Contributor Author

Thanks @sigmavirus24. Ok think we're good now.

@sigmavirus24
Copy link
Contributor

🍰

@Lukasa
Copy link
Member

Lukasa commented Nov 18, 2015

Ok, I officially love this and think it's beautiful. Thanks for the fantastic library @sigmavirus24, and thanks for the hard work @fredthomsen. You two are magical people. ✨ 🍰 ✨

Lukasa added a commit that referenced this pull request Nov 18, 2015
@Lukasa Lukasa merged commit e7ce870 into python-hyper:development Nov 18, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants