Skip to content

Improve the parsing of HostPorts received from MongoDB to work properly with with IPv6 addresses #21

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

A1kmm
Copy link

@A1kmm A1kmm commented Mar 29, 2012

Improve the parsing of HostPorts received from MongoDB to work properly with with IPv6 addresses.

MongoDB's syntax is ambiguous and complex to deal with respect to IPv6 addresses, because the :
character is used to delimit both the parts of the IPv6 address, so the parser needs to be quite
complex.

This code will parse ambiguous examples like ::1:1234 as host ::1, port 1234, matching the approach
taken in MongoDB server codebase. If only one interpretation is possible, it will take that
interpretation. For example ::1:a is parsed as having no port specifier (since a is not a valid
decimal digit).

Also add a test program that tests the code with a number of cases.

…ly with IPv6 addresses.

MongoDB's syntax is ambiguous and complex to deal with respect to IPv6 addresses, because the :
character is used to delimit both the parts of the IPv6 address, so the parser needs to be quite
complex.

This code will parse ambiguous examples like ::1:1234 as host ::1, port 1234, matching the approach
taken in MongoDB server codebase. If only one interpretation is possible, it will take that
interpretation. For example ::1:a is parsed as having no port specifier (since a is not a valid
decimal digit).

Also add a test program that tests the code with a number of cases.
spaces >> eof
return $ Host h (PortNumber $ fromIntegral port)

T.try (spaces >> eof >> return (host h)) <|> do

Choose a reason for hiding this comment

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

I think you should fix the indentation to be consistent with the rest of the codebase.

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.

2 participants