mirror of
https://github.com/ratspeak/rsLXMF
synced 2026-11-22 23:10:35 +00:00
lxmd: startup logs the full identity, delivery, and propagation hashes as lxmd does
This commit is contained in:
1 parent
2520ee1594
commit
b21732352b
2 files changed
+119
-9
No files matched your search
@@ -77,6 +77,7 @@ use rns_runtime::link_manager::{
|
||||
LinkResourceEvent,
|
||||
};
|
||||
use rns_runtime::reticulum::{AnnounceSubscription, AnnounceSubscriptionError, ReticulumHandle};
|
||||
use rns_tools::format::pretty_hex_rep;
|
||||
use rns_transport::link_messages::{AnnounceRequest, DestinationEvent};
|
||||
use rns_transport::messages::{TransportMessage, TransportQuery, TransportQueryResponse};
|
||||
|
||||
@@ -1981,11 +1982,14 @@ impl LxmdRunner {
|
||||
let identity_path = paths.preferred_identity_path().to_path_buf();
|
||||
let identity = if identity_path.exists() {
|
||||
rns_transport::notice!("Loading identity from {}", identity_path.display());
|
||||
Identity::from_file(&identity_path)?
|
||||
let id = Identity::from_file(&identity_path)?;
|
||||
rns_transport::notice!("Loaded Primary Identity {}", pretty_hex_rep(&id.hash));
|
||||
id
|
||||
} else {
|
||||
rns_transport::notice!("No identity found, generating new one");
|
||||
rns_transport::notice!("No Primary Identity file found, creating new...");
|
||||
let id = Identity::new();
|
||||
id.to_file(&paths.identity_path)?;
|
||||
rns_transport::notice!("Created new Primary Identity {}", pretty_hex_rep(&id.hash));
|
||||
id
|
||||
};
|
||||
|
||||
@@ -1998,12 +2002,6 @@ impl LxmdRunner {
|
||||
let control_dest_hash =
|
||||
Destination::hash_from_name_and_identity(CONTROL_APP_NAME, Some(&identity.hash));
|
||||
|
||||
rns_transport::notice!(
|
||||
"Identity: {} (LXMF: {})",
|
||||
&identity_hash[..16],
|
||||
&hex::encode(lxmf_dest_hash)[..16],
|
||||
);
|
||||
|
||||
let wall_now = now_f64() as u64;
|
||||
let delivery_ratchets = DeliveryRatchetState::load_or_initialize(
|
||||
&identity,
|
||||
@@ -6689,7 +6687,10 @@ pub(crate) async fn main() {
|
||||
|
||||
runner.refresh_control_state();
|
||||
|
||||
rns_transport::notice!("LXMF router initialized");
|
||||
rns_transport::notice!(
|
||||
"LXMF Router ready to receive on {}",
|
||||
pretty_hex_rep(&runner.lxmf_dest_hash)
|
||||
);
|
||||
|
||||
// Python's enable_propagation() always announces the node, independent of
|
||||
// the deferred start jobs.
|
||||
@@ -6697,6 +6698,10 @@ pub(crate) async fn main() {
|
||||
runner.schedule_node_announce(now_f64());
|
||||
runner.startup_node_announce_pending = true;
|
||||
tracing::info!("Startup propagation announce scheduled in {NODE_ANNOUNCE_DELAY}s");
|
||||
rns_transport::notice!(
|
||||
"LXMF Propagation Node started on {}",
|
||||
pretty_hex_rep(&runner.propagation_dest_hash)
|
||||
);
|
||||
}
|
||||
let deferred_start = tokio::time::sleep(Duration::from_secs(DEFERRED_JOBS_DELAY));
|
||||
tokio::pin!(deferred_start);
|
||||
|
||||
@@ -208,6 +208,111 @@ discover_interfaces = No
|
||||
);
|
||||
}
|
||||
|
||||
/// lxmd.py's startup lines with full `RNS.prettyhexrep` hashes: a loaded identity
|
||||
/// with the propagation node on, a created one with it off.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn startup_logs_full_identity_delivery_and_propagation_hashes() {
|
||||
use rns_identity::destination::Destination;
|
||||
use rns_identity::identity::Identity;
|
||||
|
||||
for propagation in [true, false] {
|
||||
let lxmf_dir = TestDir::new("lxmf-startup-lines");
|
||||
let rns_dir = TestDir::new("rns-startup-lines");
|
||||
let identity_path = lxmf_dir.path().join("identity");
|
||||
if propagation {
|
||||
write_rust_identity(&identity_path);
|
||||
}
|
||||
fs::write(
|
||||
lxmf_dir.path().join("config"),
|
||||
format!(
|
||||
"[lxmf]\n\n[propagation]\nenable_node = {}\n",
|
||||
if propagation { "yes" } else { "no" }
|
||||
),
|
||||
)
|
||||
.expect("write LXMF config");
|
||||
fs::write(
|
||||
rns_dir.path().join("config"),
|
||||
"\
|
||||
[reticulum]
|
||||
share_instance = No
|
||||
enable_transport = No
|
||||
respond_to_probes = No
|
||||
panic_on_interface_error = No
|
||||
discover_interfaces = No
|
||||
|
||||
[interfaces]
|
||||
",
|
||||
)
|
||||
.expect("write no-interface Reticulum config");
|
||||
|
||||
let log_path = rns_dir.path().join("lxmd-rs.log");
|
||||
let log = fs::File::create(&log_path).expect("create lxmd-rs log");
|
||||
let log_err = log.try_clone().expect("clone lxmd-rs log");
|
||||
let mut daemon = Daemon(Some(
|
||||
Command::new(env!("CARGO_BIN_EXE_lxmd-rs"))
|
||||
.arg("--config")
|
||||
.arg(lxmf_dir.path())
|
||||
.arg("--rnsconfig")
|
||||
.arg(rns_dir.path())
|
||||
.stdout(log)
|
||||
.stderr(log_err)
|
||||
.spawn()
|
||||
.expect("lxmd-rs subprocess should start"),
|
||||
));
|
||||
|
||||
let read_log = || fs::read_to_string(&log_path).unwrap_or_default();
|
||||
let deadline = Instant::now() + Duration::from_secs(30);
|
||||
while !read_log().contains("LXMF Daemon running") {
|
||||
if let Some(status) = daemon.child().try_wait().expect("poll lxmd-rs startup") {
|
||||
panic!("lxmd-rs exited during startup ({status}):\n{}", read_log());
|
||||
}
|
||||
assert!(
|
||||
Instant::now() < deadline,
|
||||
"lxmd-rs did not finish startup:\n{}",
|
||||
read_log()
|
||||
);
|
||||
std::thread::sleep(Duration::from_millis(50));
|
||||
}
|
||||
drop(daemon);
|
||||
let text = read_log();
|
||||
|
||||
let identity = Identity::from_file(&identity_path).expect("read lxmd-rs identity");
|
||||
let pretty = |hash: &[u8]| format!("<{}>", hex::encode(hash));
|
||||
let delivery =
|
||||
Destination::hash_from_name_and_identity("lxmf.delivery", Some(&identity.hash));
|
||||
let node =
|
||||
Destination::hash_from_name_and_identity("lxmf.propagation", Some(&identity.hash));
|
||||
let identity_line = if propagation {
|
||||
format!("Loaded Primary Identity {}", pretty(&identity.hash))
|
||||
} else {
|
||||
format!("Created new Primary Identity {}", pretty(&identity.hash))
|
||||
};
|
||||
let delivery_line = format!("LXMF Router ready to receive on {}", pretty(&delivery));
|
||||
let node_line = format!("LXMF Propagation Node started on {}", pretty(&node));
|
||||
|
||||
let position = |line: &str| {
|
||||
text.find(line)
|
||||
.unwrap_or_else(|| panic!("missing {line:?} in lxmd-rs output:\n{text}"))
|
||||
};
|
||||
let running = position("LXMF Daemon running");
|
||||
assert!(
|
||||
position(&identity_line) < position(&delivery_line),
|
||||
"{text}"
|
||||
);
|
||||
if propagation {
|
||||
assert!(position(&delivery_line) < position(&node_line), "{text}");
|
||||
assert!(position(&node_line) < running, "{text}");
|
||||
} else {
|
||||
assert!(position(&delivery_line) < running, "{text}");
|
||||
assert!(
|
||||
!text.contains("LXMF Propagation Node started on"),
|
||||
"propagation line without a propagation node:\n{text}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn version_reports_binary_name_and_package_version() {
|
||||
let output = lxmd(&["--version"]);
|
||||
|
||||
Reference in new issue
Block a user