@@ -394,12 +394,10 @@ pub enum NetAddress {
394394 port : u16 ,
395395 } ,
396396 /// An old-style Tor onion address/port on which the peer is listening.
397- OnionV2 {
398- /// The bytes (usually encoded in base32 with ".onion" appended)
399- addr : [ u8 ; 10 ] ,
400- /// The port on which the node is listening
401- port : u16 ,
402- } ,
397+ ///
398+ /// This field is deprecated and the Tor network generally no longer supports V2 Onion
399+ /// addresses. Thus, the details are not parsed here.
400+ OnionV2 ( [ u8 ; 12 ] ) ,
403401 /// A new-style Tor onion address/port on which the peer is listening.
404402 /// To create the human-readable "hostname", concatenate ed25519_pubkey, checksum, and version,
405403 /// wrap as base32 and append ".onion".
@@ -421,7 +419,7 @@ impl NetAddress {
421419 match self {
422420 & NetAddress :: IPv4 { ..} => { 1 } ,
423421 & NetAddress :: IPv6 { ..} => { 2 } ,
424- & NetAddress :: OnionV2 { .. } => { 3 } ,
422+ & NetAddress :: OnionV2 ( _ ) => { 3 } ,
425423 & NetAddress :: OnionV3 { ..} => { 4 } ,
426424 }
427425 }
@@ -431,7 +429,7 @@ impl NetAddress {
431429 match self {
432430 & NetAddress :: IPv4 { .. } => { 6 } ,
433431 & NetAddress :: IPv6 { .. } => { 18 } ,
434- & NetAddress :: OnionV2 { .. } => { 12 } ,
432+ & NetAddress :: OnionV2 ( _ ) => { 12 } ,
435433 & NetAddress :: OnionV3 { .. } => { 37 } ,
436434 }
437435 }
@@ -453,10 +451,9 @@ impl Writeable for NetAddress {
453451 addr. write ( writer) ?;
454452 port. write ( writer) ?;
455453 } ,
456- & NetAddress :: OnionV2 { ref addr , ref port } => {
454+ & NetAddress :: OnionV2 ( bytes ) => {
457455 3u8 . write ( writer) ?;
458- addr. write ( writer) ?;
459- port. write ( writer) ?;
456+ bytes. write ( writer) ?;
460457 } ,
461458 & NetAddress :: OnionV3 { ref ed25519_pubkey, ref checksum, ref version, ref port } => {
462459 4u8 . write ( writer) ?;
@@ -486,12 +483,7 @@ impl Readable for Result<NetAddress, u8> {
486483 port : Readable :: read ( reader) ?,
487484 } ) )
488485 } ,
489- 3 => {
490- Ok ( Ok ( NetAddress :: OnionV2 {
491- addr : Readable :: read ( reader) ?,
492- port : Readable :: read ( reader) ?,
493- } ) )
494- } ,
486+ 3 => Ok ( Ok ( NetAddress :: OnionV2 ( Readable :: read ( reader) ?) ) ) ,
495487 4 => {
496488 Ok ( Ok ( NetAddress :: OnionV3 {
497489 ed25519_pubkey : Readable :: read ( reader) ?,
@@ -1922,10 +1914,9 @@ mod tests {
19221914 } ) ;
19231915 }
19241916 if onionv2 {
1925- addresses. push ( msgs:: NetAddress :: OnionV2 {
1926- addr : [ 255 , 254 , 253 , 252 , 251 , 250 , 249 , 248 , 247 , 246 ] ,
1927- port : 9735
1928- } ) ;
1917+ addresses. push ( msgs:: NetAddress :: OnionV2 (
1918+ [ 255 , 254 , 253 , 252 , 251 , 250 , 249 , 248 , 247 , 246 , 38 , 7 ]
1919+ ) ) ;
19291920 }
19301921 if onionv3 {
19311922 addresses. push ( msgs:: NetAddress :: OnionV3 {
0 commit comments