mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
improve verbose tracing. clean up some errors.
This commit is contained in:
parent
99e824829b
commit
22069d3430
@ -347,7 +347,10 @@ impl WebsocketProtocolHandler {
|
||||
// Negotiate TLS if this is WSS
|
||||
if tls {
|
||||
let connector = TlsConnector::default();
|
||||
let tls_stream = connector.connect(domain.to_string(), tcp_stream).await?;
|
||||
let tls_stream = network_result_try!(connector
|
||||
.connect(domain.to_string(), tcp_stream)
|
||||
.await
|
||||
.into_network_result()?);
|
||||
let (ws_stream, _response) = client_async(request, tls_stream)
|
||||
.await
|
||||
.map_err(to_io_error_other)?;
|
||||
|
@ -19,12 +19,27 @@ impl NetworkManager {
|
||||
data: Vec<u8>,
|
||||
) -> EyreResult<NetworkResult<SendDataMethod>> {
|
||||
// First try to send data to the last flow we've seen this peer on
|
||||
|
||||
let data = if let Some(flow) = destination_node_ref.last_flow() {
|
||||
#[cfg(feature = "verbose-tracing")]
|
||||
log_net!(debug
|
||||
"send_data: trying last flow ({:?}) for {:?}",
|
||||
flow,
|
||||
destination_node_ref
|
||||
);
|
||||
|
||||
match self.net().send_data_to_existing_flow(flow, data).await? {
|
||||
SendDataToExistingFlowResult::Sent(unique_flow) => {
|
||||
// Update timestamp for this last flow since we just sent to it
|
||||
destination_node_ref.set_last_flow(unique_flow.flow, Timestamp::now());
|
||||
|
||||
#[cfg(feature = "verbose-tracing")]
|
||||
log_net!(debug
|
||||
"send_data: sent to last flow ({:?}) for {:?}",
|
||||
unique_flow,
|
||||
destination_node_ref
|
||||
);
|
||||
|
||||
return Ok(NetworkResult::value(SendDataMethod {
|
||||
opt_relayed_contact_method: None,
|
||||
contact_method: NodeContactMethod::Existing,
|
||||
@ -34,6 +49,12 @@ impl NetworkManager {
|
||||
SendDataToExistingFlowResult::NotSent(data) => {
|
||||
// Couldn't send data to existing flow
|
||||
// so pass the data back out
|
||||
#[cfg(feature = "verbose-tracing")]
|
||||
log_net!(debug
|
||||
"send_data: did not send to last flow ({:?}) for {:?}",
|
||||
flow,
|
||||
destination_node_ref
|
||||
);
|
||||
data
|
||||
}
|
||||
}
|
||||
|
@ -467,10 +467,10 @@ async def test_dht_write_read_local():
|
||||
for desc0 in records:
|
||||
desc1 = await rc0.open_dht_record(desc0.key)
|
||||
|
||||
vd0 = await rc0.get_dht_value(desc1.key, ValueSubkey(0))
|
||||
vd0 = await rc0.get_dht_value(desc1.key, ValueSubkey(0), force_refresh=True)
|
||||
assert vd0.data == TEST_DATA
|
||||
|
||||
vd1 = await rc0.get_dht_value(desc1.key, ValueSubkey(1))
|
||||
vd1 = await rc0.get_dht_value(desc1.key, ValueSubkey(1), force_refresh=True)
|
||||
assert vd1.data == TEST_DATA2
|
||||
await rc0.close_dht_record(desc1.key)
|
||||
|
||||
|
@ -156,7 +156,7 @@ pub struct CmdlineArgs {
|
||||
|
||||
/// Change targets to ignore for logging
|
||||
#[arg(long)]
|
||||
ignore_log_targets: Option<Vec<String>>,
|
||||
ignore_log_targets: Option<String>,
|
||||
|
||||
/// Override all network listen addresses with ':port'
|
||||
#[arg(long)]
|
||||
@ -319,6 +319,9 @@ fn main() -> EyreResult<()> {
|
||||
if let Some(ignore_log_targets) = args.ignore_log_targets {
|
||||
println!("Changing ignored log targets: {:?}", ignore_log_targets);
|
||||
settingsrw.logging.terminal.ignore_log_targets = ignore_log_targets
|
||||
.split(',')
|
||||
.map(|x| x.to_owned())
|
||||
.collect();
|
||||
}
|
||||
|
||||
if let Some(port) = args.port {
|
||||
|
@ -58,6 +58,9 @@ impl<T> IoNetworkResultExt<T> for io::Result<T> {
|
||||
| io::ErrorKind::ConnectionAborted
|
||||
| io::ErrorKind::ConnectionRefused
|
||||
| io::ErrorKind::ConnectionReset => Ok(NetworkResult::NoConnection(e)),
|
||||
io::ErrorKind::InvalidInput | io::ErrorKind::InvalidData => {
|
||||
Ok(NetworkResult::InvalidMessage(e.to_string()))
|
||||
}
|
||||
io::ErrorKind::AddrNotAvailable => Ok(NetworkResult::AlreadyExists(e)),
|
||||
_ => Err(e),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user