Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(iroh-net)!: Rename Endpoint::local_addr to bound_sockets #2366

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iroh-net/bench/src/iroh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn server_endpoint(rt: &tokio::runtime::Runtime, opt: &Opt) -> (NodeAddr, En
.bind(0)
.await
.unwrap();
let addr = ep.local_addr();
let addr = ep.bound_sockets();
let addr = SocketAddr::new("127.0.0.1".parse().unwrap(), addr.0.port());
let addr = NodeAddr::new(ep.node_id()).with_direct_addresses([addr]);
(addr, ep)
Expand Down
6 changes: 3 additions & 3 deletions iroh-net/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ impl Endpoint {
///
/// The [`Endpoint`] always binds on an IPv4 address and also tries to bind on an IPv6
/// address if available.
pub fn local_addr(&self) -> (SocketAddr, Option<SocketAddr>) {
pub fn bound_sockets(&self) -> (SocketAddr, Option<SocketAddr>) {
self.msock.local_addr()
}

Expand Down Expand Up @@ -1246,7 +1246,7 @@ mod tests {
.bind(0)
.await
.unwrap();
let eps = ep.local_addr();
let eps = ep.bound_sockets();
info!(me = %ep.node_id().fmt_short(), ipv4=%eps.0, ipv6=?eps.1, "server bound");
for i in 0..n_clients {
let now = Instant::now();
Expand Down Expand Up @@ -1291,7 +1291,7 @@ mod tests {
.bind(0)
.await
.unwrap();
let eps = ep.local_addr();
let eps = ep.bound_sockets();
info!(me = %ep.node_id().fmt_short(), ipv4=%eps.0, ipv6=?eps.1, "client bound");
let node_addr = NodeAddr::new(server_node_id).with_relay_url(relay_url);
info!(to = ?node_addr, "client connecting");
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<D: BaoStore> Node<D> {
/// can contact the node consider using [`Node::local_endpoint_addresses`]. However the
/// port will always be the concrete port.
pub fn local_address(&self) -> Vec<SocketAddr> {
let (v4, v6) = self.inner.endpoint.local_addr();
let (v4, v6) = self.inner.endpoint.bound_sockets();
let mut addrs = vec![v4];
if let Some(v6) = v6 {
addrs.push(v6);
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/node/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ where
) {
let rpc = RpcServer::new(rpc);
let internal_rpc = RpcServer::new(internal_rpc);
let (ipv4, ipv6) = server.local_addr();
let (ipv4, ipv6) = server.bound_sockets();
debug!(
"listening at: {}{}",
ipv4,
Expand Down
Loading