Skip to content

Fix ip-address parsing for IPv6 addresses - #1670

Merged
L1ghtn1ng merged 1 commit into
laramies:masterfrom
jeffguy:master
Feb 24, 2024
Merged

L1ghtn1ng merged 1 commit into
laramies:masterfrom
jeffguy:master

Conversation

@jeffguy

@jeffguy jeffguy commented Feb 24, 2024

Copy link
Copy Markdown
Contributor

Sometimes, the host string uses IPv6 instead of IPv4, so the address has colons. This can result in a string like

google.com:2607:f8b0:4006:80b::200e

If we then run

subdomain, addr = host.split(":")

host.split(":") returns a list of seven strings because their are six colons. Setting (subdomain, addr) to a list of seven strings doesn't work (ValueError: too many values to unpack (expected 2)). What we really want here is

subdomain, addr = host.split(":", 1)

which splits only on the first colon, so a list of two strings is returned, and the whole IPv6 address gets assigned to the addr variable.

@L1ghtn1ng

Copy link
Copy Markdown
Collaborator

Thank you for submitting this, much appreciated ☺️

@L1ghtn1ng
L1ghtn1ng merged commit b87064f into laramies:master Feb 24, 2024
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