Merge branch 'rename_for_to_from' into 'main'
tor-cell: Rename for_client and for_relay See merge request tpo/core/arti!793
This commit is contained in:
commit
49f0521904
|
@ -650,7 +650,7 @@ fn take_one_netinfo_addr(r: &mut Reader<'_>) -> Result<Option<IpAddr>> {
|
|||
}
|
||||
impl Netinfo {
|
||||
/// Construct a new Netinfo to be sent by a client.
|
||||
pub fn for_client(their_addr: Option<IpAddr>) -> Self {
|
||||
pub fn from_client(their_addr: Option<IpAddr>) -> 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<V>(timestamp: u32, their_addr: Option<IpAddr>, my_addrs: V) -> Self
|
||||
pub fn from_relay<V>(timestamp: u32, their_addr: Option<IpAddr>, my_addrs: V) -> Self
|
||||
where
|
||||
V: Into<Vec<IpAddr>>,
|
||||
{
|
||||
|
|
|
@ -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(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -578,7 +578,7 @@ impl<T: AsyncRead + AsyncWrite + Send + Unpin + 'static, S: SleepProvider> 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,
|
||||
|
|
Loading…
Reference in New Issue