aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-10-25 00:18:48 -0700
committerBryan Newbold <bnewbold@robocracy.org>2017-10-25 00:18:48 -0700
commitb330843fb1788d7882f72ce9cbaf526e1bb91e56 (patch)
tree9e089672c2047f89a1e940d8f4adee3d71b9f456 /src/bin
parent91d3f4e6307ecd4031aee7cdefdc7da4aa37d2be (diff)
downloadgeniza-b330843fb1788d7882f72ce9cbaf526e1bb91e56.tar.gz
geniza-b330843fb1788d7882f72ce9cbaf526e1bb91e56.zip
unencrypted networking
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/geniza-net.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/bin/geniza-net.rs b/src/bin/geniza-net.rs
index 0f413a8..de97e88 100644
--- a/src/bin/geniza-net.rs
+++ b/src/bin/geniza-net.rs
@@ -16,6 +16,10 @@ fn run() -> Result<()> {
.about("Connects to a peer and exchanges handshake")
.arg_from_usage("<host_port> 'peer host:port to connect to'")
.arg_from_usage("<dat_key> 'dat key (public key) to register with'"))
+ .subcommand(SubCommand::with_name("clone")
+ .about("Connects to a peer, pulls all metadata and content")
+ .arg_from_usage("<host_port> 'peer host:port to connect to'")
+ .arg_from_usage("<dat_key> 'dat key (public key) to register with'"))
.get_matches();
@@ -36,7 +40,30 @@ fn run() -> Result<()> {
}
DatConnection::connect(
host_port,
- &key_bytes)?;
+ &key_bytes,
+ false)?;
+ println!("Done!");
+ },
+ ("clone", Some(subm)) => {
+ let host_port = subm.value_of("host_port").unwrap();
+ let dat_key = subm.value_of("dat_key").unwrap();
+ if dat_key.len() != 32*2 {
+ bail!("dat key not correct length");
+ }
+ let mut key_bytes = vec![];
+ for i in 0..32 {
+ let r = u8::from_str_radix(&dat_key[2*i .. 2*i+2], 16);
+ match r {
+ Ok(b) => key_bytes.push(b),
+ Err(e) => bail!("Problem with hex: {}", e),
+ };
+ }
+ let mut dc = DatConnection::connect(
+ host_port,
+ &key_bytes,
+ false)?;
+ dc.receive_all(false)?;
+ dc.receive_all(true)?;
println!("Done!");
},
_ => {