From a699c92cdceb0382d9bfec37724166145a7eb6df Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 28 Nov 2017 23:34:35 -0800 Subject: WIP on node (synchronization) code --- src/bin/geniza-net.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/bin/geniza-net.rs') diff --git a/src/bin/geniza-net.rs b/src/bin/geniza-net.rs index 38dc507..dd80c4f 100644 --- a/src/bin/geniza-net.rs +++ b/src/bin/geniza-net.rs @@ -55,6 +55,19 @@ fn run() -> Result<()> { .about("Prints the DNS name to query (mDNS or centrally) for peers") .arg_from_usage(" 'dat key (public key) to convert (in hex)'"), ) + .subcommand( + SubCommand::with_name("naive-clone") + .about("Pulls a drive from a single (known) peer, using a naive algorithm") + .arg(Arg::with_name("dat-dir") + .short("d") + .long("dat-dir") + .value_name("PATH") + .help("dat drive directory") + .default_value(".dat") + .takes_value(true)) + .arg_from_usage(" 'peer host:port to connect to'") + .arg_from_usage(" 'dat key (public key) to pull"), + ) .get_matches(); @@ -113,6 +126,17 @@ fn run() -> Result<()> { } println!(".dat.local"); } + ("naive-clone", Some(subm)) => { + let host_port = subm.value_of("host_port").unwrap(); + let dat_key = subm.value_of("dat_key").unwrap(); + let key_bytes = parse_dat_key(&dat_key)?; + let dir = Path::new(subm.value_of("dat-dir").unwrap()); + let mut metadata = SleepDirRegister::create(&dir, "metadata")?; + node_simple_clone(host_port, &key_bytes, &mut metadata, false)?; + // TODO: read out content key from metadata register + //let content = SleepDirRegister::create(&dir, "content")?; + //node_simple_clone(host_port, &key_bytes, &mut content, true)?; + } _ => { println!("Missing or unimplemented command!"); println!("{}", matches.usage()); -- cgit v1.2.3