X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=lightning%2Fsrc%2Fln%2Fpeer_handler.rs;h=d12f8c06eed0409630864359e54c20d3b714930d;hb=d0f69f77bd6ed40bff7ef1026f23e4444a5a884a;hp=120a7535a6ed2551ac63662c03042b36933c2d35;hpb=20a81e5c1484dfef0cdf636438889344052cb2b1;p=rust-lightning diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 120a7535..d12f8c06 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -377,6 +377,8 @@ struct PeerHolder { /// lifetimes). Other times you can afford a reference, which is more efficient, in which case /// SimpleRefPeerManager is the more appropriate type. Defining these type aliases prevents /// issues such as overly long function definitions. +/// +/// (C-not exported) as Arcs don't make sense in bindings pub type SimpleArcPeerManager = PeerManager>, Arc, Arc, Arc>>, Arc, Arc>; /// SimpleRefPeerManager is a type alias for a PeerManager reference, and is the reference @@ -385,6 +387,8 @@ pub type SimpleArcPeerManager = PeerManager = PeerManager, &'e NetGraphMsgHandler<&'g NetworkGraph, &'h C, &'f L>, &'f L, IgnoringMessageHandler>; /// A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls @@ -502,21 +506,21 @@ impl core::fmt::Display for OptionalFromDebugger<'_> { fn filter_addresses(ip_address: Option) -> Option { match ip_address{ // For IPv4 range 10.0.0.0 - 10.255.255.255 (10/8) - Some(NetAddress::IPv4{addr: [0xA, 0x00..=0xFF, _, _], port: _}) => None, + Some(NetAddress::IPv4{addr: [10, _, _, _], port: _}) => None, // For IPv4 range 0.0.0.0 - 0.255.255.255 (0/8) - Some(NetAddress::IPv4{addr: [0x0, 0x0..=0xFF, _, _], port: _}) => None, + Some(NetAddress::IPv4{addr: [0, _, _, _], port: _}) => None, // For IPv4 range 100.64.0.0 - 100.127.255.255 (100.64/10) - Some(NetAddress::IPv4{addr: [0x64, 0x40..=0x7F, _, _], port: _}) => None, + Some(NetAddress::IPv4{addr: [100, 64..=127, _, _], port: _}) => None, // For IPv4 range 127.0.0.0 - 127.255.255.255 (127/8) - Some(NetAddress::IPv4{addr: [0x7F, 0x0..=0xFF, _, _], port: _}) => None, + Some(NetAddress::IPv4{addr: [127, _, _, _], port: _}) => None, // For IPv4 range 169.254.0.0 - 169.254.255.255 (169.254/16) - Some(NetAddress::IPv4{addr: [0xA9, 0xFE, _, _], port: _}) => None, + Some(NetAddress::IPv4{addr: [169, 254, _, _], port: _}) => None, // For IPv4 range 172.16.0.0 - 172.31.255.255 (172.16/12) - Some(NetAddress::IPv4{addr: [0xAC, 0x10..=0x1F, _, _], port: _}) => None, + Some(NetAddress::IPv4{addr: [172, 16..=31, _, _], port: _}) => None, // For IPv4 range 192.168.0.0 - 192.168.255.255 (192.168/16) - Some(NetAddress::IPv4{addr: [0xC0, 0xA8, _, _], port: _}) => None, + Some(NetAddress::IPv4{addr: [192, 168, _, _], port: _}) => None, // For IPv4 range 192.88.99.0 - 192.88.99.255 (192.88.99/24) - Some(NetAddress::IPv4{addr: [0xC0, 0x58, 0x63, _], port: _}) => None, + Some(NetAddress::IPv4{addr: [192, 88, 99, _], port: _}) => None, // For IPv6 range 2000:0000:0000:0000:0000:0000:0000:0000 - 3fff:ffff:ffff:ffff:ffff:ffff:ffff:ffff (2000::/3) Some(NetAddress::IPv6{addr: [0x20..=0x3F, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], port: _}) => ip_address, // For remaining addresses @@ -576,9 +580,10 @@ impl P /// Indicates a new outbound connection has been established to a node with the given node_id /// and an optional remote network address. + /// /// The remote network address adds the option to report a remote IP address back to a connecting - /// peer using the init message. - /// The user should pass the remote network address to whatever host they are connected to. + /// peer using the init message. + /// The user should pass the remote network address of the host they are connected to. /// /// Note that if an Err is returned here you MUST NOT call socket_disconnected for the new /// descriptor but must disconnect the connection immediately. @@ -623,6 +628,10 @@ impl P /// Indicates a new inbound connection has been established to a node with an optional remote /// network address. /// + /// The remote network address adds the option to report a remote IP address back to a connecting + /// peer using the init message. + /// The user should pass the remote network address of the host they are connected to. + /// /// May refuse the connection by returning an Err, but will never write bytes to the remote end /// (outbound connector always speaks first). Note that if an Err is returned here you MUST NOT /// call socket_disconnected for the new descriptor but must disconnect the connection @@ -903,7 +912,7 @@ impl P peer.their_node_id = Some(their_node_id); insert_node_id!(); let features = InitFeatures::known(); - let resp = msgs::Init { features, remote_network_address: filter_addresses(peer.their_net_address.clone())}; + let resp = msgs::Init { features, remote_network_address: filter_addresses(peer.their_net_address.clone())}; self.enqueue_message(peer, &resp); peer.awaiting_pong_timer_tick_intervals = 0; }, @@ -914,7 +923,7 @@ impl P peer.their_node_id = Some(their_node_id); insert_node_id!(); let features = InitFeatures::known(); - let resp = msgs::Init { features, remote_network_address: filter_addresses(peer.their_net_address.clone())}; + let resp = msgs::Init { features, remote_network_address: filter_addresses(peer.their_net_address.clone())}; self.enqueue_message(peer, &resp); peer.awaiting_pong_timer_tick_intervals = 0; },