major rewrite of application server & frontend

- adds TOML based configuation files
  - with example configuratios in config-examples
- reimplments arcane CLI argument parser as automaton
- adds a new CLI focused arround configuration files
- moves all file utility stuff from `main.rs` to `util.rs`
- moves all AppServer stuff to dedicated `app_server.rs`
- add mio for multi-listen-socket support (should fix #27)
- consistency: rename private to secret
This commit is contained in:
wucke13
2023-04-15 14:41:08 +02:00
committed by Karolin Varner
parent d5b2a9414f
commit b99d072879
14 changed files with 1560 additions and 765 deletions

View File

@@ -8,21 +8,21 @@ fn generate_keys() {
let tmpdir = PathBuf::from(env!("CARGO_TARGET_TMPDIR")).join("keygen");
fs::create_dir_all(&tmpdir).unwrap();
let priv_key_path = tmpdir.join("private-key");
let pub_key_path = tmpdir.join("public-key");
let secret_key_path = tmpdir.join("secret-key");
let public_key_path = tmpdir.join("public-key");
let output = test_bin::get_test_bin(BIN)
.args(["keygen", "private-key"])
.arg(&priv_key_path)
.arg("public-key")
.arg(&pub_key_path)
.args(["gen-keys", "--secret-key"])
.arg(&secret_key_path)
.arg("--public-key")
.arg(&public_key_path)
.output()
.expect("Failed to start {BIN}");
assert_eq!(String::from_utf8_lossy(&output.stdout), "");
assert!(priv_key_path.is_file());
assert!(pub_key_path.is_file());
assert!(secret_key_path.is_file());
assert!(public_key_path.is_file());
// cleanup
fs::remove_dir_all(&tmpdir).unwrap();
@@ -46,22 +46,22 @@ fn check_exchange() {
let tmpdir = PathBuf::from(env!("CARGO_TARGET_TMPDIR")).join("exchange");
fs::create_dir_all(&tmpdir).unwrap();
let priv_key_paths = [tmpdir.join("private-key-0"), tmpdir.join("private-key-1")];
let pub_key_paths = [tmpdir.join("public-key-0"), tmpdir.join("public-key-1")];
let secret_key_paths = [tmpdir.join("secret-key-0"), tmpdir.join("secret-key-1")];
let public_key_paths = [tmpdir.join("public-key-0"), tmpdir.join("public-key-1")];
let shared_key_paths = [tmpdir.join("shared-key-0"), tmpdir.join("shared-key-1")];
// generate key pairs
for (priv_key_path, pub_key_path) in priv_key_paths.iter().zip(pub_key_paths.iter()) {
for (secret_key_path, pub_key_path) in secret_key_paths.iter().zip(public_key_paths.iter()) {
let output = test_bin::get_test_bin(BIN)
.args(["keygen", "private-key"])
.arg(&priv_key_path)
.arg("public-key")
.args(["gen-keys", "--secret-key"])
.arg(&secret_key_path)
.arg("--public-key")
.arg(&pub_key_path)
.output()
.expect("Failed to start {BIN}");
assert_eq!(String::from_utf8_lossy(&output.stdout), "");
assert!(priv_key_path.is_file());
assert!(secret_key_path.is_file());
assert!(pub_key_path.is_file());
}
@@ -69,12 +69,12 @@ fn check_exchange() {
let port = find_udp_socket();
let listen_addr = format!("localhost:{port}");
let mut server = test_bin::get_test_bin(BIN)
.args(["exchange", "private-key"])
.arg(&priv_key_paths[0])
.args(["exchange", "secret-key"])
.arg(&secret_key_paths[0])
.arg("public-key")
.arg(&pub_key_paths[0])
.arg(&public_key_paths[0])
.args(["listen", &listen_addr, "verbose", "peer", "public-key"])
.arg(&pub_key_paths[1])
.arg(&public_key_paths[1])
.arg("outfile")
.arg(&shared_key_paths[0])
.stdout(Stdio::null())
@@ -82,14 +82,16 @@ fn check_exchange() {
.spawn()
.expect("Failed to start {BIN}");
std::thread::sleep(Duration::from_millis(500));
// start second process, the client
let mut client = test_bin::get_test_bin(BIN)
.args(["exchange", "private-key"])
.arg(&priv_key_paths[1])
.args(["exchange", "secret-key"])
.arg(&secret_key_paths[1])
.arg("public-key")
.arg(&pub_key_paths[1])
.arg(&public_key_paths[1])
.args(["verbose", "peer", "public-key"])
.arg(&pub_key_paths[0])
.arg(&public_key_paths[0])
.args(["endpoint", &listen_addr])
.arg("outfile")
.arg(&shared_key_paths[1])