@@ -394,12 +394,10 @@ pub enum NetAddress {
394
394
port : u16 ,
395
395
} ,
396
396
/// 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 ] ) ,
403
401
/// A new-style Tor onion address/port on which the peer is listening.
404
402
/// To create the human-readable "hostname", concatenate ed25519_pubkey, checksum, and version,
405
403
/// wrap as base32 and append ".onion".
@@ -421,7 +419,7 @@ impl NetAddress {
421
419
match self {
422
420
& NetAddress :: IPv4 { ..} => { 1 } ,
423
421
& NetAddress :: IPv6 { ..} => { 2 } ,
424
- & NetAddress :: OnionV2 { .. } => { 3 } ,
422
+ & NetAddress :: OnionV2 ( _ ) => { 3 } ,
425
423
& NetAddress :: OnionV3 { ..} => { 4 } ,
426
424
}
427
425
}
@@ -431,7 +429,7 @@ impl NetAddress {
431
429
match self {
432
430
& NetAddress :: IPv4 { .. } => { 6 } ,
433
431
& NetAddress :: IPv6 { .. } => { 18 } ,
434
- & NetAddress :: OnionV2 { .. } => { 12 } ,
432
+ & NetAddress :: OnionV2 ( _ ) => { 12 } ,
435
433
& NetAddress :: OnionV3 { .. } => { 37 } ,
436
434
}
437
435
}
@@ -453,10 +451,9 @@ impl Writeable for NetAddress {
453
451
addr. write ( writer) ?;
454
452
port. write ( writer) ?;
455
453
} ,
456
- & NetAddress :: OnionV2 { ref addr , ref port } => {
454
+ & NetAddress :: OnionV2 ( bytes ) => {
457
455
3u8 . write ( writer) ?;
458
- addr. write ( writer) ?;
459
- port. write ( writer) ?;
456
+ bytes. write ( writer) ?;
460
457
} ,
461
458
& NetAddress :: OnionV3 { ref ed25519_pubkey, ref checksum, ref version, ref port } => {
462
459
4u8 . write ( writer) ?;
@@ -486,12 +483,7 @@ impl Readable for Result<NetAddress, u8> {
486
483
port : Readable :: read ( reader) ?,
487
484
} ) )
488
485
} ,
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) ?) ) ) ,
495
487
4 => {
496
488
Ok ( Ok ( NetAddress :: OnionV3 {
497
489
ed25519_pubkey : Readable :: read ( reader) ?,
@@ -1922,10 +1914,9 @@ mod tests {
1922
1914
} ) ;
1923
1915
}
1924
1916
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
+ ) ) ;
1929
1920
}
1930
1921
if onionv3 {
1931
1922
addresses. push ( msgs:: NetAddress :: OnionV3 {
0 commit comments