summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-12-20 09:55:45 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-12-20 09:55:45 +0100
commit1ef607dc33e0c1204ac6d9509a074e88d692aa86 (patch)
tree52803055399790030e73a62d42b96306fbbef550
parent2ecb95a4b0dec4abd47dbdbf96dfc198165625f2 (diff)
Let client connect to multiple other clients
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--cli/src/cli.rs1
-rw-r--r--cli/src/profile.rs18
2 files changed, 13 insertions, 6 deletions
diff --git a/cli/src/cli.rs b/cli/src/cli.rs
index ee8d608..4b0b0f5 100644
--- a/cli/src/cli.rs
+++ b/cli/src/cli.rs
@@ -46,6 +46,7 @@ pub fn app<'a>() -> App<'a> {
.long("connect")
.required(false)
.takes_value(true)
+ .multiple(true)
.value_name("MULTIADDR")
.about("Connect to MULTIADDR as well")
)
diff --git a/cli/src/profile.rs b/cli/src/profile.rs
index 87b1e54..c239bc5 100644
--- a/cli/src/profile.rs
+++ b/cli/src/profile.rs
@@ -36,10 +36,14 @@ async fn profile_serve(matches: &ArgMatches) -> Result<()> {
use ipfs::MultiaddrWithPeerId;
let name = matches.value_of("name").map(String::from).unwrap(); // required
- let connect_peer = matches.value_of("connect").map(|s| {
- s.parse::<MultiaddrWithPeerId>()
- .map_err(anyhow::Error::from)
- }).transpose()?;
+ let connect_peer = matches.values_of("connect")
+ .map(|v| {
+ v.map(|s| {
+ s.parse::<MultiaddrWithPeerId>().map_err(anyhow::Error::from)
+ })
+ .collect::<Result<Vec<_>>>()
+ })
+ .transpose()?;
let state_dir = Profile::state_dir_path(&name)?;
@@ -51,8 +55,10 @@ async fn profile_serve(matches: &ArgMatches) -> Result<()> {
}
if let Some(connect_to) = connect_peer {
- log::info!("Connecting to {:?}", connect_to);
- profile.connect(connect_to).await?;
+ for c in connect_to {
+ log::info!("Connecting to {:?}", c);
+ profile.connect(c).await?;
+ }
}
let running = Arc::new(AtomicBool::new(true));