@@ -98,7 +98,7 @@ pub struct Init {
9898 /// message. A node can decide to use that information to discover a potential update to its
9999 /// public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing
100100 /// the new address.
101- pub remote_network_address : Option < NetAddress > ,
101+ pub remote_network_address : Option < SocketAddress > ,
102102}
103103
104104/// An [`error`] message to be sent to or received from a peer.
@@ -746,16 +746,16 @@ pub struct AnnouncementSignatures {
746746
747747/// An address which can be used to connect to a remote peer.
748748#[ derive( Clone , Debug , PartialEq , Eq ) ]
749- pub enum NetAddress {
750- /// An IPv4 address/ port on which the peer is listening.
751- IPv4 {
749+ pub enum SocketAddress {
750+ /// An IPv4 address and port on which the peer is listening.
751+ TcpIpV4 {
752752 /// The 4-byte IPv4 address
753753 addr : [ u8 ; 4 ] ,
754754 /// The port on which the node is listening
755755 port : u16 ,
756756 } ,
757- /// An IPv6 address/ port on which the peer is listening.
758- IPv6 {
757+ /// An IPv6 address and port on which the peer is listening.
758+ TcpIpV6 {
759759 /// The 16-byte IPv6 address
760760 addr : [ u8 ; 16 ] ,
761761 /// The port on which the node is listening
@@ -788,28 +788,28 @@ pub enum NetAddress {
788788 port : u16 ,
789789 } ,
790790}
791- impl NetAddress {
791+ impl SocketAddress {
792792 /// Gets the ID of this address type. Addresses in [`NodeAnnouncement`] messages should be sorted
793793 /// by this.
794794 pub ( crate ) fn get_id ( & self ) -> u8 {
795795 match self {
796- & NetAddress :: IPv4 { ..} => { 1 } ,
797- & NetAddress :: IPv6 { ..} => { 2 } ,
798- & NetAddress :: OnionV2 ( _) => { 3 } ,
799- & NetAddress :: OnionV3 { ..} => { 4 } ,
800- & NetAddress :: Hostname { ..} => { 5 } ,
796+ & SocketAddress :: IPv4 { ..} => { 1 } ,
797+ & SocketAddress :: IPv6 { ..} => { 2 } ,
798+ & SocketAddress :: OnionV2 ( _) => { 3 } ,
799+ & SocketAddress :: OnionV3 { ..} => { 4 } ,
800+ & SocketAddress :: Hostname { ..} => { 5 } ,
801801 }
802802 }
803803
804804 /// Strict byte-length of address descriptor, 1-byte type not recorded
805805 fn len ( & self ) -> u16 {
806806 match self {
807- & NetAddress :: IPv4 { .. } => { 6 } ,
808- & NetAddress :: IPv6 { .. } => { 18 } ,
809- & NetAddress :: OnionV2 ( _) => { 12 } ,
810- & NetAddress :: OnionV3 { .. } => { 37 } ,
807+ & SocketAddress :: IPv4 { .. } => { 6 } ,
808+ & SocketAddress :: IPv6 { .. } => { 18 } ,
809+ & SocketAddress :: OnionV2 ( _) => { 12 } ,
810+ & SocketAddress :: OnionV3 { .. } => { 37 } ,
811811 // Consists of 1-byte hostname length, hostname bytes, and 2-byte port.
812- & NetAddress :: Hostname { ref hostname, .. } => { u16:: from ( hostname. len ( ) ) + 3 } ,
812+ & SocketAddress :: Hostname { ref hostname, .. } => { u16:: from ( hostname. len ( ) ) + 3 } ,
813813 }
814814 }
815815
@@ -819,31 +819,31 @@ impl NetAddress {
819819 pub ( crate ) const MAX_LEN : u16 = 258 ;
820820}
821821
822- impl Writeable for NetAddress {
822+ impl Writeable for SocketAddress {
823823 fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
824824 match self {
825- & NetAddress :: IPv4 { ref addr, ref port } => {
825+ & SocketAddress :: IPv4 { ref addr, ref port } => {
826826 1u8 . write ( writer) ?;
827827 addr. write ( writer) ?;
828828 port. write ( writer) ?;
829829 } ,
830- & NetAddress :: IPv6 { ref addr, ref port } => {
830+ & SocketAddress :: IPv6 { ref addr, ref port } => {
831831 2u8 . write ( writer) ?;
832832 addr. write ( writer) ?;
833833 port. write ( writer) ?;
834834 } ,
835- & NetAddress :: OnionV2 ( bytes) => {
835+ & SocketAddress :: OnionV2 ( bytes) => {
836836 3u8 . write ( writer) ?;
837837 bytes. write ( writer) ?;
838838 } ,
839- & NetAddress :: OnionV3 { ref ed25519_pubkey, ref checksum, ref version, ref port } => {
839+ & SocketAddress :: OnionV3 { ref ed25519_pubkey, ref checksum, ref version, ref port } => {
840840 4u8 . write ( writer) ?;
841841 ed25519_pubkey. write ( writer) ?;
842842 checksum. write ( writer) ?;
843843 version. write ( writer) ?;
844844 port. write ( writer) ?;
845845 } ,
846- & NetAddress :: Hostname { ref hostname, ref port } => {
846+ & SocketAddress :: Hostname { ref hostname, ref port } => {
847847 5u8 . write ( writer) ?;
848848 hostname. write ( writer) ?;
849849 port. write ( writer) ?;
@@ -853,33 +853,33 @@ impl Writeable for NetAddress {
853853 }
854854}
855855
856- impl Readable for Result < NetAddress , u8 > {
857- fn read < R : Read > ( reader : & mut R ) -> Result < Result < NetAddress , u8 > , DecodeError > {
856+ impl Readable for Result < SocketAddress , u8 > {
857+ fn read < R : Read > ( reader : & mut R ) -> Result < Result < SocketAddress , u8 > , DecodeError > {
858858 let byte = <u8 as Readable >:: read ( reader) ?;
859859 match byte {
860860 1 => {
861- Ok ( Ok ( NetAddress :: IPv4 {
861+ Ok ( Ok ( SocketAddress :: IPv4 {
862862 addr : Readable :: read ( reader) ?,
863863 port : Readable :: read ( reader) ?,
864864 } ) )
865865 } ,
866866 2 => {
867- Ok ( Ok ( NetAddress :: IPv6 {
867+ Ok ( Ok ( SocketAddress :: IPv6 {
868868 addr : Readable :: read ( reader) ?,
869869 port : Readable :: read ( reader) ?,
870870 } ) )
871871 } ,
872- 3 => Ok ( Ok ( NetAddress :: OnionV2 ( Readable :: read ( reader) ?) ) ) ,
872+ 3 => Ok ( Ok ( SocketAddress :: OnionV2 ( Readable :: read ( reader) ?) ) ) ,
873873 4 => {
874- Ok ( Ok ( NetAddress :: OnionV3 {
874+ Ok ( Ok ( SocketAddress :: OnionV3 {
875875 ed25519_pubkey : Readable :: read ( reader) ?,
876876 checksum : Readable :: read ( reader) ?,
877877 version : Readable :: read ( reader) ?,
878878 port : Readable :: read ( reader) ?,
879879 } ) )
880880 } ,
881881 5 => {
882- Ok ( Ok ( NetAddress :: Hostname {
882+ Ok ( Ok ( SocketAddress :: Hostname {
883883 hostname : Readable :: read ( reader) ?,
884884 port : Readable :: read ( reader) ?,
885885 } ) )
@@ -889,8 +889,8 @@ impl Readable for Result<NetAddress, u8> {
889889 }
890890}
891891
892- impl Readable for NetAddress {
893- fn read < R : Read > ( reader : & mut R ) -> Result < NetAddress , DecodeError > {
892+ impl Readable for SocketAddress {
893+ fn read < R : Read > ( reader : & mut R ) -> Result < SocketAddress , DecodeError > {
894894 match Readable :: read ( reader) {
895895 Ok ( Ok ( res) ) => Ok ( res) ,
896896 Ok ( Err ( _) ) => Err ( DecodeError :: UnknownVersion ) ,
@@ -938,7 +938,7 @@ pub struct UnsignedNodeAnnouncement {
938938 /// This should be sanitized before use. There is no guarantee of uniqueness.
939939 pub alias : NodeAlias ,
940940 /// List of addresses on which this node is reachable
941- pub addresses : Vec < NetAddress > ,
941+ pub addresses : Vec < SocketAddress > ,
942942 pub ( crate ) excess_address_data : Vec < u8 > ,
943943 pub ( crate ) excess_data : Vec < u8 > ,
944944}
@@ -1773,7 +1773,7 @@ impl Readable for Init {
17731773 fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
17741774 let global_features: InitFeatures = Readable :: read ( r) ?;
17751775 let features: InitFeatures = Readable :: read ( r) ?;
1776- let mut remote_network_address: Option < NetAddress > = None ;
1776+ let mut remote_network_address: Option < SocketAddress > = None ;
17771777 let mut networks: Option < WithoutLength < Vec < ChainHash > > > = None ;
17781778 decode_tlv_stream ! ( r, {
17791779 ( 1 , networks, option) ,
@@ -2272,7 +2272,7 @@ impl Readable for UnsignedNodeAnnouncement {
22722272 let alias: NodeAlias = Readable :: read ( r) ?;
22732273
22742274 let addr_len: u16 = Readable :: read ( r) ?;
2275- let mut addresses: Vec < NetAddress > = Vec :: new ( ) ;
2275+ let mut addresses: Vec < SocketAddress > = Vec :: new ( ) ;
22762276 let mut addr_readpos = 0 ;
22772277 let mut excess = false ;
22782278 let mut excess_byte = 0 ;
@@ -2663,32 +2663,32 @@ mod tests {
26632663 } ;
26642664 let mut addresses = Vec :: new ( ) ;
26652665 if ipv4 {
2666- addresses. push ( msgs:: NetAddress :: IPv4 {
2666+ addresses. push ( msgs:: SocketAddress :: IPv4 {
26672667 addr : [ 255 , 254 , 253 , 252 ] ,
26682668 port : 9735
26692669 } ) ;
26702670 }
26712671 if ipv6 {
2672- addresses. push ( msgs:: NetAddress :: IPv6 {
2672+ addresses. push ( msgs:: SocketAddress :: IPv6 {
26732673 addr : [ 255 , 254 , 253 , 252 , 251 , 250 , 249 , 248 , 247 , 246 , 245 , 244 , 243 , 242 , 241 , 240 ] ,
26742674 port : 9735
26752675 } ) ;
26762676 }
26772677 if onionv2 {
2678- addresses. push ( msgs:: NetAddress :: OnionV2 (
2678+ addresses. push ( msgs:: SocketAddress :: OnionV2 (
26792679 [ 255 , 254 , 253 , 252 , 251 , 250 , 249 , 248 , 247 , 246 , 38 , 7 ]
26802680 ) ) ;
26812681 }
26822682 if onionv3 {
2683- addresses. push ( msgs:: NetAddress :: OnionV3 {
2683+ addresses. push ( msgs:: SocketAddress :: OnionV3 {
26842684 ed25519_pubkey : [ 255 , 254 , 253 , 252 , 251 , 250 , 249 , 248 , 247 , 246 , 245 , 244 , 243 , 242 , 241 , 240 , 239 , 238 , 237 , 236 , 235 , 234 , 233 , 232 , 231 , 230 , 229 , 228 , 227 , 226 , 225 , 224 ] ,
26852685 checksum : 32 ,
26862686 version : 16 ,
26872687 port : 9735
26882688 } ) ;
26892689 }
26902690 if hostname {
2691- addresses. push ( msgs:: NetAddress :: Hostname {
2691+ addresses. push ( msgs:: SocketAddress :: Hostname {
26922692 hostname : Hostname :: try_from ( String :: from ( "host" ) ) . unwrap ( ) ,
26932693 port : 9735 ,
26942694 } ) ;
@@ -3504,7 +3504,7 @@ mod tests {
35043504 } . encode( ) , hex:: decode( "00000000014001010101010101010101010101010101010101010101010101010101010101010202020202020202020202020202020202020202020202020202020202020202" ) . unwrap( ) ) ;
35053505 let init_msg = msgs:: Init { features : InitFeatures :: from_le_bytes ( vec ! [ ] ) ,
35063506 networks : Some ( vec ! [ mainnet_hash] ) ,
3507- remote_network_address : Some ( msgs:: NetAddress :: IPv4 {
3507+ remote_network_address : Some ( msgs:: SocketAddress :: IPv4 {
35083508 addr : [ 127 , 0 , 0 , 1 ] ,
35093509 port : 1000 ,
35103510 } ) ,
0 commit comments