projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix anchor output matching
[rust-lightning]
/
lightning
/
src
/
ln
/
peer_handler.rs
diff --git
a/lightning/src/ln/peer_handler.rs
b/lightning/src/ln/peer_handler.rs
index 1a39bbb3ae408e7047159e6d9f3f63267188b61f..1e0294073a25d2b01b470bbbbad16d9f9ab3d305 100644
(file)
--- a/
lightning/src/ln/peer_handler.rs
+++ b/
lightning/src/ln/peer_handler.rs
@@
-20,9
+20,10
@@
use bitcoin::secp256k1::{self, Secp256k1, SecretKey, PublicKey};
use crate::sign::{KeysManager, NodeSigner, Recipient};
use crate::events::{MessageSendEvent, MessageSendEventsProvider, OnionMessageProvider};
use crate::sign::{KeysManager, NodeSigner, Recipient};
use crate::events::{MessageSendEvent, MessageSendEventsProvider, OnionMessageProvider};
+use crate::ln::ChannelId;
use crate::ln::features::{InitFeatures, NodeFeatures};
use crate::ln::msgs;
use crate::ln::features::{InitFeatures, NodeFeatures};
use crate::ln::msgs;
-use crate::ln::msgs::{ChannelMessageHandler, LightningError,
N
etAddress, OnionMessageHandler, RoutingMessageHandler};
+use crate::ln::msgs::{ChannelMessageHandler, LightningError,
Sock
etAddress, OnionMessageHandler, RoutingMessageHandler};
use crate::ln::channelmanager::{SimpleArcChannelManager, SimpleRefChannelManager};
use crate::util::ser::{VecWriter, Writeable, Writer};
use crate::ln::peer_channel_encryptor::{PeerChannelEncryptor,NextNoiseStep};
use crate::ln::channelmanager::{SimpleArcChannelManager, SimpleRefChannelManager};
use crate::util::ser::{VecWriter, Writeable, Writer};
use crate::ln::peer_channel_encryptor::{PeerChannelEncryptor,NextNoiseStep};
@@
-186,7
+187,7
@@
impl ErroringMessageHandler {
pub fn new() -> Self {
Self { message_queue: Mutex::new(Vec::new()) }
}
pub fn new() -> Self {
Self { message_queue: Mutex::new(Vec::new()) }
}
- fn push_error(&self, node_id: &PublicKey, channel_id:
[u8; 32]
) {
+ fn push_error(&self, node_id: &PublicKey, channel_id:
ChannelId
) {
self.message_queue.lock().unwrap().push(MessageSendEvent::HandleError {
action: msgs::ErrorAction::SendErrorMessage {
msg: msgs::ErrorMessage { channel_id, data: "We do not support channel messages, sorry.".to_owned() },
self.message_queue.lock().unwrap().push(MessageSendEvent::HandleError {
action: msgs::ErrorAction::SendErrorMessage {
msg: msgs::ErrorMessage { channel_id, data: "We do not support channel messages, sorry.".to_owned() },
@@
-482,7
+483,7
@@
struct Peer {
/// handshake and can talk to this peer normally (though use [`Peer::handshake_complete`] to
/// check this.
their_features: Option<InitFeatures>,
/// handshake and can talk to this peer normally (though use [`Peer::handshake_complete`] to
/// check this.
their_features: Option<InitFeatures>,
- their_
net_address: Option<N
etAddress>,
+ their_
socket_address: Option<Sock
etAddress>,
pending_outbound_buffer: LinkedList<Vec<u8>>,
pending_outbound_buffer_first_msg_offset: usize,
pending_outbound_buffer: LinkedList<Vec<u8>>,
pending_outbound_buffer_first_msg_offset: usize,
@@
-854,28
+855,28
@@
impl core::fmt::Display for OptionalFromDebugger<'_> {
/// A function used to filter out local or private addresses
/// <https://www.iana.org./assignments/ipv4-address-space/ipv4-address-space.xhtml>
/// <https://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xhtml>
/// A function used to filter out local or private addresses
/// <https://www.iana.org./assignments/ipv4-address-space/ipv4-address-space.xhtml>
/// <https://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xhtml>
-fn filter_addresses(ip_address: Option<
NetAddress>) -> Option<N
etAddress> {
+fn filter_addresses(ip_address: Option<
SocketAddress>) -> Option<Sock
etAddress> {
match ip_address{
// For IPv4 range 10.0.0.0 - 10.255.255.255 (10/8)
match ip_address{
// For IPv4 range 10.0.0.0 - 10.255.255.255 (10/8)
- Some(
NetAddress::IPv
4{addr: [10, _, _, _], port: _}) => None,
+ Some(
SocketAddress::TcpIpV
4{addr: [10, _, _, _], port: _}) => None,
// For IPv4 range 0.0.0.0 - 0.255.255.255 (0/8)
// For IPv4 range 0.0.0.0 - 0.255.255.255 (0/8)
- Some(
NetAddress::IPv
4{addr: [0, _, _, _], port: _}) => None,
+ Some(
SocketAddress::TcpIpV
4{addr: [0, _, _, _], port: _}) => None,
// For IPv4 range 100.64.0.0 - 100.127.255.255 (100.64/10)
// For IPv4 range 100.64.0.0 - 100.127.255.255 (100.64/10)
- Some(
NetAddress::IPv
4{addr: [100, 64..=127, _, _], port: _}) => None,
+ Some(
SocketAddress::TcpIpV
4{addr: [100, 64..=127, _, _], port: _}) => None,
// For IPv4 range 127.0.0.0 - 127.255.255.255 (127/8)
// For IPv4 range 127.0.0.0 - 127.255.255.255 (127/8)
- Some(
NetAddress::IPv
4{addr: [127, _, _, _], port: _}) => None,
+ Some(
SocketAddress::TcpIpV
4{addr: [127, _, _, _], port: _}) => None,
// For IPv4 range 169.254.0.0 - 169.254.255.255 (169.254/16)
// For IPv4 range 169.254.0.0 - 169.254.255.255 (169.254/16)
- Some(
NetAddress::IPv
4{addr: [169, 254, _, _], port: _}) => None,
+ Some(
SocketAddress::TcpIpV
4{addr: [169, 254, _, _], port: _}) => None,
// For IPv4 range 172.16.0.0 - 172.31.255.255 (172.16/12)
// For IPv4 range 172.16.0.0 - 172.31.255.255 (172.16/12)
- Some(
NetAddress::IPv
4{addr: [172, 16..=31, _, _], port: _}) => None,
+ Some(
SocketAddress::TcpIpV
4{addr: [172, 16..=31, _, _], port: _}) => None,
// For IPv4 range 192.168.0.0 - 192.168.255.255 (192.168/16)
// For IPv4 range 192.168.0.0 - 192.168.255.255 (192.168/16)
- Some(
NetAddress::IPv
4{addr: [192, 168, _, _], port: _}) => None,
+ Some(
SocketAddress::TcpIpV
4{addr: [192, 168, _, _], port: _}) => None,
// For IPv4 range 192.88.99.0 - 192.88.99.255 (192.88.99/24)
// For IPv4 range 192.88.99.0 - 192.88.99.255 (192.88.99/24)
- Some(
NetAddress::IPv
4{addr: [192, 88, 99, _], port: _}) => None,
+ Some(
SocketAddress::TcpIpV
4{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)
// For IPv6 range 2000:0000:0000:0000:0000:0000:0000:0000 - 3fff:ffff:ffff:ffff:ffff:ffff:ffff:ffff (2000::/3)
- Some(
NetAddress::IPv
6{addr: [0x20..=0x3F, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], port: _}) => ip_address,
+ Some(
SocketAddress::TcpIpV
6{addr: [0x20..=0x3F, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _], port: _}) => ip_address,
// For remaining addresses
// For remaining addresses
- Some(
NetAddress::IPv
6{addr: _, port: _}) => None,
+ Some(
SocketAddress::TcpIpV
6{addr: _, port: _}) => None,
Some(..) => ip_address,
None => None,
}
Some(..) => ip_address,
None => None,
}
@@
-932,14
+933,14
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
///
/// The returned `Option`s will only be `Some` if an address had been previously given via
/// [`Self::new_outbound_connection`] or [`Self::new_inbound_connection`].
///
/// The returned `Option`s will only be `Some` if an address had been previously given via
/// [`Self::new_outbound_connection`] or [`Self::new_inbound_connection`].
- pub fn get_peer_node_ids(&self) -> Vec<(PublicKey, Option<
N
etAddress>)> {
+ pub fn get_peer_node_ids(&self) -> Vec<(PublicKey, Option<
Sock
etAddress>)> {
let peers = self.peers.read().unwrap();
peers.values().filter_map(|peer_mutex| {
let p = peer_mutex.lock().unwrap();
if !p.handshake_complete() {
return None;
}
let peers = self.peers.read().unwrap();
peers.values().filter_map(|peer_mutex| {
let p = peer_mutex.lock().unwrap();
if !p.handshake_complete() {
return None;
}
- Some((p.their_node_id.unwrap().0, p.their_
n
et_address.clone()))
+ Some((p.their_node_id.unwrap().0, p.their_
sock
et_address.clone()))
}).collect()
}
}).collect()
}
@@
-972,7
+973,7
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
/// [`socket_disconnected`].
///
/// [`socket_disconnected`]: PeerManager::socket_disconnected
/// [`socket_disconnected`].
///
/// [`socket_disconnected`]: PeerManager::socket_disconnected
- pub fn new_outbound_connection(&self, their_node_id: PublicKey, descriptor: Descriptor, remote_network_address: Option<
N
etAddress>) -> Result<Vec<u8>, PeerHandleError> {
+ pub fn new_outbound_connection(&self, their_node_id: PublicKey, descriptor: Descriptor, remote_network_address: Option<
Sock
etAddress>) -> Result<Vec<u8>, PeerHandleError> {
let mut peer_encryptor = PeerChannelEncryptor::new_outbound(their_node_id.clone(), self.get_ephemeral_key());
let res = peer_encryptor.get_act_one(&self.secp_ctx).to_vec();
let pending_read_buffer = [0; 50].to_vec(); // Noise act two is 50 bytes
let mut peer_encryptor = PeerChannelEncryptor::new_outbound(their_node_id.clone(), self.get_ephemeral_key());
let res = peer_encryptor.get_act_one(&self.secp_ctx).to_vec();
let pending_read_buffer = [0; 50].to_vec(); // Noise act two is 50 bytes
@@
-988,7
+989,7
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
channel_encryptor: peer_encryptor,
their_node_id: None,
their_features: None,
channel_encryptor: peer_encryptor,
their_node_id: None,
their_features: None,
- their_
n
et_address: remote_network_address,
+ their_
sock
et_address: remote_network_address,
pending_outbound_buffer: LinkedList::new(),
pending_outbound_buffer_first_msg_offset: 0,
pending_outbound_buffer: LinkedList::new(),
pending_outbound_buffer_first_msg_offset: 0,
@@
-1029,7
+1030,7
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
/// [`socket_disconnected`].
///
/// [`socket_disconnected`]: PeerManager::socket_disconnected
/// [`socket_disconnected`].
///
/// [`socket_disconnected`]: PeerManager::socket_disconnected
- pub fn new_inbound_connection(&self, descriptor: Descriptor, remote_network_address: Option<
N
etAddress>) -> Result<(), PeerHandleError> {
+ pub fn new_inbound_connection(&self, descriptor: Descriptor, remote_network_address: Option<
Sock
etAddress>) -> Result<(), PeerHandleError> {
let peer_encryptor = PeerChannelEncryptor::new_inbound(&self.node_signer);
let pending_read_buffer = [0; 50].to_vec(); // Noise act one is 50 bytes
let peer_encryptor = PeerChannelEncryptor::new_inbound(&self.node_signer);
let pending_read_buffer = [0; 50].to_vec(); // Noise act one is 50 bytes
@@
-1044,7
+1045,7
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
channel_encryptor: peer_encryptor,
their_node_id: None,
their_features: None,
channel_encryptor: peer_encryptor,
their_node_id: None,
their_features: None,
- their_
n
et_address: remote_network_address,
+ their_
sock
et_address: remote_network_address,
pending_outbound_buffer: LinkedList::new(),
pending_outbound_buffer_first_msg_offset: 0,
pending_outbound_buffer: LinkedList::new(),
pending_outbound_buffer_first_msg_offset: 0,
@@
-1367,7
+1368,7
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
insert_node_id!();
let features = self.init_features(&their_node_id);
let networks = self.message_handler.chan_handler.get_genesis_hashes();
insert_node_id!();
let features = self.init_features(&their_node_id);
let networks = self.message_handler.chan_handler.get_genesis_hashes();
- let resp = msgs::Init { features, networks, remote_network_address: filter_addresses(peer.their_
n
et_address.clone()) };
+ let resp = msgs::Init { features, networks, remote_network_address: filter_addresses(peer.their_
sock
et_address.clone()) };
self.enqueue_message(peer, &resp);
peer.awaiting_pong_timer_tick_intervals = 0;
},
self.enqueue_message(peer, &resp);
peer.awaiting_pong_timer_tick_intervals = 0;
},
@@
-1380,7
+1381,7
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
insert_node_id!();
let features = self.init_features(&their_node_id);
let networks = self.message_handler.chan_handler.get_genesis_hashes();
insert_node_id!();
let features = self.init_features(&their_node_id);
let networks = self.message_handler.chan_handler.get_genesis_hashes();
- let resp = msgs::Init { features, networks, remote_network_address: filter_addresses(peer.their_
n
et_address.clone()) };
+ let resp = msgs::Init { features, networks, remote_network_address: filter_addresses(peer.their_
sock
et_address.clone()) };
self.enqueue_message(peer, &resp);
peer.awaiting_pong_timer_tick_intervals = 0;
},
self.enqueue_message(peer, &resp);
peer.awaiting_pong_timer_tick_intervals = 0;
},
@@
-1420,13
+1421,13
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
}
(msgs::DecodeError::UnsupportedCompression, _) => {
log_gossip!(self.logger, "We don't support zlib-compressed message fields, sending a warning and ignoring message");
}
(msgs::DecodeError::UnsupportedCompression, _) => {
log_gossip!(self.logger, "We don't support zlib-compressed message fields, sending a warning and ignoring message");
- self.enqueue_message(peer, &msgs::WarningMessage { channel_id:
[0; 32]
, data: "Unsupported message compression: zlib".to_owned() });
+ self.enqueue_message(peer, &msgs::WarningMessage { channel_id:
ChannelId::new_zero()
, data: "Unsupported message compression: zlib".to_owned() });
continue;
}
(_, Some(ty)) if is_gossip_msg(ty) => {
log_gossip!(self.logger, "Got an invalid value while deserializing a gossip message");
self.enqueue_message(peer, &msgs::WarningMessage {
continue;
}
(_, Some(ty)) if is_gossip_msg(ty) => {
log_gossip!(self.logger, "Got an invalid value while deserializing a gossip message");
self.enqueue_message(peer, &msgs::WarningMessage {
- channel_id:
[0; 32]
,
+ channel_id:
ChannelId::new_zero()
,
data: format!("Unreadable/bogus gossip message of type {}", ty),
});
continue;
data: format!("Unreadable/bogus gossip message of type {}", ty),
});
continue;
@@
-1592,7
+1593,7
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
wire::Message::Error(msg) => {
log_debug!(self.logger, "Got Err message from {}: {}", log_pubkey!(their_node_id), PrintableString(&msg.data));
self.message_handler.chan_handler.handle_error(&their_node_id, &msg);
wire::Message::Error(msg) => {
log_debug!(self.logger, "Got Err message from {}: {}", log_pubkey!(their_node_id), PrintableString(&msg.data));
self.message_handler.chan_handler.handle_error(&their_node_id, &msg);
- if msg.channel_id
== [0; 32]
{
+ if msg.channel_id
.is_zero()
{
return Err(PeerHandleError { }.into());
}
},
return Err(PeerHandleError { }.into());
}
},
@@
-1913,31
+1914,31
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
MessageSendEvent::SendAcceptChannel { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendAcceptChannel event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
MessageSendEvent::SendAcceptChannel { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendAcceptChannel event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.temporary_channel_id)
);
+
&msg.temporary_channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendAcceptChannelV2 { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendAcceptChannelV2 event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendAcceptChannelV2 { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendAcceptChannelV2 event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.temporary_channel_id)
);
+
&msg.temporary_channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendOpenChannel { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendOpenChannel event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendOpenChannel { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendOpenChannel event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.temporary_channel_id)
);
+
&msg.temporary_channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendOpenChannelV2 { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendOpenChannelV2 event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendOpenChannelV2 { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendOpenChannelV2 event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.temporary_channel_id)
);
+
&msg.temporary_channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendFundingCreated { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendFundingCreated event in peer_handler for node {} for channel {} (which becomes {})",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendFundingCreated { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendFundingCreated event in peer_handler for node {} for channel {} (which becomes {})",
log_pubkey!(node_id),
-
log_bytes!(msg.temporary_channel_id)
,
+
&msg.temporary_channel_id
,
log_funding_channel_id!(msg.funding_txid, msg.funding_output_index));
// TODO: If the peer is gone we should generate a DiscardFunding event
// indicating to the wallet that they should just throw away this funding transaction
log_funding_channel_id!(msg.funding_txid, msg.funding_output_index));
// TODO: If the peer is gone we should generate a DiscardFunding event
// indicating to the wallet that they should just throw away this funding transaction
@@
-1946,73
+1947,73
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
MessageSendEvent::SendFundingSigned { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendFundingSigned event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
MessageSendEvent::SendFundingSigned { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendFundingSigned event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendChannelReady { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendChannelReady event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendChannelReady { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendChannelReady event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxAddInput { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxAddInput event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxAddInput { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxAddInput event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxAddOutput { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxAddOutput event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxAddOutput { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxAddOutput event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxRemoveInput { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxRemoveInput event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxRemoveInput { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxRemoveInput event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxRemoveOutput { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxRemoveOutput event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxRemoveOutput { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxRemoveOutput event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxComplete { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxComplete event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxComplete { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxComplete event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxSignatures { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxSignatures event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxSignatures { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxSignatures event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxInitRbf { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxInitRbf event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxInitRbf { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxInitRbf event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxAckRbf { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxAckRbf event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxAckRbf { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxAckRbf event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxAbort { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxAbort event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendTxAbort { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendTxAbort event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendAnnouncementSignatures { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendAnnouncementSignatures event in peer_handler for node {} for channel {})",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendAnnouncementSignatures { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendAnnouncementSignatures event in peer_handler for node {} for channel {})",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::UpdateHTLCs { ref node_id, updates: msgs::CommitmentUpdate { ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs, ref update_fail_malformed_htlcs, ref update_fee, ref commitment_signed } } => {
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::UpdateHTLCs { ref node_id, updates: msgs::CommitmentUpdate { ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs, ref update_fail_malformed_htlcs, ref update_fee, ref commitment_signed } } => {
@@
-2021,7
+2022,7
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
update_add_htlcs.len(),
update_fulfill_htlcs.len(),
update_fail_htlcs.len(),
update_add_htlcs.len(),
update_fulfill_htlcs.len(),
update_fail_htlcs.len(),
-
log_bytes!(commitment_signed.channel_id)
);
+
&commitment_signed.channel_id
);
let mut peer = get_peer_for_forwarding!(node_id);
for msg in update_add_htlcs {
self.enqueue_message(&mut *peer, msg);
let mut peer = get_peer_for_forwarding!(node_id);
for msg in update_add_htlcs {
self.enqueue_message(&mut *peer, msg);
@@
-2043,25
+2044,25
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
MessageSendEvent::SendRevokeAndACK { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendRevokeAndACK event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
MessageSendEvent::SendRevokeAndACK { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendRevokeAndACK event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendClosingSigned { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendClosingSigned event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendClosingSigned { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendClosingSigned event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendShutdown { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling Shutdown event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendShutdown { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling Shutdown event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendChannelReestablish { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendChannelReestablish event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendChannelReestablish { ref node_id, ref msg } => {
log_debug!(self.logger, "Handling SendChannelReestablish event in peer_handler for node {} for channel {}",
log_pubkey!(node_id),
-
log_bytes!(msg.channel_id)
);
+
&msg.channel_id
);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendChannelAnnouncement { ref node_id, ref msg, ref update_msg } => {
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
MessageSendEvent::SendChannelAnnouncement { ref node_id, ref msg, ref update_msg } => {
@@
-2087,7
+2088,7
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
}
},
MessageSendEvent::BroadcastChannelUpdate { msg } => {
}
},
MessageSendEvent::BroadcastChannelUpdate { msg } => {
- log_debug!(self.logger, "Handling BroadcastChannelUpdate event in peer_handler for
short channel id {}", msg.contents.short_channel_id
);
+ log_debug!(self.logger, "Handling BroadcastChannelUpdate event in peer_handler for
contents {:?}", msg.contents
);
match self.message_handler.route_handler.handle_channel_update(&msg) {
Ok(_) | Err(LightningError { action: msgs::ErrorAction::IgnoreDuplicateGossip, .. }) =>
self.forward_broadcast_msg(peers, &wire::Message::ChannelUpdate(msg), None),
match self.message_handler.route_handler.handle_channel_update(&msg) {
Ok(_) | Err(LightningError { action: msgs::ErrorAction::IgnoreDuplicateGossip, .. }) =>
self.forward_broadcast_msg(peers, &wire::Message::ChannelUpdate(msg), None),
@@
-2398,7
+2399,7
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
// be absurd. We ensure this by checking that at least 100 (our stated public contract on when
// broadcast_node_announcement panics) of the maximum-length addresses would fit in a 64KB
// message...
// be absurd. We ensure this by checking that at least 100 (our stated public contract on when
// broadcast_node_announcement panics) of the maximum-length addresses would fit in a 64KB
// message...
- const HALF_MESSAGE_IS_ADDRS: u32 = ::core::u16::MAX as u32 / (
N
etAddress::MAX_LEN as u32 + 1) / 2;
+ const HALF_MESSAGE_IS_ADDRS: u32 = ::core::u16::MAX as u32 / (
Sock
etAddress::MAX_LEN as u32 + 1) / 2;
#[deny(const_err)]
#[allow(dead_code)]
// ...by failing to compile if the number of addresses that would be half of a message is
#[deny(const_err)]
#[allow(dead_code)]
// ...by failing to compile if the number of addresses that would be half of a message is
@@
-2420,7
+2421,7
@@
impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
/// Panics if `addresses` is absurdly large (more than 100).
///
/// [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
/// Panics if `addresses` is absurdly large (more than 100).
///
/// [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events
- pub fn broadcast_node_announcement(&self, rgb: [u8; 3], alias: [u8; 32], mut addresses: Vec<
N
etAddress>) {
+ pub fn broadcast_node_announcement(&self, rgb: [u8; 3], alias: [u8; 32], mut addresses: Vec<
Sock
etAddress>) {
if addresses.len() > 100 {
panic!("More than half the message size was taken up by public addresses!");
}
if addresses.len() > 100 {
panic!("More than half the message size was taken up by public addresses!");
}
@@
-2482,11
+2483,12
@@
mod tests {
use crate::sign::{NodeSigner, Recipient};
use crate::events;
use crate::io;
use crate::sign::{NodeSigner, Recipient};
use crate::events;
use crate::io;
+ use crate::ln::ChannelId;
use crate::ln::features::{InitFeatures, NodeFeatures};
use crate::ln::peer_channel_encryptor::PeerChannelEncryptor;
use crate::ln::peer_handler::{CustomMessageHandler, PeerManager, MessageHandler, SocketDescriptor, IgnoringMessageHandler, filter_addresses};
use crate::ln::{msgs, wire};
use crate::ln::features::{InitFeatures, NodeFeatures};
use crate::ln::peer_channel_encryptor::PeerChannelEncryptor;
use crate::ln::peer_handler::{CustomMessageHandler, PeerManager, MessageHandler, SocketDescriptor, IgnoringMessageHandler, filter_addresses};
use crate::ln::{msgs, wire};
- use crate::ln::msgs::{LightningError,
N
etAddress};
+ use crate::ln::msgs::{LightningError,
Sock
etAddress};
use crate::util::test_utils;
use bitcoin::Network;
use crate::util::test_utils;
use bitcoin::Network;
@@
-2645,13
+2647,13
@@
mod tests {
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
- let addr_a =
NetAddress::IPv
4{addr: [127, 0, 0, 1], port: 1000};
+ let addr_a =
SocketAddress::TcpIpV
4{addr: [127, 0, 0, 1], port: 1000};
let id_b = peer_b.node_signer.get_node_id(Recipient::Node).unwrap();
let mut fd_b = FileDescriptor {
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
let id_b = peer_b.node_signer.get_node_id(Recipient::Node).unwrap();
let mut fd_b = FileDescriptor {
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
- let addr_b =
NetAddress::IPv
4{addr: [127, 0, 0, 1], port: 1001};
+ let addr_b =
SocketAddress::TcpIpV
4{addr: [127, 0, 0, 1], port: 1001};
let initial_data = peer_b.new_outbound_connection(id_a, fd_b.clone(), Some(addr_a.clone())).unwrap();
peer_a.new_inbound_connection(fd_a.clone(), Some(addr_b.clone())).unwrap();
assert_eq!(peer_a.read_event(&mut fd_a, &initial_data).unwrap(), false);
let initial_data = peer_b.new_outbound_connection(id_a, fd_b.clone(), Some(addr_a.clone())).unwrap();
peer_a.new_inbound_connection(fd_a.clone(), Some(addr_b.clone())).unwrap();
assert_eq!(peer_a.read_event(&mut fd_a, &initial_data).unwrap(), false);
@@
-2696,12
+2698,12
@@
mod tests {
fd: $id + ctr * 3, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
fd: $id + ctr * 3, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
- let addr_a =
NetAddress::IPv
4{addr: [127, 0, 0, 1], port: 1000};
+ let addr_a =
SocketAddress::TcpIpV
4{addr: [127, 0, 0, 1], port: 1000};
let mut fd_b = FileDescriptor {
fd: $id + ctr * 3, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
let mut fd_b = FileDescriptor {
fd: $id + ctr * 3, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
- let addr_b =
NetAddress::IPv
4{addr: [127, 0, 0, 1], port: 1001};
+ let addr_b =
SocketAddress::TcpIpV
4{addr: [127, 0, 0, 1], port: 1001};
let initial_data = peers[1].new_outbound_connection(id_a, fd_b.clone(), Some(addr_a.clone())).unwrap();
peers[0].new_inbound_connection(fd_a.clone(), Some(addr_b.clone())).unwrap();
if peers[0].read_event(&mut fd_a, &initial_data).is_err() { break; }
let initial_data = peers[1].new_outbound_connection(id_a, fd_b.clone(), Some(addr_a.clone())).unwrap();
peers[0].new_inbound_connection(fd_a.clone(), Some(addr_b.clone())).unwrap();
if peers[0].read_event(&mut fd_a, &initial_data).is_err() { break; }
@@
-2721,7
+2723,7
@@
mod tests {
.push(crate::events::MessageSendEvent::SendShutdown {
node_id: peers[1].node_signer.get_node_id(Recipient::Node).unwrap(),
msg: msgs::Shutdown {
.push(crate::events::MessageSendEvent::SendShutdown {
node_id: peers[1].node_signer.get_node_id(Recipient::Node).unwrap(),
msg: msgs::Shutdown {
- channel_id:
[0; 32]
,
+ channel_id:
ChannelId::new_zero()
,
scriptpubkey: bitcoin::Script::new(),
},
});
scriptpubkey: bitcoin::Script::new(),
},
});
@@
-2729,7
+2731,7
@@
mod tests {
.push(crate::events::MessageSendEvent::SendShutdown {
node_id: peers[0].node_signer.get_node_id(Recipient::Node).unwrap(),
msg: msgs::Shutdown {
.push(crate::events::MessageSendEvent::SendShutdown {
node_id: peers[0].node_signer.get_node_id(Recipient::Node).unwrap(),
msg: msgs::Shutdown {
- channel_id:
[0; 32]
,
+ channel_id:
ChannelId::new_zero()
,
scriptpubkey: bitcoin::Script::new(),
},
});
scriptpubkey: bitcoin::Script::new(),
},
});
@@
-2768,12
+2770,12
@@
mod tests {
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
- let addr_a =
NetAddress::IPv
4{addr: [127, 0, 0, 1], port: 1000};
+ let addr_a =
SocketAddress::TcpIpV
4{addr: [127, 0, 0, 1], port: 1000};
let mut fd_b = FileDescriptor {
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
let mut fd_b = FileDescriptor {
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
- let addr_b =
NetAddress::IPv
4{addr: [127, 0, 0, 1], port: 1001};
+ let addr_b =
SocketAddress::TcpIpV
4{addr: [127, 0, 0, 1], port: 1001};
let initial_data = peer_b.new_outbound_connection(id_a, fd_b.clone(), Some(addr_a.clone())).unwrap();
peer_a.new_inbound_connection(fd_a.clone(), Some(addr_b.clone())).unwrap();
assert_eq!(peer_a.read_event(&mut fd_a, &initial_data).unwrap(), false);
let initial_data = peer_b.new_outbound_connection(id_a, fd_b.clone(), Some(addr_a.clone())).unwrap();
peer_a.new_inbound_connection(fd_a.clone(), Some(addr_b.clone())).unwrap();
assert_eq!(peer_a.read_event(&mut fd_a, &initial_data).unwrap(), false);
@@
-2804,12
+2806,12
@@
mod tests {
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
- let addr_a =
NetAddress::IPv
4{addr: [127, 0, 0, 1], port: 1000};
+ let addr_a =
SocketAddress::TcpIpV
4{addr: [127, 0, 0, 1], port: 1000};
let mut fd_b = FileDescriptor {
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
let mut fd_b = FileDescriptor {
fd: 1, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
- let addr_b =
NetAddress::IPv
4{addr: [127, 0, 0, 1], port: 1001};
+ let addr_b =
SocketAddress::TcpIpV
4{addr: [127, 0, 0, 1], port: 1001};
let initial_data = peer_b.new_outbound_connection(id_a, fd_b.clone(), Some(addr_a.clone())).unwrap();
peer_a.new_inbound_connection(fd_a.clone(), Some(addr_b.clone())).unwrap();
assert_eq!(peer_a.read_event(&mut fd_a, &initial_data).unwrap(), false);
let initial_data = peer_b.new_outbound_connection(id_a, fd_b.clone(), Some(addr_a.clone())).unwrap();
peer_a.new_inbound_connection(fd_a.clone(), Some(addr_b.clone())).unwrap();
assert_eq!(peer_a.read_event(&mut fd_a, &initial_data).unwrap(), false);
@@
-2858,7
+2860,7
@@
mod tests {
let their_id = peers[1].node_signer.get_node_id(Recipient::Node).unwrap();
let their_id = peers[1].node_signer.get_node_id(Recipient::Node).unwrap();
- let msg = msgs::Shutdown { channel_id:
[42; 32]
, scriptpubkey: bitcoin::Script::new() };
+ let msg = msgs::Shutdown { channel_id:
ChannelId::from_bytes([42; 32])
, scriptpubkey: bitcoin::Script::new() };
a_chan_handler.pending_events.lock().unwrap().push(events::MessageSendEvent::SendShutdown {
node_id: their_id, msg: msg.clone()
});
a_chan_handler.pending_events.lock().unwrap().push(events::MessageSendEvent::SendShutdown {
node_id: their_id, msg: msg.clone()
});
@@
-2886,7
+2888,7
@@
mod tests {
fd: 3, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
fd: 3, outbound_data: Arc::new(Mutex::new(Vec::new())),
disconnect: Arc::new(AtomicBool::new(false)),
};
- let addr_dup =
NetAddress::IPv
4{addr: [127, 0, 0, 1], port: 1003};
+ let addr_dup =
SocketAddress::TcpIpV
4{addr: [127, 0, 0, 1], port: 1003};
let id_a = cfgs[0].node_signer.get_node_id(Recipient::Node).unwrap();
peers[0].new_inbound_connection(fd_dup.clone(), Some(addr_dup.clone())).unwrap();
let id_a = cfgs[0].node_signer.get_node_id(Recipient::Node).unwrap();
peers[0].new_inbound_connection(fd_dup.clone(), Some(addr_dup.clone())).unwrap();
@@
-3024,91
+3026,91
@@
mod tests {
// Tests the filter_addresses function.
// For (10/8)
// Tests the filter_addresses function.
// For (10/8)
- let ip_address =
NetAddress::IPv
4{addr: [10, 0, 0, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [10, 0, 0, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [10, 0, 255, 201], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [10, 0, 255, 201], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [10, 255, 255, 255], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [10, 255, 255, 255], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (0/8)
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (0/8)
- let ip_address =
NetAddress::IPv
4{addr: [0, 0, 0, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [0, 0, 0, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [0, 0, 255, 187], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [0, 0, 255, 187], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [0, 255, 255, 255], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [0, 255, 255, 255], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (100.64/10)
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (100.64/10)
- let ip_address =
NetAddress::IPv
4{addr: [100, 64, 0, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [100, 64, 0, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [100, 78, 255, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [100, 78, 255, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [100, 127, 255, 255], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [100, 127, 255, 255], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (127/8)
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (127/8)
- let ip_address =
NetAddress::IPv
4{addr: [127, 0, 0, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [127, 0, 0, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [127, 65, 73, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [127, 65, 73, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [127, 255, 255, 255], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [127, 255, 255, 255], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (169.254/16)
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (169.254/16)
- let ip_address =
NetAddress::IPv
4{addr: [169, 254, 0, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [169, 254, 0, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [169, 254, 221, 101], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [169, 254, 221, 101], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [169, 254, 255, 255], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [169, 254, 255, 255], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (172.16/12)
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (172.16/12)
- let ip_address =
NetAddress::IPv
4{addr: [172, 16, 0, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [172, 16, 0, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [172, 27, 101, 23], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [172, 27, 101, 23], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [172, 31, 255, 255], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [172, 31, 255, 255], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (192.168/16)
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (192.168/16)
- let ip_address =
NetAddress::IPv
4{addr: [192, 168, 0, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [192, 168, 0, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [192, 168, 205, 159], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [192, 168, 205, 159], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [192, 168, 255, 255], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [192, 168, 255, 255], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (192.88.99/24)
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (192.88.99/24)
- let ip_address =
NetAddress::IPv
4{addr: [192, 88, 99, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [192, 88, 99, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [192, 88, 99, 140], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [192, 88, 99, 140], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
4{addr: [192, 88, 99, 255], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [192, 88, 99, 255], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For other IPv4 addresses
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For other IPv4 addresses
- let ip_address =
NetAddress::IPv
4{addr: [188, 255, 99, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [188, 255, 99, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), Some(ip_address.clone()));
assert_eq!(filter_addresses(Some(ip_address.clone())), Some(ip_address.clone()));
- let ip_address =
NetAddress::IPv
4{addr: [123, 8, 129, 14], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [123, 8, 129, 14], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), Some(ip_address.clone()));
assert_eq!(filter_addresses(Some(ip_address.clone())), Some(ip_address.clone()));
- let ip_address =
NetAddress::IPv
4{addr: [2, 88, 9, 255], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
4{addr: [2, 88, 9, 255], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), Some(ip_address.clone()));
// For (2000::/3)
assert_eq!(filter_addresses(Some(ip_address.clone())), Some(ip_address.clone()));
// For (2000::/3)
- let ip_address =
NetAddress::IPv
6{addr: [32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
6{addr: [32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), Some(ip_address.clone()));
assert_eq!(filter_addresses(Some(ip_address.clone())), Some(ip_address.clone()));
- let ip_address =
NetAddress::IPv
6{addr: [45, 34, 209, 190, 0, 123, 55, 34, 0, 0, 3, 27, 201, 0, 0, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
6{addr: [45, 34, 209, 190, 0, 123, 55, 34, 0, 0, 3, 27, 201, 0, 0, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), Some(ip_address.clone()));
assert_eq!(filter_addresses(Some(ip_address.clone())), Some(ip_address.clone()));
- let ip_address =
NetAddress::IPv
6{addr: [63, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
6{addr: [63, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), Some(ip_address.clone()));
// For other IPv6 addresses
assert_eq!(filter_addresses(Some(ip_address.clone())), Some(ip_address.clone()));
// For other IPv6 addresses
- let ip_address =
NetAddress::IPv
6{addr: [24, 240, 12, 32, 0, 0, 0, 0, 20, 97, 0, 32, 121, 254, 0, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
6{addr: [24, 240, 12, 32, 0, 0, 0, 0, 20, 97, 0, 32, 121, 254, 0, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
6{addr: [68, 23, 56, 63, 0, 0, 2, 7, 75, 109, 0, 39, 0, 0, 0, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
6{addr: [68, 23, 56, 63, 0, 0, 2, 7, 75, 109, 0, 39, 0, 0, 0, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
- let ip_address =
NetAddress::IPv
6{addr: [101, 38, 140, 230, 100, 0, 30, 98, 0, 26, 0, 0, 57, 96, 0, 0], port: 1000};
+ let ip_address =
SocketAddress::TcpIpV
6{addr: [101, 38, 140, 230, 100, 0, 30, 98, 0, 26, 0, 0, 57, 96, 0, 0], port: 1000};
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (None)
assert_eq!(filter_addresses(Some(ip_address.clone())), None);
// For (None)