Fixes for validation of dial info

This commit is contained in:
John Smith
2022-06-05 13:23:18 -04:00
parent cfcf430a99
commit 1eb26758e9
11 changed files with 112 additions and 46 deletions

View File

@@ -1315,8 +1315,8 @@ impl PeerInfo {
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
pub struct PeerAddress {
pub socket_address: SocketAddress,
pub protocol_type: ProtocolType,
socket_address: SocketAddress,
protocol_type: ProtocolType,
}
impl PeerAddress {
@@ -1327,6 +1327,14 @@ impl PeerAddress {
}
}
pub fn socket_address(&self) -> &SocketAddress {
&self.socket_address
}
pub fn protocol_type(&self) -> ProtocolType {
self.protocol_type
}
pub fn to_socket_addr(&self) -> SocketAddr {
self.socket_address.to_socket_addr()
}
@@ -1338,8 +1346,8 @@ impl PeerAddress {
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct ConnectionDescriptor {
pub remote: PeerAddress,
pub local: Option<SocketAddress>,
remote: PeerAddress,
local: Option<SocketAddress>,
}
impl ConnectionDescriptor {
@@ -1355,6 +1363,15 @@ impl ConnectionDescriptor {
local: None,
}
}
pub fn remote(&self) -> PeerAddress {
self.remote
}
pub fn remote_address(&self) -> &SocketAddress {
self.remote.socket_address()
}
pub fn local(&self) -> Option<SocketAddress> {
self.local
}
pub fn protocol_type(&self) -> ProtocolType {
self.remote.protocol_type
}