aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-12-05 23:18:41 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-12-05 23:18:41 -0800
commit66b1ee42a5318c09b005f253dfddef371e6955f4 (patch)
tree4544c2f0b27326fb30345e856b7eadc47244a34e /src/bin
parentf3c0199e4c59e357dccbc289c687155905fc28e4 (diff)
downloadgeniza-66b1ee42a5318c09b005f253dfddef371e6955f4.tar.gz
geniza-66b1ee42a5318c09b005f253dfddef371e6955f4.zip
geniza-net cleanups
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/geniza-net.rs27
1 files changed, 4 insertions, 23 deletions
diff --git a/src/bin/geniza-net.rs b/src/bin/geniza-net.rs
index e6fa448..11bcee8 100644
--- a/src/bin/geniza-net.rs
+++ b/src/bin/geniza-net.rs
@@ -40,8 +40,8 @@ fn run() -> Result<()> {
.arg_from_usage("<dat_key> 'dat key (public key) to register with'"),
)
.subcommand(
- SubCommand::with_name("receive-all")
- .about("Connects to a peer, pulls all metadata and content")
+ SubCommand::with_name("receive-some")
+ .about("Connects to a peer, pulls some 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'"),
)
@@ -80,26 +80,13 @@ fn run() -> Result<()> {
("connect", 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 key_bytes = parse_dat_key(&dat_key)?;
DatConnection::connect(host_port, &key_bytes, false)?;
println!("Done!");
}
- ("receive-all", Some(subm)) => {
+ ("receive-some", 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 key_bytes = parse_dat_key(&dat_key)?;
let mut dc = DatConnection::connect(host_port, &key_bytes, false)?;
// XXX: number here totally arbitrary
@@ -109,9 +96,6 @@ fn run() -> Result<()> {
}
("discovery-key", Some(subm)) => {
let dat_key = subm.value_of("dat_key").unwrap();
- if dat_key.len() != 32 * 2 {
- bail!("dat key not correct length");
- }
let key_bytes = parse_dat_key(&dat_key)?;
let disc_key = make_discovery_key(&key_bytes);
for b in disc_key {
@@ -121,9 +105,6 @@ fn run() -> Result<()> {
}
("discovery-dns-name", Some(subm)) => {
let dat_key = subm.value_of("dat_key").unwrap();
- if dat_key.len() != 32 * 2 {
- bail!("dat key not correct length");
- }
let key_bytes = parse_dat_key(&dat_key)?;
let disc_key = make_discovery_key(&key_bytes);
for b in 0..20 {