fix: IPv6 TCP connection support#96
Merged
shenjinti merged 1 commit intorestsend:mainfrom Feb 23, 2026
Merged
Conversation
Three bugs prevented native IPv6 TCP connections from working: 1. TcpListenerConnection::serve_listener() assigned the remote peer address as the connection's local address (tcp_listener.rs). For IPv4-mapped addresses this was harmless, but for native IPv6 it produced an invalid local address. Fixed by capturing the listener's actual local address before the accept loop. 2. build_via_received() serialized IPv6 addresses without brackets in the Via received= parameter (connection.rs), producing received=2001:db8::1 instead of received=[2001:db8::1]. When rsip re-parsed this, it misinterpreted colons as port separators. 3. serve_connection() silently discarded the Result from serve_loop() (transport_layer.rs), making transport errors invisible. The error is now logged at warn level. Tested with production Ribbon SBC traffic over TCP/IPv6. All three fixes are required for native IPv6 TCP to work end-to-end. Relates to restsend#94 (similar parser failures in on_received_message).
Contributor
|
Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three bugs prevent native IPv6 TCP connections from working. IPv4-mapped addresses (
::ffff:x.x.x.x) work by accident, but native IPv6 addresses fail silently — the serve_loop exits after parsing the first message with no error logged.Discovered while building a SIP redirect server that receives INVITE traffic from a Ribbon SBC over TCP/IPv6.
Bug 1:
TcpListenerConnection::serve_listener()— wrong local addresstcp_listener.rsline 54 assigns the remote peer address as the connection's local address:For IPv4-mapped addresses this is harmless, but for native IPv6 it produces an invalid local address.
Fix: Capture the listener's actual local address (
listener.local_addr()) before the accept loop and use it for all accepted connections.Bug 2:
build_via_received()— bare IPv6 in Viareceived=connection.rsserializes IPv6 addresses without brackets:When rsip re-parses this modified Via header, it misinterprets the colons in the IPv6 address as port separators, failing with
invalid digit found in string.Fix: Wrap IPv6 addresses in brackets per RFC 3261 §18.2.1:
received=[2600:1900:4040:181:0:13::]Bug 3:
serve_connection()— silent error discardtransport_layer.rsdiscards theResultfromserve_loop():This makes transport errors completely invisible — the only log is
"transport serve_loop exited"with no error detail.Fix: Capture and log the error at
warnlevel.Testing
Tested with production Ribbon SBC traffic over TCP/IPv6:
Note
There is also a related bug in rsip 0.4.0 — the
host_with_portparser does not handle[IPv6]:portsyntax in Via headers (RFC 3261 §25.1IPv6reference). We have a fix for that but it belongs in the rsip crate, not rsipstack. Mentioning it here for awareness since it affects any SIP endpoint that receives Via headers with bracketed IPv6 addresses.Relates to #94 (similar parser failures in
on_received_message).