more clippy
This commit is contained in:
@@ -69,14 +69,11 @@ impl ProtectedStore {
|
||||
|
||||
let vkey = self.browser_key_name(key.as_ref());
|
||||
|
||||
let prev = match ls
|
||||
let prev = ls
|
||||
.get_item(&vkey)
|
||||
.map_err(map_jsvalue_error)
|
||||
.wrap_err("exception_thrown")?
|
||||
{
|
||||
Some(_) => true,
|
||||
None => false,
|
||||
};
|
||||
.is_some();
|
||||
|
||||
ls.set_item(&vkey, value.as_ref())
|
||||
.map_err(map_jsvalue_error)
|
||||
|
@@ -249,7 +249,7 @@ impl ConnectionManager {
|
||||
&self,
|
||||
dial_info: DialInfo,
|
||||
) -> EyreResult<NetworkResult<ConnectionHandle>> {
|
||||
let peer_address = dial_info.to_peer_address();
|
||||
let peer_address = dial_info.peer_address();
|
||||
let remote_addr = peer_address.socket_addr();
|
||||
let mut preferred_local_address = self
|
||||
.network_manager()
|
||||
@@ -301,26 +301,6 @@ impl ConnectionManager {
|
||||
.await;
|
||||
match result_net_res {
|
||||
Ok(net_res) => {
|
||||
// // If the connection 'already exists', then try one last time to return a connection from the table, in case
|
||||
// // an 'accept' happened at literally the same time as our connect. A preferred local address must have been
|
||||
// // specified otherwise we would have picked a different ephemeral port and this could not have happened
|
||||
// if net_res.is_already_exists() && preferred_local_address.is_some() {
|
||||
// // Make 'already existing' connection descriptor
|
||||
// let conn_desc = ConnectionDescriptor::new(
|
||||
// dial_info.to_peer_address(),
|
||||
// SocketAddress::from_socket_addr(preferred_local_address.unwrap()),
|
||||
// );
|
||||
// // Return the connection for this if we have it
|
||||
// if let Some(conn) = self
|
||||
// .arc
|
||||
// .connection_table
|
||||
// .get_connection_by_descriptor(conn_desc)
|
||||
// {
|
||||
// // Should not really happen, lets make sure we see this if it does
|
||||
// log_net!(warn "== Returning existing connection in race: {:?}", conn_desc);
|
||||
// return Ok(NetworkResult::Value(conn));
|
||||
// }
|
||||
// }
|
||||
if net_res.is_value() || retry_count == 0 {
|
||||
// Successful new connection, return it
|
||||
break net_res;
|
||||
|
@@ -46,7 +46,7 @@ use storage_manager::*;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm::*;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub use wasm::{LOCAL_NETWORK_CAPABILITIES, MAX_CAPABILITIES, PUBLIC_INTERNET_CAPABILITIES};
|
||||
pub use wasm::{/* LOCAL_NETWORK_CAPABILITIES, */ MAX_CAPABILITIES, PUBLIC_INTERNET_CAPABILITIES,};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@@ -462,7 +462,7 @@ impl Network {
|
||||
}
|
||||
// Network accounting
|
||||
self.network_manager()
|
||||
.stats_packet_sent(dial_info.to_ip_addr(), ByteCount::new(data_len as u64));
|
||||
.stats_packet_sent(dial_info.ip_addr(), ByteCount::new(data_len as u64));
|
||||
|
||||
Ok(NetworkResult::Value(()))
|
||||
})
|
||||
@@ -507,7 +507,7 @@ impl Network {
|
||||
.await
|
||||
.wrap_err("send message failure")?);
|
||||
self.network_manager()
|
||||
.stats_packet_sent(dial_info.to_ip_addr(), ByteCount::new(data_len as u64));
|
||||
.stats_packet_sent(dial_info.ip_addr(), ByteCount::new(data_len as u64));
|
||||
|
||||
// receive single response
|
||||
let mut out = vec![0u8; MAX_MESSAGE_SIZE];
|
||||
@@ -552,7 +552,7 @@ impl Network {
|
||||
|
||||
network_result_try!(pnc.send(data).await.wrap_err("send failure")?);
|
||||
self.network_manager()
|
||||
.stats_packet_sent(dial_info.to_ip_addr(), ByteCount::new(data_len as u64));
|
||||
.stats_packet_sent(dial_info.ip_addr(), ByteCount::new(data_len as u64));
|
||||
|
||||
let out =
|
||||
network_result_try!(network_result_try!(timeout(timeout_ms, pnc.recv())
|
||||
@@ -560,10 +560,8 @@ impl Network {
|
||||
.into_network_result())
|
||||
.wrap_err("recv failure")?);
|
||||
|
||||
self.network_manager().stats_packet_rcvd(
|
||||
dial_info.to_ip_addr(),
|
||||
ByteCount::new(out.len() as u64),
|
||||
);
|
||||
self.network_manager()
|
||||
.stats_packet_rcvd(dial_info.ip_addr(), ByteCount::new(out.len() as u64));
|
||||
|
||||
Ok(NetworkResult::Value(out))
|
||||
}
|
||||
@@ -676,7 +674,7 @@ impl Network {
|
||||
|
||||
// Network accounting
|
||||
self.network_manager()
|
||||
.stats_packet_sent(dial_info.to_ip_addr(), ByteCount::new(data_len as u64));
|
||||
.stats_packet_sent(dial_info.ip_addr(), ByteCount::new(data_len as u64));
|
||||
|
||||
Ok(NetworkResult::value(connection_descriptor))
|
||||
})
|
||||
|
@@ -20,7 +20,7 @@ const MAX_WS_BEFORE_BODY: usize = 2048;
|
||||
cfg_if! {
|
||||
if #[cfg(feature="rt-async-std")] {
|
||||
pub type WebsocketNetworkConnectionWSS =
|
||||
DialInfo::WS { field1: _ }ketNetworkConnection<async_tls::client::TlsStream<TcpStream>>;
|
||||
WebsocketNetworkConnection<async_tls::client::TlsStream<TcpStream>>;
|
||||
pub type WebsocketNetworkConnectionWS = WebsocketNetworkConnection<TcpStream>;
|
||||
} else if #[cfg(feature="rt-tokio")] {
|
||||
pub type WebsocketNetworkConnectionWSS =
|
||||
@@ -306,7 +306,7 @@ impl WebsocketProtocolHandler {
|
||||
|
||||
// Make our connection descriptor
|
||||
let descriptor = ConnectionDescriptor::new(
|
||||
dial_info.to_peer_address(),
|
||||
dial_info.peer_address(),
|
||||
SocketAddress::from_socket_addr(actual_local_addr),
|
||||
);
|
||||
|
||||
|
@@ -242,7 +242,7 @@ impl DialInfo {
|
||||
Self::WSS(di) => di.socket_address,
|
||||
}
|
||||
}
|
||||
pub fn to_ip_addr(&self) -> IpAddr {
|
||||
pub fn ip_addr(&self) -> IpAddr {
|
||||
match self {
|
||||
Self::UDP(di) => di.socket_address.ip_addr(),
|
||||
Self::TCP(di) => di.socket_address.ip_addr(),
|
||||
@@ -274,7 +274,7 @@ impl DialInfo {
|
||||
Self::WSS(di) => di.socket_address.socket_addr(),
|
||||
}
|
||||
}
|
||||
pub fn to_peer_address(&self) -> PeerAddress {
|
||||
pub fn peer_address(&self) -> PeerAddress {
|
||||
match self {
|
||||
Self::UDP(di) => PeerAddress::new(di.socket_address, ProtocolType::UDP),
|
||||
Self::TCP(di) => PeerAddress::new(di.socket_address, ProtocolType::TCP),
|
||||
|
@@ -32,18 +32,18 @@ pub const PUBLIC_INTERNET_CAPABILITIES: [Capability; PUBLIC_INTERNET_CAPABILITIE
|
||||
CAP_BLOCKSTORE,
|
||||
];
|
||||
|
||||
#[cfg(feature = "unstable-blockstore")]
|
||||
const LOCAL_NETWORK_CAPABILITIES_LEN: usize = 3;
|
||||
#[cfg(not(feature = "unstable-blockstore"))]
|
||||
const LOCAL_NETWORK_CAPABILITIES_LEN: usize = 2;
|
||||
// #[cfg(feature = "unstable-blockstore")]
|
||||
// const LOCAL_NETWORK_CAPABILITIES_LEN: usize = 3;
|
||||
// #[cfg(not(feature = "unstable-blockstore"))]
|
||||
// const LOCAL_NETWORK_CAPABILITIES_LEN: usize = 2;
|
||||
|
||||
pub const LOCAL_NETWORK_CAPABILITIES: [Capability; LOCAL_NETWORK_CAPABILITIES_LEN] = [
|
||||
//CAP_RELAY,
|
||||
CAP_DHT,
|
||||
CAP_APPMESSAGE,
|
||||
#[cfg(feature = "unstable-blockstore")]
|
||||
CAP_BLOCKSTORE,
|
||||
];
|
||||
// pub const LOCAL_NETWORK_CAPABILITIES: [Capability; LOCAL_NETWORK_CAPABILITIES_LEN] = [
|
||||
// //CAP_RELAY,
|
||||
// CAP_DHT,
|
||||
// CAP_APPMESSAGE,
|
||||
// #[cfg(feature = "unstable-blockstore")]
|
||||
// CAP_BLOCKSTORE,
|
||||
// ];
|
||||
|
||||
pub const MAX_CAPABILITIES: usize = 64;
|
||||
|
||||
@@ -149,7 +149,7 @@ impl Network {
|
||||
if self
|
||||
.network_manager()
|
||||
.address_filter()
|
||||
.is_ip_addr_punished(dial_info.address().to_ip_addr())
|
||||
.is_ip_addr_punished(dial_info.address().ip_addr())
|
||||
{
|
||||
return Ok(NetworkResult::no_connection_other("punished"));
|
||||
}
|
||||
@@ -173,7 +173,7 @@ impl Network {
|
||||
|
||||
// Network accounting
|
||||
self.network_manager()
|
||||
.stats_packet_sent(dial_info.to_ip_addr(), ByteCount::new(data_len as u64));
|
||||
.stats_packet_sent(dial_info.ip_addr(), ByteCount::new(data_len as u64));
|
||||
|
||||
Ok(NetworkResult::Value(()))
|
||||
})
|
||||
@@ -202,7 +202,7 @@ impl Network {
|
||||
if self
|
||||
.network_manager()
|
||||
.address_filter()
|
||||
.is_ip_addr_punished(dial_info.address().to_ip_addr())
|
||||
.is_ip_addr_punished(dial_info.address().ip_addr())
|
||||
{
|
||||
return Ok(NetworkResult::no_connection_other("punished"));
|
||||
}
|
||||
@@ -227,7 +227,7 @@ impl Network {
|
||||
|
||||
network_result_try!(pnc.send(data).await.wrap_err("send failure")?);
|
||||
self.network_manager()
|
||||
.stats_packet_sent(dial_info.to_ip_addr(), ByteCount::new(data_len as u64));
|
||||
.stats_packet_sent(dial_info.ip_addr(), ByteCount::new(data_len as u64));
|
||||
|
||||
let out =
|
||||
network_result_try!(network_result_try!(timeout(timeout_ms, pnc.recv())
|
||||
@@ -235,10 +235,8 @@ impl Network {
|
||||
.into_network_result())
|
||||
.wrap_err("recv failure")?);
|
||||
|
||||
self.network_manager().stats_packet_rcvd(
|
||||
dial_info.to_ip_addr(),
|
||||
ByteCount::new(out.len() as u64),
|
||||
);
|
||||
self.network_manager()
|
||||
.stats_packet_rcvd(dial_info.ip_addr(), ByteCount::new(out.len() as u64));
|
||||
|
||||
Ok(NetworkResult::Value(out))
|
||||
}
|
||||
@@ -273,7 +271,7 @@ impl Network {
|
||||
ConnectionHandleSendResult::Sent => {
|
||||
// Network accounting
|
||||
self.network_manager().stats_packet_sent(
|
||||
descriptor.remote().to_socket_addr().ip(),
|
||||
descriptor.remote().socket_addr().ip(),
|
||||
ByteCount::new(data_len as u64),
|
||||
);
|
||||
|
||||
@@ -324,7 +322,7 @@ impl Network {
|
||||
|
||||
// Network accounting
|
||||
self.network_manager()
|
||||
.stats_packet_sent(dial_info.to_ip_addr(), ByteCount::new(data_len as u64));
|
||||
.stats_packet_sent(dial_info.ip_addr(), ByteCount::new(data_len as u64));
|
||||
|
||||
Ok(NetworkResult::value(connection_descriptor))
|
||||
})
|
||||
@@ -434,11 +432,11 @@ impl Network {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
pub fn get_local_port(&self, protocol_type: ProtocolType) -> Option<u16> {
|
||||
pub fn get_local_port(&self, _protocol_type: ProtocolType) -> Option<u16> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn get_preferred_local_address(&self, dial_info: &DialInfo) -> Option<SocketAddr> {
|
||||
pub fn get_preferred_local_address(&self, _dial_info: &DialInfo) -> Option<SocketAddr> {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -456,7 +454,7 @@ impl Network {
|
||||
}
|
||||
|
||||
pub fn get_protocol_config(&self) -> ProtocolConfig {
|
||||
self.inner.lock().protocol_config.clone()
|
||||
self.inner.lock().protocol_config
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
|
@@ -19,7 +19,7 @@ impl ProtocolNetworkConnection {
|
||||
timeout_ms: u32,
|
||||
address_filter: AddressFilter,
|
||||
) -> io::Result<NetworkResult<ProtocolNetworkConnection>> {
|
||||
if address_filter.is_ip_addr_punished(dial_info.address().to_ip_addr()) {
|
||||
if address_filter.is_ip_addr_punished(dial_info.address().ip_addr()) {
|
||||
return Ok(NetworkResult::no_connection_other("punished"));
|
||||
}
|
||||
match dial_info.protocol_type() {
|
||||
|
@@ -56,7 +56,7 @@ impl WebsocketNetworkConnection {
|
||||
}
|
||||
|
||||
pub fn descriptor(&self) -> ConnectionDescriptor {
|
||||
self.descriptor.clone()
|
||||
self.descriptor
|
||||
}
|
||||
|
||||
// #[instrument(level = "trace", err, skip(self))]
|
||||
@@ -144,7 +144,7 @@ impl WebsocketProtocolHandler {
|
||||
|
||||
// Make our connection descriptor
|
||||
let wnc = WebsocketNetworkConnection::new(
|
||||
ConnectionDescriptor::new_no_local(dial_info.to_peer_address()),
|
||||
ConnectionDescriptor::new_no_local(dial_info.peer_address()),
|
||||
wsmeta,
|
||||
wsio,
|
||||
);
|
||||
|
@@ -399,8 +399,8 @@ impl RoutingDomainDetail for PublicInternetRoutingDomainDetail {
|
||||
dif_sort.clone()
|
||||
) {
|
||||
// Ensure we aren't on the same public IP address (no hairpin nat)
|
||||
if reverse_did.dial_info.to_ip_addr()
|
||||
!= target_did.dial_info.to_ip_addr()
|
||||
if reverse_did.dial_info.ip_addr()
|
||||
!= target_did.dial_info.ip_addr()
|
||||
{
|
||||
// Can we receive a direct reverse connection?
|
||||
if !reverse_did.class.requires_signal() {
|
||||
@@ -433,8 +433,8 @@ impl RoutingDomainDetail for PublicInternetRoutingDomainDetail {
|
||||
dif_sort.clone(),
|
||||
) {
|
||||
// Ensure we aren't on the same public IP address (no hairpin nat)
|
||||
if reverse_udp_did.dial_info.to_ip_addr()
|
||||
!= target_udp_did.dial_info.to_ip_addr()
|
||||
if reverse_udp_did.dial_info.ip_addr()
|
||||
!= target_udp_did.dial_info.ip_addr()
|
||||
{
|
||||
// The target and ourselves have a udp dialinfo that they can reach
|
||||
return ContactMethod::SignalHolePunch(
|
||||
|
@@ -22,7 +22,12 @@ impl RPCOperationWatchValueQ {
|
||||
watcher: PublicKey,
|
||||
signature: Signature,
|
||||
) -> Result<Self, RPCError> {
|
||||
if subkeys.len() > MAX_WATCH_VALUE_Q_SUBKEYS_LEN {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let subkeys_len = subkeys.len() as usize;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let subkeys_len = subkeys.len();
|
||||
|
||||
if subkeys_len > MAX_WATCH_VALUE_Q_SUBKEYS_LEN {
|
||||
return Err(RPCError::protocol("WatchValueQ subkeys length too long"));
|
||||
}
|
||||
Ok(Self {
|
||||
@@ -37,8 +42,12 @@ impl RPCOperationWatchValueQ {
|
||||
|
||||
// signature covers: key, subkeys, expiration, count, using watcher key
|
||||
fn make_signature_data(&self) -> Vec<u8> {
|
||||
let mut sig_data =
|
||||
Vec::with_capacity(PUBLIC_KEY_LENGTH + 4 + (self.subkeys.len() * 8) + 8 + 4);
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let subkeys_len = self.subkeys.len() as usize;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let subkeys_len = self.subkeys.len();
|
||||
|
||||
let mut sig_data = Vec::with_capacity(PUBLIC_KEY_LENGTH + 4 + (subkeys_len * 8) + 8 + 4);
|
||||
sig_data.extend_from_slice(&self.key.kind.0);
|
||||
sig_data.extend_from_slice(&self.key.value.bytes);
|
||||
for sk in self.subkeys.ranges() {
|
||||
|
@@ -70,7 +70,7 @@ pub async fn test_protected_store(ps: ProtectedStore) {
|
||||
assert_eq!(ps.load_user_secret("_test_broken").await.unwrap(), None);
|
||||
assert_eq!(ps.load_user_secret("_test_broken").await.unwrap(), None);
|
||||
assert!(ps.remove_user_secret("_test_key").await.unwrap());
|
||||
assert!(ps.remove_user_secret("_test_key").await.unwrap());
|
||||
assert!(!ps.remove_user_secret("_test_key").await.unwrap());
|
||||
assert!(!ps.remove_user_secret("_test_key").await.unwrap());
|
||||
assert!(!ps.remove_user_secret("_test_broken").await.unwrap());
|
||||
|
||||
|
Reference in New Issue
Block a user