Skip to content

feat(iroh)!: replace Incoming::local_ip with Incoming::local_addr#4182

Merged
dignifiedquire merged 8 commits intomainfrom
fix-local-addrs
Apr 30, 2026
Merged

feat(iroh)!: replace Incoming::local_ip with Incoming::local_addr#4182
dignifiedquire merged 8 commits intomainfrom
fix-local-addrs

Conversation

@dignifiedquire
Copy link
Copy Markdown
Contributor

Description

This allows custom transports to show expose their incoming address as well, and makes this API more future proof for transports in general.

Closes #3886

Breaking Changes

  • remove
    • Incoming::local_ip (use Incoming::local_addr now)

This allows custom transports to show expose their incoming address as well, and makes this API more future proof for transports in general.

Closes #3886
@dignifiedquire dignifiedquire requested review from flub and rklaehn April 27, 2026 09:24
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/4182/docs/iroh/

Last updated: 2026-04-30T08:08:26Z

Comment thread iroh/src/socket/transports.rs Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 528f2fb

Comment thread iroh/src/socket/transports.rs Outdated
Comment on lines +544 to +547
/// The remote custom address.
remote: CustomAddr,
/// The local custom address, if the transport reports one.
local: Option<CustomAddr>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the public API, but not sure I like the implementation. The type is entirely different for Custom now, essentially it is a 4-tuple that describes the network path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flub feel better with the latest version?

@dignifiedquire dignifiedquire added this to the v1.0.0-rc.0 milestone Apr 27, 2026
@rklaehn
Copy link
Copy Markdown
Contributor

rklaehn commented Apr 27, 2026

Here is a variant that leaves Addr alone: #4185

@n0bot n0bot Bot added this to iroh Apr 27, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh Apr 27, 2026
…sses. (#4185)

## Description

Introduce a struct RecvInfo that has local and remote addresses.

This is an internal struct unless you enable custom transports. It
internally has remote as Addr, but the only public way to construct it
is via new, which takes only a CustomAddr. So the custom transports API
becomes a bit more tight.

We could have a separate struct for the custom transports, but that
would mean that we would have to copy in a hot path.


## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist
<!-- Remove any that are not relevant. -->
- [ ] Self-review.
- [ ] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [ ] Tests if relevant.
- [ ] All breaking changes documented.
- [ ] List all breaking changes in the above "Breaking Changes" section.
- [ ] Open an issue or PR on any number0 repos that are affected by this
breaking change. Give guidance on how the updates should be handled or
do the actual updates themselves. The major ones are:
    - [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc)
    - [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip)
    - [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs)
    - [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe)
    - [ ] [`sendme`](https://github.com/n0-computer/sendme)
@rklaehn rklaehn requested a review from flub April 27, 2026 12:33
Comment thread iroh/src/socket.rs
Comment on lines +642 to +645
if let Some(local) = recv_info.local() {
let local_mapped = self.mapped_addrs.custom_addrs.get(local);
noq_meta.dst_ip = Some(local_mapped.private_socket_addr().ip());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work? MappedAddrs::custom_addrs is a map from a custom addr to an IPv6 ULA. Both the local and remote custom addresses get looked up there so they both get their own IPv6 ULA. Where do they get inserted into this map?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could have sworn I had code for this, maybe it got lost..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happening in socket.rs 640, get also inserts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I guess I find it a bit confusing that both the remote and local addrs are in the same map. Would it not make sense to use different ULA subnets for the local and remote addresses? That would also make identifying them in logs etc a bit more easily.

I'd even be tempted to map each different custom transport to a different ULA subnet, since I believe you have a unique numerical identifier for it anyway. But I guess that's out of scope here as that already exists.

AFAIK the ULA mapping is not part of a real contract, other than that it is unique. So changing the address mapping should be something we're allowed to do post 1.0 so perhaps this isn't overly important.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is ULA? 😅

I didn't want to introduce too many new maps, which is why I kept them in the same map for now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IPv6 Unique Local Addresses. It is a range of IPv6 addresses that you can assign yourself. We use them for all the mapped addresses and use a subnet per mapping purpose.

@dignifiedquire dignifiedquire moved this from 🚑 Needs Triage to 👀 In review in iroh Apr 28, 2026
@dignifiedquire dignifiedquire merged commit 5dc7160 into main Apr 30, 2026
34 of 35 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in iroh Apr 30, 2026
@dignifiedquire dignifiedquire deleted the fix-local-addrs branch April 30, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Figure out Incoming::local_ip

3 participants