feat: added a client, but forgot to add signing

This commit is contained in:
Andrew Rioux
2023-04-28 18:05:08 -04:00
parent 40d105b043
commit 50bca92194
6 changed files with 79 additions and 5 deletions

View File

@@ -6,3 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.70"
ed25519-dalek = "1.0.1"

View File

@@ -1,3 +1,58 @@
fn main() {
println!("Hello, world!");
use std::{io::prelude::*, net::UdpSocket, thread};
use anyhow::anyhow;
const PRIVKEY: &[u8] = include_bytes!("../../key-generator/privkey");
fn main() -> anyhow::Result<()> {
let privkey =
let mut stdout = std::io::stdout();
let mut stderr = std::io::stderr();
let stdin = std::io::stdin();
let mut args = std::env::args();
args.next();
let target = args.next().ok_or(anyhow!("Please specify a target IP"))?;
let remote_stdin = UdpSocket::bind("0.0.0.0:0")?;
let remote_stdout = UdpSocket::bind("0.0.0.0:54248")?;
let remote_stderr = UdpSocket::bind("0.0.0.0:54249")?;
let out_thread = thread::spawn(move || {
let mut buffer = [0u8; 1024];
loop {
let Ok(amount) = remote_stdout.recv(&mut buffer[..]) else { continue; };
let Ok(_) = stdout.write(&mut buffer[..amount]) else { continue; };
}
});
let err_thread = thread::spawn(move || {
let mut buffer = [0u8; 1024];
loop {
let Ok(amount) = remote_stderr.recv(&mut buffer[..]) else { continue; };
let Ok(_) = stderr.write(&mut buffer[..amount]) else { continue; };
}
});
loop {
let mut cmd = String::new();
let Ok(_) = stdin.read_line(&mut cmd) else { continue; };
let cmd = cmd.trim();
if cmd == "exit" {
break;
}
let Ok(_) = remote_stdin.send_to(cmd.as_bytes(), &target) else {
continue;
};
}
drop(out_thread);
drop(err_thread);
Ok(())
}