home-assistant-libs / voip-utils

Apache License 2.0
1 stars 5 forks source link

Host is restricted to IPv4 #9

Closed synesthesiam closed 1 year ago

synesthesiam commented 1 year ago

See https://github.com/home-assistant/core/issues/92481

troykelly commented 1 year ago

I've made some changes here https://github.com/troykelly/voip-utils/blob/remove-ipv4-only/voip_utils/sip.py

I'm not sure of the wider impact, and not sure how to test - any advice welcome

synesthesiam commented 1 year ago

This is merged now. Some IPv4 stuff is still hard-coded, e.g. https://github.com/home-assistant-libs/voip-utils/blob/ee03f5f4e30baf5e75657bf25dea9aec87fe00ce/voip_utils/sip.py#L123

ToxicFrog commented 10 months ago

The PR #12 hasn't been merged yet, so I don't think this should be closed.

I tried out #12 locally, and it didn't work out of the box because the server_address field in SdpInfo isn't provided when the Hass integration constructs one. Changing line 29 to server_address: str = "localhost" so it's not a mandatory constructor argument allows it to start up.

Unfortunately, it still doesn't work there because resolve_hostname() fails, because the hostname it's passed is "". Looking at the code around line 115 that extracts the server IP or hostname, it looks like the regex for IPv6 address matches the empty string, so it always succeeds and results in a host of "" -- the positive lookahead that's meant to constrain it ends up matching on the : separating the host and the port. Later code then tries to resolve that (because it's neither an ipv4 nor ipv6 address) and explodes.

I don't have time right now to figure out what the correct regex for ipv6 support is, but commenting out that part of the regex entirely results in it extracting the correct hostname and dialing in using the hostname works properly at that point.

slyticoon commented 5 months ago

This still appears to be an issue. Trying to set up my HA instance as a trunk in FreePBX, but I am getting the same error. Hostname doesn't want to resolve.

Will try the fix of commenting out Ipv6 regex.