@@ -545,6 +545,11 @@ pub enum NetAddress {
545
545
/// The port on which the node is listening.
546
546
port : u16 ,
547
547
} ,
548
+ /// A websocket address/port on which the peer is listening.
549
+ Websocket {
550
+ /// The port on which the node is listening.
551
+ port : u16 ,
552
+ } ,
548
553
}
549
554
impl NetAddress {
550
555
/// Gets the ID of this address type. Addresses in [`NodeAnnouncement`] messages should be sorted
@@ -556,6 +561,7 @@ impl NetAddress {
556
561
& NetAddress :: OnionV2 ( _) => { 3 } ,
557
562
& NetAddress :: OnionV3 { ..} => { 4 } ,
558
563
& NetAddress :: Hostname { ..} => { 5 } ,
564
+ & NetAddress :: Websocket { ..} => { 6 } ,
559
565
}
560
566
}
561
567
@@ -568,6 +574,7 @@ impl NetAddress {
568
574
& NetAddress :: OnionV3 { .. } => { 37 } ,
569
575
// Consists of 1-byte hostname length, hostname bytes, and 2-byte port.
570
576
& NetAddress :: Hostname { ref hostname, .. } => { u16:: from ( hostname. len ( ) ) + 3 } ,
577
+ & NetAddress :: Websocket { .. } => { 2 } ,
571
578
}
572
579
}
573
580
@@ -606,6 +613,9 @@ impl Writeable for NetAddress {
606
613
hostname. write ( writer) ?;
607
614
port. write ( writer) ?;
608
615
} ,
616
+ & NetAddress :: Websocket { ref port } => {
617
+ port. write ( writer) ?;
618
+ } ,
609
619
}
610
620
Ok ( ( ) )
611
621
}
@@ -642,6 +652,11 @@ impl Readable for Result<NetAddress, u8> {
642
652
port : Readable :: read ( reader) ?,
643
653
} ) )
644
654
} ,
655
+ 6 => {
656
+ Ok ( Ok ( NetAddress :: Websocket {
657
+ port : Readable :: read ( reader) ?,
658
+ } ) )
659
+ } ,
645
660
_ => return Ok ( Err ( byte) ) ,
646
661
}
647
662
}
0 commit comments