Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(iroh-cli)!: Use config and logging from iroh-node-utils #2953

Merged
merged 46 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4d30302
refactor(iroh): extract docs RPC into iroh-docs
dignifiedquire Oct 30, 2024
a749306
remove dead code
dignifiedquire Oct 30, 2024
c9ff5cd
fix?
divagant-martian Oct 30, 2024
d301ed7
doc needs to be used with a different param
divagant-martian Oct 30, 2024
cea6d32
more fixes
divagant-martian Oct 30, 2024
ac5b0e0
it compiles again
dignifiedquire Oct 31, 2024
b4821d1
fixup cli
dignifiedquire Oct 31, 2024
940b28d
extract authors
dignifiedquire Oct 31, 2024
6fe36b3
Merge branch 'main' into refactor-extract-rpc-docs
rklaehn Nov 7, 2024
b47eb11
Update to latest quic-rpc
rklaehn Nov 7, 2024
f97acb7
fix docs
rklaehn Nov 7, 2024
f60c829
Merge branch 'main' into refactor-extract-rpc-docs
rklaehn Nov 7, 2024
2d671b6
fix default author in example
rklaehn Nov 7, 2024
69c7fb0
remove entry.content_bytes from examples
rklaehn Nov 7, 2024
06d49ca
Merge branch 'main' into refactor-extract-rpc-docs
rklaehn Nov 7, 2024
c911ff8
Merge branch 'main' into refactor-extract-rpc-docs
rklaehn Nov 7, 2024
c8a0e48
Add generics for docs engine
rklaehn Nov 7, 2024
377143e
Merge branch 'main' into refactor-extract-rpc-docs
rklaehn Nov 12, 2024
0b6042f
Go back to .authors(), at least for the client.
rklaehn Nov 12, 2024
11c15fd
Also export authors client
rklaehn Nov 12, 2024
8ab5f83
fix example
rklaehn Nov 12, 2024
97ffc0f
WIP
rklaehn Nov 13, 2024
3e04bd1
Merge branch 'main' into extract-node-rpc
rklaehn Nov 13, 2024
172c890
refactor: Add new crate iroh-node-util (name TBD)...
rklaehn Nov 14, 2024
8288006
Merge branch 'main' into extract-node-rpc
rklaehn Nov 14, 2024
3449d4e
Merge branch 'main' into extract-node-rpc
rklaehn Nov 19, 2024
4f9cf48
remove dead code and remove example
rklaehn Nov 19, 2024
06feab6
remove util methods
rklaehn Nov 19, 2024
8e1d4e9
add a LOICENSE
rklaehn Nov 19, 2024
807c11d
clippy
rklaehn Nov 19, 2024
28d8d96
use a trait
rklaehn Nov 19, 2024
59a62f2
WIP
rklaehn Nov 19, 2024
fa52a9c
wire up metrics
rklaehn Nov 19, 2024
e97e243
Add some docs for the trait to be implemented
rklaehn Nov 19, 2024
1d77a0b
fix docs
rklaehn Nov 19, 2024
1834989
fix dependency versions
rklaehn Nov 19, 2024
d4002c4
Add README.md and description
rklaehn Nov 19, 2024
09124d5
Add docs everywhere it makes sense...
rklaehn Nov 19, 2024
89b12cb
Add logging and config stuff from iroh-cli
rklaehn Nov 19, 2024
c89780c
format cargo.toml
rklaehn Nov 19, 2024
0db1759
Merge branch 'extract-node-rpc' into move-dirs-next-stuff
rklaehn Nov 19, 2024
fcb48da
Use everything possible from iroh-node-util
rklaehn Nov 19, 2024
8fb024e
fix docs
rklaehn Nov 19, 2024
a300ab6
try to get docs to work again with features
rklaehn Nov 19, 2024
68ccd12
Merge branch 'main' into move-dirs-next-stuff
rklaehn Nov 20, 2024
4037156
Move env_file_rust_log to logging so we don't have a feature flag com…
rklaehn Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 49 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"iroh-router",
"net-tools/netwatch",
"net-tools/portmapper",
"iroh-node-util",
]
resolver = "2"

Expand Down
5 changes: 1 addition & 4 deletions iroh-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ console = "0.15.5"
crossterm = "0.27.0"
derive_more = { version = "1.0.0", features = ["display"] }
dialoguer = { version = "0.11.0", default-features = false }
dirs-next = "2.0.0"
futures-buffered = "0.2.4"
futures-lite = "2.3"
futures-util = { version = "0.3.30", features = ["futures-sink"] }
Expand All @@ -45,6 +44,7 @@ iroh-blobs = { version = "0.28.1", features = ["cli"] }
iroh-docs = { version = "0.28.0", features = ["cli"] }
iroh-gossip = { version = "0.28.1", features = ["cli"] }
iroh-metrics = { version = "0.28.0" }
iroh-node-util = { path = "../iroh-node-util", features = ["config", "logging"] }
parking_lot = "0.12.1"
pkarr = { version = "2.2.0", default-features = false }
portable-atomic = "1"
Expand All @@ -56,7 +56,6 @@ ratatui = "0.26.2"
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
rustyline = "12.0.0"
serde = { version = "1.0.197", features = ["derive"] }
serde_with = "3.7.0"
shell-words = "1.1.0"
shellexpand = "3.1.0"
strum = { version = "0.26.2", features = ["derive"] }
Expand All @@ -67,8 +66,6 @@ tokio = { version = "1.36.0", features = ["full"] }
tokio-util = { version = "0.7.12", features = ["rt"] }
toml = { version = "0.8.12", features = ["preserve_order"] }
tracing = "0.1.40"
tracing-appender = "0.2.3"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[dev-dependencies]
duct = "0.13.6"
Expand Down
4 changes: 2 additions & 2 deletions iroh-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl Cli {
)
.await
} else {
crate::logging::init_terminal_logging()?;
iroh_node_util::logging::init_terminal_logging()?;
let iroh = if let Some(addr) = self.rpc_addr {
Iroh::connect_addr(addr).await.context("rpc connect")?
} else {
Expand All @@ -154,7 +154,7 @@ impl Cli {
)
.await
} else {
crate::logging::init_terminal_logging()?;
iroh_node_util::logging::init_terminal_logging()?;
let iroh = if let Some(addr) = self.rpc_addr {
Iroh::connect_addr(addr).await.context("rpc connect")?
} else {
Expand Down
10 changes: 6 additions & 4 deletions iroh-cli/src/commands/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use iroh::{
util::{path::IrohPaths, progress::ProgressWriter},
};
use iroh_metrics::core::Core;
use iroh_node_util::config::data_root;
use portable_atomic::AtomicU64;
use postcard::experimental::max_size::MaxSize;
use rand::Rng;
Expand All @@ -53,7 +54,7 @@ use tokio::{io::AsyncWriteExt, sync};
use tokio_util::task::AbortOnDropHandle;
use tracing::warn;

use crate::config::{iroh_data_root, NodeConfig};
use crate::config::NodeConfig;

/// Options for the secret key usage.
#[derive(Debug, Clone, derive_more::Display)]
Expand Down Expand Up @@ -1016,7 +1017,7 @@ fn create_secret_key(secret_key: SecretKeyOption) -> anyhow::Result<SecretKey> {
SecretKey::try_from(&bytes[..])?
}
SecretKeyOption::Local => {
let path = IrohPaths::SecretKey.with_root(iroh_data_root()?);
let path = IrohPaths::SecretKey.with_root(data_root("iroh")?);
if path.exists() {
let bytes = std::fs::read(&path)?;
SecretKey::try_from_openssh(bytes)?
Expand Down Expand Up @@ -1108,8 +1109,9 @@ fn inspect_ticket(ticket: &str, zbase32: bool) -> anyhow::Result<()> {

/// Runs the doctor commands.
pub async fn run(command: Commands, config: &NodeConfig) -> anyhow::Result<()> {
let data_dir = iroh_data_root()?;
let _guard = crate::logging::init_terminal_and_file_logging(&config.file_logs, &data_dir)?;
let data_dir = data_root("iroh")?;
let _guard =
iroh_node_util::logging::init_terminal_and_file_logging(&config.file_logs, &data_dir)?;
let metrics_fut = super::start::start_metrics_server(config.metrics_addr);
let cmd_res = match command {
Commands::Report {
Expand Down
6 changes: 3 additions & 3 deletions iroh-cli/src/commands/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl RpcCommands {
Self::Tags { command } => command.run(&iroh.tags()).await,
Self::Gossip { command } => command.run(&iroh.gossip()).await,
Self::Stats => {
let stats = iroh.stats().await?;
let stats = iroh.node().stats().await?;
for (name, details) in stats.iter() {
println!(
"{:23} : {:>6} ({})",
Expand All @@ -111,11 +111,11 @@ impl RpcCommands {
Ok(())
}
Self::Shutdown { force } => {
iroh.shutdown(force).await?;
iroh.node().shutdown(force).await?;
Ok(())
}
Self::Status => {
let response = iroh.status().await?;
let response = iroh.node().status().await?;
println!("Listening addresses: {:#?}", response.listen_addrs);
println!("Node ID: {}", response.addr.node_id);
println!("Version: {}", response.version);
Expand Down
3 changes: 2 additions & 1 deletion iroh-cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ where
F: FnOnce(iroh::client::Iroh) -> T + Send + 'static,
T: Future<Output = Result<()>> + 'static,
{
let _guard = crate::logging::init_terminal_and_file_logging(&config.file_logs, iroh_data_root)?;
let _guard =
iroh_node_util::logging::init_terminal_and_file_logging(&config.file_logs, iroh_data_root)?;
let metrics_fut = start_metrics_server(config.metrics_addr);
let metrics_dumper_fut =
start_metrics_dumper(config.metrics_dump_path.clone(), Duration::from_millis(100));
Expand Down
Loading
Loading