mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-02-10 03:38:36 -05:00
subscribe handlers in init. log cleanup.
This commit is contained in:
parent
5dffb30603
commit
9042a7afd5
@ -373,6 +373,23 @@ impl NetworkManager {
|
|||||||
*self.unlocked_inner.routing_table.write() = Some(routing_table.clone());
|
*self.unlocked_inner.routing_table.write() = Some(routing_table.clone());
|
||||||
*self.unlocked_inner.address_filter.write() = Some(address_filter);
|
*self.unlocked_inner.address_filter.write() = Some(address_filter);
|
||||||
*self.unlocked_inner.update_callback.write() = Some(update_callback);
|
*self.unlocked_inner.update_callback.write() = Some(update_callback);
|
||||||
|
|
||||||
|
// Register event handlers
|
||||||
|
let this = self.clone();
|
||||||
|
self.event_bus().subscribe(move |evt| {
|
||||||
|
let this = this.clone();
|
||||||
|
Box::pin(async move {
|
||||||
|
this.peer_info_change_event_handler(evt);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
let this = self.clone();
|
||||||
|
self.event_bus().subscribe(move |evt| {
|
||||||
|
let this = this.clone();
|
||||||
|
Box::pin(async move {
|
||||||
|
this.socket_address_change_event_handler(evt);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,22 +461,6 @@ impl NetworkManager {
|
|||||||
rpc_processor.startup().await?;
|
rpc_processor.startup().await?;
|
||||||
receipt_manager.startup().await?;
|
receipt_manager.startup().await?;
|
||||||
|
|
||||||
// Register event handlers
|
|
||||||
let this = self.clone();
|
|
||||||
self.event_bus().subscribe(move |evt| {
|
|
||||||
let this = this.clone();
|
|
||||||
Box::pin(async move {
|
|
||||||
this.peer_info_change_event_handler(evt);
|
|
||||||
})
|
|
||||||
});
|
|
||||||
let this = self.clone();
|
|
||||||
self.event_bus().subscribe(move |evt| {
|
|
||||||
let this = this.clone();
|
|
||||||
Box::pin(async move {
|
|
||||||
this.socket_address_change_event_handler(evt);
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
log_net!("NetworkManager::internal_startup end");
|
log_net!("NetworkManager::internal_startup end");
|
||||||
|
|
||||||
Ok(StartupDisposition::Success)
|
Ok(StartupDisposition::Success)
|
||||||
|
@ -161,6 +161,7 @@ impl RoutingDomainEditorCommonTrait for RoutingDomainEditorLocalNetwork {
|
|||||||
info!(
|
info!(
|
||||||
"[LocalNetwork] removed dial info:\n{}",
|
"[LocalNetwork] removed dial info:\n{}",
|
||||||
indent_all_string(&removed_dial_info.to_multiline_string())
|
indent_all_string(&removed_dial_info.to_multiline_string())
|
||||||
|
.strip_trailing_newline()
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
}
|
}
|
||||||
@ -172,6 +173,7 @@ impl RoutingDomainEditorCommonTrait for RoutingDomainEditorLocalNetwork {
|
|||||||
info!(
|
info!(
|
||||||
"[LocalNetwork] added dial info:\n{}",
|
"[LocalNetwork] added dial info:\n{}",
|
||||||
indent_all_string(&added_dial_info.to_multiline_string())
|
indent_all_string(&added_dial_info.to_multiline_string())
|
||||||
|
.strip_trailing_newline()
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
}
|
}
|
||||||
@ -188,35 +190,35 @@ impl RoutingDomainEditorCommonTrait for RoutingDomainEditorLocalNetwork {
|
|||||||
}
|
}
|
||||||
if old_outbound_protocols != new_outbound_protocols {
|
if old_outbound_protocols != new_outbound_protocols {
|
||||||
info!(
|
info!(
|
||||||
"[LocalNetwork] changed network: outbound {:?}->{:?}\n",
|
"[LocalNetwork] changed network: outbound {:?}->{:?}",
|
||||||
old_outbound_protocols, new_outbound_protocols
|
old_outbound_protocols, new_outbound_protocols
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
}
|
}
|
||||||
if old_inbound_protocols != new_inbound_protocols {
|
if old_inbound_protocols != new_inbound_protocols {
|
||||||
info!(
|
info!(
|
||||||
"[LocalNetwork] changed network: inbound {:?}->{:?}\n",
|
"[LocalNetwork] changed network: inbound {:?}->{:?}",
|
||||||
old_inbound_protocols, new_inbound_protocols,
|
old_inbound_protocols, new_inbound_protocols,
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
}
|
}
|
||||||
if old_address_types != new_address_types {
|
if old_address_types != new_address_types {
|
||||||
info!(
|
info!(
|
||||||
"[LocalNetwork] changed network: address types {:?}->{:?}\n",
|
"[LocalNetwork] changed network: address types {:?}->{:?}",
|
||||||
old_address_types, new_address_types,
|
old_address_types, new_address_types,
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
}
|
}
|
||||||
if old_capabilities != new_capabilities {
|
if old_capabilities != new_capabilities {
|
||||||
info!(
|
info!(
|
||||||
"[PublicInternet] changed network: capabilities {:?}->{:?}\n",
|
"[PublicInternet] changed network: capabilities {:?}->{:?}",
|
||||||
old_capabilities, new_capabilities
|
old_capabilities, new_capabilities
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
}
|
}
|
||||||
if old_network_class != new_network_class {
|
if old_network_class != new_network_class {
|
||||||
info!(
|
info!(
|
||||||
"[LocalNetwork] changed network class: {:?}->{:?}\n",
|
"[LocalNetwork] changed network class: {:?}->{:?}",
|
||||||
old_network_class, new_network_class
|
old_network_class, new_network_class
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
|
@ -170,6 +170,7 @@ impl RoutingDomainEditorCommonTrait for RoutingDomainEditorPublicInternet {
|
|||||||
info!(
|
info!(
|
||||||
"[PublicInternet] removed dial info:\n{}",
|
"[PublicInternet] removed dial info:\n{}",
|
||||||
indent_all_string(&removed_dial_info.to_multiline_string())
|
indent_all_string(&removed_dial_info.to_multiline_string())
|
||||||
|
.strip_trailing_newline()
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
}
|
}
|
||||||
@ -181,6 +182,7 @@ impl RoutingDomainEditorCommonTrait for RoutingDomainEditorPublicInternet {
|
|||||||
info!(
|
info!(
|
||||||
"[PublicInternet] added dial info:\n{}",
|
"[PublicInternet] added dial info:\n{}",
|
||||||
indent_all_string(&added_dial_info.to_multiline_string())
|
indent_all_string(&added_dial_info.to_multiline_string())
|
||||||
|
.strip_trailing_newline()
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
}
|
}
|
||||||
@ -197,35 +199,35 @@ impl RoutingDomainEditorCommonTrait for RoutingDomainEditorPublicInternet {
|
|||||||
}
|
}
|
||||||
if old_outbound_protocols != new_outbound_protocols {
|
if old_outbound_protocols != new_outbound_protocols {
|
||||||
info!(
|
info!(
|
||||||
"[PublicInternet] changed network: outbound {:?}->{:?}\n",
|
"[PublicInternet] changed network: outbound {:?}->{:?}",
|
||||||
old_outbound_protocols, new_outbound_protocols
|
old_outbound_protocols, new_outbound_protocols
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
}
|
}
|
||||||
if old_inbound_protocols != new_inbound_protocols {
|
if old_inbound_protocols != new_inbound_protocols {
|
||||||
info!(
|
info!(
|
||||||
"[PublicInternet] changed network: inbound {:?}->{:?}\n",
|
"[PublicInternet] changed network: inbound {:?}->{:?}",
|
||||||
old_inbound_protocols, new_inbound_protocols,
|
old_inbound_protocols, new_inbound_protocols,
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
}
|
}
|
||||||
if old_address_types != new_address_types {
|
if old_address_types != new_address_types {
|
||||||
info!(
|
info!(
|
||||||
"[PublicInternet] changed network: address types {:?}->{:?}\n",
|
"[PublicInternet] changed network: address types {:?}->{:?}",
|
||||||
old_address_types, new_address_types,
|
old_address_types, new_address_types,
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
}
|
}
|
||||||
if old_capabilities != new_capabilities {
|
if old_capabilities != new_capabilities {
|
||||||
info!(
|
info!(
|
||||||
"[PublicInternet] changed network: capabilities {:?}->{:?}\n",
|
"[PublicInternet] changed network: capabilities {:?}->{:?}",
|
||||||
old_capabilities, new_capabilities
|
old_capabilities, new_capabilities
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
}
|
}
|
||||||
if old_network_class != new_network_class {
|
if old_network_class != new_network_class {
|
||||||
info!(
|
info!(
|
||||||
"[PublicInternet] changed network class: {:?}->{:?}\n",
|
"[PublicInternet] changed network class: {:?}->{:?}",
|
||||||
old_network_class, new_network_class
|
old_network_class, new_network_class
|
||||||
);
|
);
|
||||||
peer_info_changed = true;
|
peer_info_changed = true;
|
||||||
|
@ -2321,3 +2321,16 @@ where
|
|||||||
out
|
out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait StripTrailingNewline {
|
||||||
|
fn strip_trailing_newline(&self) -> &str;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: AsRef<str>> StripTrailingNewline for T {
|
||||||
|
fn strip_trailing_newline(&self) -> &str {
|
||||||
|
self.as_ref()
|
||||||
|
.strip_suffix("\r\n")
|
||||||
|
.or(self.as_ref().strip_suffix("\n"))
|
||||||
|
.unwrap_or(self.as_ref())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user