diff --git a/crates/tor-cell/src/chancell/msg.rs b/crates/tor-cell/src/chancell/msg.rs index 487549d42..b4cfe821d 100644 --- a/crates/tor-cell/src/chancell/msg.rs +++ b/crates/tor-cell/src/chancell/msg.rs @@ -650,7 +650,7 @@ fn take_one_netinfo_addr(r: &mut Reader<'_>) -> Result> { } impl Netinfo { /// Construct a new Netinfo to be sent by a client. - pub fn for_client(their_addr: Option) -> Self { + pub fn from_client(their_addr: Option) -> Self { Netinfo { timestamp: 0, // clients don't report their timestamps. their_addr, @@ -658,7 +658,7 @@ impl Netinfo { } } /// Construct a new Netinfo to be sent by a relay - pub fn for_relay(timestamp: u32, their_addr: Option, my_addrs: V) -> Self + pub fn from_relay(timestamp: u32, their_addr: Option, my_addrs: V) -> Self where V: Into>, { diff --git a/crates/tor-cell/tests/testvec_chanmsg.rs b/crates/tor-cell/tests/testvec_chanmsg.rs index c285be199..f05c39775 100644 --- a/crates/tor-cell/tests/testvec_chanmsg.rs +++ b/crates/tor-cell/tests/testvec_chanmsg.rs @@ -243,14 +243,14 @@ fn test_netinfo() { fbody( cmd, "00000000 04 04 7F000001 00", - &msg::Netinfo::for_client(Some(localhost)).into(), + &msg::Netinfo::from_client(Some(localhost)).into(), ); // example relay netinfo fbody( cmd, "5F6F80E1 04 04 7F000001 01 04 04 7F000001", - &msg::Netinfo::for_relay(0x5f6f80e1, Some(localhost), &[localhost][..]).into(), + &msg::Netinfo::from_relay(0x5f6f80e1, Some(localhost), &[localhost][..]).into(), ); // example ipv6 relay netinfo @@ -261,7 +261,7 @@ fn test_netinfo() { 02 04 04 7F000001 06 10 00000000000000000000000000000001", - &msg::Netinfo::for_relay( + &msg::Netinfo::from_relay( 0x5f6f859c, Some(localhost_v6), &[localhost, localhost_v6][..], @@ -280,14 +280,14 @@ fn test_netinfo() { false, ); let expect: msg::ChanMsg = - msg::Netinfo::for_relay(0x5f6f859c, None, &[localhost_v6][..]).into(); + msg::Netinfo::from_relay(0x5f6f859c, None, &[localhost_v6][..]).into(); assert_eq!(format!("{:?}", netinfo), format!("{:?}", expect)); // Zero-valued their_address are None (hand-generated from above) fbody( cmd, "00000000 04 04 00000000 00", - &msg::Netinfo::for_client(None).into(), + &msg::Netinfo::from_client(None).into(), ); } diff --git a/crates/tor-proto/src/channel/handshake.rs b/crates/tor-proto/src/channel/handshake.rs index 804abc285..fcc35cd35 100644 --- a/crates/tor-proto/src/channel/handshake.rs +++ b/crates/tor-proto/src/channel/handshake.rs @@ -578,7 +578,7 @@ impl Verif .and_then(ChannelMethod::socket_addrs) .and_then(|addrs| addrs.get(0)) .map(SocketAddr::ip); - let netinfo = msg::Netinfo::for_client(peer_ip); + let netinfo = msg::Netinfo::from_client(peer_ip); self.tls .send(netinfo.into()) .await @@ -816,7 +816,7 @@ pub(super) mod test { R: Runtime, { let localhost = std::net::IpAddr::V4(std::net::Ipv4Addr::LOCALHOST); - let netinfo_cell = msg::Netinfo::for_client(Some(localhost)); + let netinfo_cell = msg::Netinfo::from_client(Some(localhost)); let clock_skew = ClockSkew::None; UnverifiedChannel { link_protocol: 4,