Skip to content

Conversation

@tankyleo
Copy link
Contributor

@tankyleo tankyleo commented Feb 2, 2026


    Add `remote_addr` field to `lightning_net_tokio::setup_outbound`

    When `setup_outbound` was used to setup a connection proxied over Tor,
    it previously set `remote_addr` to the address of the Tor proxy, and not
    the address of the peer on the other side of the stream.

    The address of the Tor proxy was assigned to the
    `PeerDetails::socket_address` for that peer in
    `PeerManager::list_peers`, and if it was not a private IPV4 or IPV6
    address, it was also reported to the peer in our init message.

    Here we ask callers of `setup_outbound` to pass a `remote_addr`
    separately from the `StdTcpStream`. `connect_outbound` sets this new
    `remote_addr` parameter to `get_addr_from_stream`, and
    `tor_connect_outbound` passes its own `addr` parameter directly to
    `remote_addr`.

    Notably, Onion V3 addresses will now appear in `PeerManager::list_peers`
    for outbound Tor connections to Onion V3 services made using
    `tor_connect_outbound`, and will be reported to the peer in our init
    message.

    While this adds a new parameter to the public `fn setup_outbound`
    function, this closely mirrors the existing public method
    `PeerManager::new_outbound_connection`.

When `setup_outbound` was used to setup a connection proxied over Tor,
it previously set `remote_addr` to the address of the Tor proxy, and not
the address of the peer on the other side of the stream.

The address of the Tor proxy was assigned to the
`PeerDetails::socket_address` for that peer in
`PeerManager::list_peers`, and if it was not a private IPV4 or IPV6
address, it was also reported to the peer in our init message.

Here we ask callers of `setup_outbound` to pass a `remote_addr`
separately from the `StdTcpStream`. `connect_outbound` sets this new
`remote_addr` parameter to `get_addr_from_stream`, and
`tor_connect_outbound` passes its own `addr` parameter directly to
`remote_addr`.

Notably, Onion V3 addresses will now appear in `PeerManager::list_peers`
for outbound Tor connections to Onion V3 services made using
`tor_connect_outbound`, and will be reported to the peer in our init
message.

While this adds a new parameter to the public `fn setup_outbound`
function, this closely mirrors the existing public method
`PeerManager::new_outbound_connection`.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Feb 2, 2026

👋 Thanks for assigning @TheBlueMatt as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@tankyleo
Copy link
Contributor Author

tankyleo commented Feb 2, 2026

Fixes the issues @jharveyb reported in lightningdevkit/ldk-node#778

@tankyleo tankyleo requested review from TheBlueMatt and tnull February 2, 2026 19:27
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 41.66667% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.00%. Comparing base (8679d8d) to head (f8906d7).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
lightning-net-tokio/src/lib.rs 41.66% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4372      +/-   ##
==========================================
+ Coverage   85.98%   86.00%   +0.01%     
==========================================
  Files         156      156              
  Lines      102641   102694      +53     
  Branches   102641   102694      +53     
==========================================
+ Hits        88258    88317      +59     
+ Misses      11873    11869       -4     
+ Partials     2510     2508       -2     
Flag Coverage Δ
tests 86.00% <41.66%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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