4 Commits

Author SHA1 Message Date
b4c2fae778 Fix readme 2024-11-11 12:48:00 +02:00
61552a3d70 Fix help a bit. 2024-11-11 12:46:55 +02:00
AB
3ca8e27ded Bump version in Cargo.toml 2024-09-25 15:40:40 +03:00
AB
2b7b3b9a22 Fix help text. Added nix-shell to build locally 2024-09-25 15:24:21 +03:00
4 changed files with 45 additions and 32 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "khm"
version = "0.2.0"
version = "0.2.2"
edition = "2021"
authors = ["AB <ab@hexor.cy>", "ChatGPT-4o"]
@ -15,4 +15,4 @@ tokio = { version = "1", features = ["full"] }
tokio-postgres = { version = "0.7", features = ["with-chrono-0_4"] }
clap = { version = "4", features = ["derive"] }
chrono = "0.4.38"
reqwest = { version = "0.12", features = ["json"] }
reqwest = { version = "0.12", features = ["json"] }

View File

@ -24,21 +24,23 @@ khm --server --ip 127.0.0.1 --port 8080 --db-host 127.0.0.1 --db-name khm --db-u
To run the application in client mode, use the following command:
```bash
khm --host http://khm.example.com:8080 --known-hosts ~/.ssh/known_hosts --in-place
khm --host http://khm.example.com:8080/<FLOW_NAME>/ --known-hosts ~/.ssh/known_hosts --in-place
```
### Arguments
- `--server`: Run in server mode (default: false).
- `--ip`: IP address to bind the server or client to (default: 127.0.0.1).
- `--port`: Port to bind the server or client to (default: 8080).
- `--db-host`: Hostname or IP address of the PostgreSQL database (default: 127.0.0.1).
- `--db-name`: Name of the PostgreSQL database (default: khm).
- `--db-user`: Username for the PostgreSQL database (required in server mode).
- `--db-password`: Password for the PostgreSQL database (required in server mode).
- `--host`: Host address of the server to connect to in client mode (required in client mode).
- `--known-hosts`: Path to the `known_hosts` file (default: ~/.ssh/known_hosts).
- `--in-place`: Update the `known_hosts` file with keys from the server after sending keys (default: false).
- `--flows`: Comma-separated list of flows to manage (default: default).
Options:
- `--server` Run in server mode
- `--in-place` Server mode: Sync the known_hosts file with keys from the server
- `--flows <FLOWS>...` Server mode: Comma-separated list of flows to manage [default: default]
- `-i, --ip <IP>` Server mode: IP address to bind the server to [default: 127.0.0.1]
- `-p, --port <PORT>` Server mode: Port to bind the server to [default: 8080]
- `--db-host <DB_HOST>` Server mode: Hostname or IP address of the PostgreSQL database [default: 127.0.0.1]
- `--db-name <DB_NAME>` Server mode: Name of the PostgreSQL database [default: khm]
- `--db-user <DB_USER>` Server mode: Username for the PostgreSQL database
- `--db-password <DB_PASSWORD>` Server mode: Password for the PostgreSQL database
- `--host <HOST>` Client mode: Full host address of the server to connect to. Like `https://khm.example.com/<FLOW_NAME>`
- `--known-hosts <KNOWN_HOSTS>` Client mode: Path to the known_hosts file [default: ~/.ssh/known_hosts]
## Installation

11
shell.nix Normal file
View File

@ -0,0 +1,11 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = [
pkgs.openssl
pkgs.pkg-config
];
shellHook = ''
unset OPENSSL_DIR
'';
}

View File

@ -19,12 +19,27 @@ use log::{error, info};
Running in server mode:\n\
khm --server --ip 0.0.0.0 --port 1337 --db-host psql.psql.svc --db-name khm --db-user admin --db-password <SECRET> --flows work,home\n\
\n\
Running in client mode to send diff and sync ~/.ssh/known_hosts with remote flow in place:\n\
khm --host http://kh.example.com:8080 --known-hosts ~/.ssh/known_hosts --in-place\n\
Running in client mode to send diff and sync ~/.ssh/known_hosts with remote flow `work` in place:\n\
khm --host https://khm.example.com/work --known-hosts ~/.ssh/known_hosts --in-place\n\
\n\
"
)]
struct Args {
/// Run in server mode (default: false)
#[arg(long, help = "Run in server mode")]
server: bool,
/// Update the known_hosts file with keys from the server after sending keys (default: false)
#[arg(
long,
help = "Server mode: Sync the known_hosts file with keys from the server"
)]
in_place: bool,
/// Comma-separated list of flows to manage (default: default)
#[arg(long, default_value = "default", value_parser, num_args = 1.., value_delimiter = ',', help = "Server mode: Comma-separated list of flows to manage")]
flows: Vec<String>,
/// IP address to bind the server or client to (default: 127.0.0.1)
#[arg(
short,
@ -79,14 +94,10 @@ struct Args {
#[arg(
long,
required_if_eq("server", "false"),
help = "Client mode: Host address of the server to connect to"
help = "Client mode: Full host address of the server to connect to. Like https://khm.example.com/<FLOW_NAME>"
)]
host: Option<String>,
/// Run in server mode (default: false)
#[arg(long, help = "Run in server mode")]
server: bool,
/// Path to the known_hosts file (default: ~/.ssh/known_hosts)
#[arg(
long,
@ -94,17 +105,6 @@ struct Args {
help = "Client mode: Path to the known_hosts file"
)]
known_hosts: String,
/// Update the known_hosts file with keys from the server after sending keys (default: false)
#[arg(
long,
help = "Server mode: Sync the known_hosts file with keys from the server"
)]
in_place: bool,
/// Comma-separated list of flows to manage (default: default)
#[arg(long, default_value = "default", value_parser, num_args = 1.., value_delimiter = ',', help = "Comma-separated list of flows to manage")]
flows: Vec<String>,
}
#[actix_web::main]