-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: expose ja4db update over the http api
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-FileCopyrightText: (C) 2024 Jason Ish <[email protected]> | ||
// SPDX-License-Identifier: MIT | ||
|
||
use std::sync::Arc; | ||
|
||
use axum::{Extension, Json}; | ||
use tracing::info; | ||
|
||
use crate::server::{main::SessionExtractor, ServerContext}; | ||
|
||
use super::ApiError; | ||
|
||
pub(super) async fn update_ja4db( | ||
context: Extension<Arc<ServerContext>>, | ||
_session: SessionExtractor, | ||
) -> Result<Json<serde_json::Value>, ApiError> { | ||
let mut conn = context.config_repo.pool.begin().await?; | ||
info!("Updating JA4db"); | ||
let n = crate::commands::ja4db::updatedb(&mut conn).await?; | ||
conn.commit().await?; | ||
let response = json!({ | ||
"entries": n, | ||
}); | ||
info!("JA4db successfully updated: entries={n}"); | ||
Ok(Json(response)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters