lox_cli/src/bin/lox_client.rs

43 lines
1.4 KiB
Rust
Raw Normal View History

// This seems like probably not the best way to do this, but it works.
#[path = "../client_net.rs"]
mod client_net;
use crate::client_net::send;
use ed25519_dalek::PublicKey;
use lox::IssuerPubKey;
use std::env::args;
use std::fs::File;
#[tokio::main]
async fn main() {
let bridgedb_pubkey_filename = "bridgedb_pubkey.json";
let lox_auth_pubkeys_filename = "lox_auth_pubkeys.json";
// TODO: make argument passing nicer (maybe flags, config files, etc.)
// network address to connect to, e.g., localhost:8080
let addr = args().nth(1).unwrap();
// message to send
// TODO: determine commands so the client sends something meaningful
let msg = args().nth(2).unwrap();
// import bridgedb pubkey
let bridgedb_pubkey_infile = File::open(bridgedb_pubkey_filename).unwrap();
let bridgedb_pubkey: PublicKey = serde_json::from_reader(bridgedb_pubkey_infile).unwrap();
// import lox_auth pubkeys
let lox_auth_pubkeys_infile = File::open(lox_auth_pubkeys_filename).unwrap();
2022-11-24 22:48:58 -05:00
let lox_auth_pubkeys: Vec<IssuerPubKey> =
serde_json::from_reader(lox_auth_pubkeys_infile).unwrap();
let lox_pub = &lox_auth_pubkeys[0];
let migration_pub = &lox_auth_pubkeys[1];
let migrationkey_pub = &lox_auth_pubkeys[2];
let reachability_pub = &lox_auth_pubkeys[3];
let invitation_pub = &lox_auth_pubkeys[4];
2023-01-21 20:01:31 -05:00
let s = send(addr, msg.into()).await;
println!("{}", serde_json::to_string(&s).unwrap());
}