Skip to content

Commit

Permalink
Switch to using the From header for device ID (#20)
Browse files Browse the repository at this point in the history
It appears the From header is actually more meaningingful for calls
coming from Asterisk, as the Contact header does not distinguish between
which device initiated a call like the From header does.
  • Loading branch information
jaminh authored Jul 31, 2024
1 parent 13ad004 commit 84ded2e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions voip_utils/sip.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ def datagram_received(self, data: bytes, addr):

caller_uri = None
caller_name = None
# The Contact header should give us the URI used for sending SIP messages to the device
if headers.get("contact") is not None:
caller_uri, caller_name = self._parse_uri_header(headers.get("contact"))
# We can try using the From header as a fallback
elif headers.get("from") is not None:
# The From header should give us the URI used for sending SIP messages to the device
if headers.get("from") is not None:
caller_uri, caller_name = self._parse_uri_header(headers.get("from"))
# We can try using the Contact header as a fallback
elif headers.get("contact") is not None:
caller_uri, caller_name = self._parse_uri_header(headers.get("contact"))
# If all else fails try to generate a URI based on the IP and port from the address the message came from
else:
caller_uri = "sip:" + caller_ip + ":" + caller_sip_port
Expand Down

0 comments on commit 84ded2e

Please sign in to comment.