mirror of
https://github.com/house-of-vanity/khm.git
synced 2025-07-07 15:24:07 +00:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
2f1fcd681e | |||
26acbf75ac |
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1064,7 +1064,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "khm"
|
name = "khm"
|
||||||
version = "0.4.0"
|
version = "0.4.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.4.1"
|
version = "0.4.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["AB <ab@hexor.cy>"]
|
authors = ["AB <ab@hexor.cy>"]
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ Options:
|
|||||||
- `--db-name <DB_NAME>` Server mode: Name of the PostgreSQL database [default: khm]
|
- `--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-user <DB_USER>` Server mode: Username for the PostgreSQL database
|
||||||
- `--db-password <DB_PASSWORD>` Server mode: Password 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>`
|
- `--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]
|
- `--known-hosts <KNOWN_HOSTS>` Client mode: Path to the known_hosts file [default: ~/.ssh/known_hosts]
|
||||||
|
|
||||||
@ -61,4 +62,4 @@ Contributions are welcome! Please open an issue or submit a pull request for any
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This project is licensed under the WTFPL License.
|
This project is licensed under the WTFPL License.
|
||||||
|
@ -35,8 +35,6 @@ pub fn is_valid_ssh_key(key: &str) -> bool {
|
|||||||
|| ed25519_re.is_match(key)
|
|| 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> {
|
pub async fn get_keys_from_db(client: &Client) -> Result<Vec<Flow>, tokio_postgres::Error> {
|
||||||
let rows = client.query(
|
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",
|
"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
|
// Always try to associate all keys with the flow, regardless of whether they're new or existing
|
||||||
if key_stats.inserted > 0 {
|
if !key_stats.key_id_map.is_empty() {
|
||||||
// Extract only key IDs from statistics
|
// 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();
|
let key_ids: Vec<i32> = key_stats.key_id_map.iter().map(|(_, id)| *id).collect();
|
||||||
|
|
||||||
// Batch insert key-flow associations
|
// Batch insert key-flow associations
|
||||||
@ -209,7 +207,7 @@ pub async fn add_keys(
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
info!(
|
info!(
|
||||||
"No new keys to associate from client '{}' with flow '{}'",
|
"No keys to associate from client '{}' with flow '{}'",
|
||||||
client_hostname, flow_id_str
|
client_hostname, flow_id_str
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user