2 Commits

Author SHA1 Message Date
2f1fcd681e Update README.MD 2025-05-12 02:46:25 +03:00
A B
26acbf75ac Fix cross-flow keys 2025-05-11 23:44:18 +00:00
4 changed files with 8 additions and 9 deletions

2
Cargo.lock generated
View File

@ -1064,7 +1064,7 @@ dependencies = [
[[package]]
name = "khm"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"actix-web",
"base64 0.21.7",

View File

@ -1,6 +1,6 @@
[package]
name = "khm"
version = "0.4.1"
version = "0.4.2"
edition = "2021"
authors = ["AB <ab@hexor.cy>"]

View File

@ -38,6 +38,7 @@ Options:
- `--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
- `--basic-auth <BASIC_AUTH>` Client mode: Basic Auth credentials [default: ""]
- `--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]

View File

@ -35,8 +35,6 @@ pub fn is_valid_ssh_key(key: &str) -> bool {
|| ed25519_re.is_match(key)
}
// Note: Removed unused functions insert_key_if_not_exists and insert_flow_key
pub async fn get_keys_from_db(client: &Client) -> Result<Vec<Flow>, tokio_postgres::Error> {
let rows = client.query(
"SELECT k.host, k.key, f.name FROM public.keys k INNER JOIN public.flows f ON k.key_id = f.key_id",
@ -185,9 +183,9 @@ pub async fn add_keys(
}
};
// If there are no new keys, no need to update flow associations
if key_stats.inserted > 0 {
// Extract only key IDs from statistics
// Always try to associate all keys with the flow, regardless of whether they're new or existing
if !key_stats.key_id_map.is_empty() {
// Extract all key IDs from statistics, both new and existing
let key_ids: Vec<i32> = key_stats.key_id_map.iter().map(|(_, id)| *id).collect();
// Batch insert key-flow associations
@ -209,7 +207,7 @@ pub async fn add_keys(
);
} else {
info!(
"No new keys to associate from client '{}' with flow '{}'",
"No keys to associate from client '{}' with flow '{}'",
client_hostname, flow_id_str
);
}