Merge pull request #1204 from TheBlueMatt/2021-12-no-torv2

Remove OnionV2 parsing support
This commit is contained in:
Matt Corallo 2021-12-06 22:49:18 +00:00 committed by GitHub
commit 9c6961ea84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 23 deletions

View file

@ -394,12 +394,10 @@ pub enum NetAddress {
port: u16, port: u16,
}, },
/// An old-style Tor onion address/port on which the peer is listening. /// An old-style Tor onion address/port on which the peer is listening.
OnionV2 { ///
/// The bytes (usually encoded in base32 with ".onion" appended) /// This field is deprecated and the Tor network generally no longer supports V2 Onion
addr: [u8; 10], /// addresses. Thus, the details are not parsed here.
/// The port on which the node is listening OnionV2([u8; 12]),
port: u16,
},
/// A new-style Tor onion address/port on which the peer is listening. /// A new-style Tor onion address/port on which the peer is listening.
/// To create the human-readable "hostname", concatenate ed25519_pubkey, checksum, and version, /// To create the human-readable "hostname", concatenate ed25519_pubkey, checksum, and version,
/// wrap as base32 and append ".onion". /// wrap as base32 and append ".onion".
@ -421,7 +419,7 @@ impl NetAddress {
match self { match self {
&NetAddress::IPv4 {..} => { 1 }, &NetAddress::IPv4 {..} => { 1 },
&NetAddress::IPv6 {..} => { 2 }, &NetAddress::IPv6 {..} => { 2 },
&NetAddress::OnionV2 {..} => { 3 }, &NetAddress::OnionV2(_) => { 3 },
&NetAddress::OnionV3 {..} => { 4 }, &NetAddress::OnionV3 {..} => { 4 },
} }
} }
@ -431,7 +429,7 @@ impl NetAddress {
match self { match self {
&NetAddress::IPv4 { .. } => { 6 }, &NetAddress::IPv4 { .. } => { 6 },
&NetAddress::IPv6 { .. } => { 18 }, &NetAddress::IPv6 { .. } => { 18 },
&NetAddress::OnionV2 { .. } => { 12 }, &NetAddress::OnionV2(_) => { 12 },
&NetAddress::OnionV3 { .. } => { 37 }, &NetAddress::OnionV3 { .. } => { 37 },
} }
} }
@ -453,10 +451,9 @@ impl Writeable for NetAddress {
addr.write(writer)?; addr.write(writer)?;
port.write(writer)?; port.write(writer)?;
}, },
&NetAddress::OnionV2 { ref addr, ref port } => { &NetAddress::OnionV2(bytes) => {
3u8.write(writer)?; 3u8.write(writer)?;
addr.write(writer)?; bytes.write(writer)?;
port.write(writer)?;
}, },
&NetAddress::OnionV3 { ref ed25519_pubkey, ref checksum, ref version, ref port } => { &NetAddress::OnionV3 { ref ed25519_pubkey, ref checksum, ref version, ref port } => {
4u8.write(writer)?; 4u8.write(writer)?;
@ -486,12 +483,7 @@ impl Readable for Result<NetAddress, u8> {
port: Readable::read(reader)?, port: Readable::read(reader)?,
})) }))
}, },
3 => { 3 => Ok(Ok(NetAddress::OnionV2(Readable::read(reader)?))),
Ok(Ok(NetAddress::OnionV2 {
addr: Readable::read(reader)?,
port: Readable::read(reader)?,
}))
},
4 => { 4 => {
Ok(Ok(NetAddress::OnionV3 { Ok(Ok(NetAddress::OnionV3 {
ed25519_pubkey: Readable::read(reader)?, ed25519_pubkey: Readable::read(reader)?,
@ -1922,10 +1914,9 @@ mod tests {
}); });
} }
if onionv2 { if onionv2 {
addresses.push(msgs::NetAddress::OnionV2 { addresses.push(msgs::NetAddress::OnionV2(
addr: [255, 254, 253, 252, 251, 250, 249, 248, 247, 246], [255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 38, 7]
port: 9735 ));
});
} }
if onionv3 { if onionv3 {
addresses.push(msgs::NetAddress::OnionV3 { addresses.push(msgs::NetAddress::OnionV3 {

View file

@ -475,10 +475,9 @@ macro_rules! impl_array {
); );
} }
//TODO: performance issue with [u8; size] with impl_array!()
impl_array!(3); // for rgb impl_array!(3); // for rgb
impl_array!(4); // for IPv4 impl_array!(4); // for IPv4
impl_array!(10); // for OnionV2 impl_array!(12); // for OnionV2
impl_array!(16); // for IPv6 impl_array!(16); // for IPv6
impl_array!(32); // for channel id & hmac impl_array!(32); // for channel id & hmac
impl_array!(PUBLIC_KEY_SIZE); // for PublicKey impl_array!(PUBLIC_KEY_SIZE); // for PublicKey