Skip to content

Derive Listener Transport from Type of Listener Being Created - #139

Open
themooer1 wants to merge 1 commit into
restsend:mainfrom
themooer1:fix/listener-socket-addr
Open

Derive Listener Transport from Type of Listener Being Created#139
themooer1 wants to merge 1 commit into
restsend:mainfrom
themooer1:fix/listener-socket-addr

Conversation

@themooer1

Copy link
Copy Markdown

This PR changes the new methods on TcpListenerConnection, TlsListenerConnection, and WebSocketListenerConnection so they tag their local_addr SipAddr with the correct Transport type e.g. TlsListenerConnection uses Transport::Tls. This makes it so those listeners generate the correct Contact: headers instead of, e.g. a TlsListenerConnection's local_addr causing a plain sip:...@192.168.1.10:<udp_port>;transport=udp Contact: header to be generated.

Previously, for everything but UdpConnection, local_addr was set to a SipAddr which the user passed in, but this didn't make sense because SipAddr is just a SocketAddr + a Transport type. It wouldn't make sense to pass in a Transport type at odds with the type of listener being constructed, so callers of the new method always just passed in None for the transport and that's how it stayed causing the Contact: header builder to fall back to the default_contact_uri which generated an invalid Contact: header if the default listener didn't match the type of connection being handled. Since it never makes sense to pass in a SipAddr with a transport different from the transport used by <whatever>ListenerConnection, I made all the constructors do what UdpConnection::create_connection does and just accept a SocketAddr, which is the only data the constructor really needs to know. Inside the constructor, local_addr is constructed by wrapping the SocketAddr in a SipAddr with the correct Transport.

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.

1 participant