mirror of
https://github.com/house-of-vanity/khm.git
synced 2025-08-21 14:27:14 +00:00
Fixed client mode flow args
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1064,7 +1064,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "khm"
|
name = "khm"
|
||||||
version = "0.8.1"
|
version = "0.6.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"base64 0.21.7",
|
"base64 0.21.7",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "khm"
|
name = "khm"
|
||||||
version = "0.6.1"
|
version = "0.6.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["AB <ab@hexor.cy>"]
|
authors = ["AB <ab@hexor.cy>"]
|
||||||
|
|
||||||
|
@@ -193,9 +193,12 @@ pub async fn run_client(args: crate::Args) -> std::io::Result<()> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let host = args.host.expect("host is required in client mode");
|
let host = args.host.expect("host is required in client mode");
|
||||||
info!("Client mode: Sending keys to server at {}", host);
|
let flow = args.flow.expect("flow is required in client mode");
|
||||||
|
let url = format!("{}/{}", host, flow);
|
||||||
|
|
||||||
if let Err(e) = send_keys_to_server(&host, keys, &args.basic_auth).await {
|
info!("Client mode: Sending keys to server at {}", url);
|
||||||
|
|
||||||
|
if let Err(e) = send_keys_to_server(&url, keys, &args.basic_auth).await {
|
||||||
error!("Failed to send keys to server: {}", e);
|
error!("Failed to send keys to server: {}", e);
|
||||||
return Err(io::Error::new(
|
return Err(io::Error::new(
|
||||||
io::ErrorKind::Other,
|
io::ErrorKind::Other,
|
||||||
@@ -205,7 +208,7 @@ pub async fn run_client(args: crate::Args) -> std::io::Result<()> {
|
|||||||
|
|
||||||
if args.in_place {
|
if args.in_place {
|
||||||
info!("Client mode: In-place update is enabled. Fetching keys from server.");
|
info!("Client mode: In-place update is enabled. Fetching keys from server.");
|
||||||
let server_keys = match get_keys_from_server(&host, &args.basic_auth).await {
|
let server_keys = match get_keys_from_server(&url, &args.basic_auth).await {
|
||||||
Ok(keys) => keys,
|
Ok(keys) => keys,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to get keys from server: {}", e);
|
error!("Failed to get keys from server: {}", e);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
use crate::server::SshKey;
|
use crate::server::SshKey;
|
||||||
use log::{error, info, warn};
|
use log::{error, info};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use tokio_postgres::tls::NoTlsStream;
|
use tokio_postgres::tls::NoTlsStream;
|
||||||
|
18
src/main.rs
18
src/main.rs
@@ -22,7 +22,7 @@ use log::{error, info};
|
|||||||
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\
|
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\
|
\n\
|
||||||
Running in client mode to send diff and sync ~/.ssh/known_hosts with remote flow `work` 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\
|
khm --host https://khm.example.com --flow work --known-hosts ~/.ssh/known_hosts --in-place\n\
|
||||||
\n\
|
\n\
|
||||||
"
|
"
|
||||||
)]
|
)]
|
||||||
@@ -96,10 +96,18 @@ struct Args {
|
|||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
required_if_eq("server", "false"),
|
required_if_eq("server", "false"),
|
||||||
help = "Client mode: Full host address of the server to connect to. Like https://khm.example.com/<FLOW_NAME>"
|
help = "Client mode: Full host address of the server to connect to. Like https://khm.example.com"
|
||||||
)]
|
)]
|
||||||
host: Option<String>,
|
host: Option<String>,
|
||||||
|
|
||||||
|
/// Flow name to use on the server
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
required_if_eq("server", "false"),
|
||||||
|
help = "Client mode: Flow name to use on the server"
|
||||||
|
)]
|
||||||
|
flow: Option<String>,
|
||||||
|
|
||||||
/// Path to the known_hosts file (default: ~/.ssh/known_hosts)
|
/// Path to the known_hosts file (default: ~/.ssh/known_hosts)
|
||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
@@ -121,9 +129,9 @@ async fn main() -> std::io::Result<()> {
|
|||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
// Check if we have the minimum required arguments
|
// Check if we have the minimum required arguments
|
||||||
if !args.server && args.host.is_none() {
|
if !args.server && (args.host.is_none() || args.flow.is_none()) {
|
||||||
// Neither server mode nor client mode properly configured
|
// Neither server mode nor client mode properly configured
|
||||||
eprintln!("Error: You must specify either server mode (--server) or client mode (--host)");
|
eprintln!("Error: You must specify either server mode (--server) or client mode (--host and --flow)");
|
||||||
eprintln!();
|
eprintln!();
|
||||||
eprintln!("Examples:");
|
eprintln!("Examples:");
|
||||||
eprintln!(
|
eprintln!(
|
||||||
@@ -131,7 +139,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
env!("CARGO_PKG_NAME")
|
env!("CARGO_PKG_NAME")
|
||||||
);
|
);
|
||||||
eprintln!(
|
eprintln!(
|
||||||
" Client mode: {} --host https://khm.example.com/work",
|
" Client mode: {} --host https://khm.example.com --flow work",
|
||||||
env!("CARGO_PKG_NAME")
|
env!("CARGO_PKG_NAME")
|
||||||
);
|
);
|
||||||
eprintln!();
|
eprintln!();
|
||||||
|
Reference in New Issue
Block a user