This commit is contained in:
Mateusz Gruszczyński committed 2026-10-05 09:30:21 +02:00
1 parent 1dea7f55c8
commit c819f0a335
151 files changed
+7610 -4264

No files matched your search

+28 -17
View File
@@ -66,7 +66,6 @@ async fn cache_purge(
))
}
async fn cache_invalidate(
State(state): State<Arc<App>>,
Extension(session): Extension<Session>,
@@ -123,11 +122,18 @@ async fn cache_ban_delete(
Path(id): Path<u64>,
) -> Result<Json<Value>, ApiError> {
if !state.cache.remove_ban(id) {
return Err(ApiError(StatusCode::NOT_FOUND, "unknown cache BAN rule".into()));
return Err(ApiError(
StatusCode::NOT_FOUND,
"unknown cache BAN rule".into(),
));
}
state
.store
.audit(&session.username, "cache.ban.remove", &format!("ban_id={id}"))
.audit(
&session.username,
"cache.ban.remove",
&format!("ban_id={id}"),
)
.await
.map_err(auth::internal)?;
Ok(Json(json!({"removed": id, "bans": state.cache.bans()})))
@@ -164,7 +170,10 @@ async fn kill_tunnel(
));
}
let Some(tunnel) = state.tunnel_registry.kill(id) else {
return Err(ApiError(StatusCode::NOT_FOUND, "unknown active tunnel".into()));
return Err(ApiError(
StatusCode::NOT_FOUND,
"unknown active tunnel".into(),
));
};
state
.store
@@ -207,10 +216,12 @@ async fn cache_cold_cleanup_job(
State(state): State<Arc<App>>,
Path(id): Path<u64>,
) -> Result<Json<Value>, ApiError> {
let job = state
.cache
.cold_cleanup_job(id)
.ok_or_else(|| ApiError(StatusCode::NOT_FOUND, "unknown cold-cache cleanup job".into()))?;
let job = state.cache.cold_cleanup_job(id).ok_or_else(|| {
ApiError(
StatusCode::NOT_FOUND,
"unknown cold-cache cleanup job".into(),
)
})?;
Ok(Json(json!({"job": job})))
}
#[derive(Deserialize)]
@@ -268,7 +279,6 @@ async fn certificate_upload(
Ok(Json(json!({"certificate":certificate, "staged":true})))
}
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct CertificateApiRotate {
@@ -339,12 +349,7 @@ async fn certificate_api_rotate(
let token_hash = auth::secret_hash(&token);
let credential = state
.store
.upsert_certificate_api_credential(
&key_id,
&token_hash,
&comment,
&session.username,
)
.upsert_certificate_api_credential(&key_id, &token_hash, &comment, &session.username)
.await
.map_err(|error| {
if error.to_string().contains("credential limit reached") {
@@ -371,7 +376,10 @@ async fn certificate_api_revoke(
Path(key_id): Path<String>,
) -> Result<Json<Value>, ApiError> {
if !valid_certificate_api_key_id(&key_id) {
return Err(ApiError(StatusCode::NOT_FOUND, "certificate_api.not_found".into()));
return Err(ApiError(
StatusCode::NOT_FOUND,
"certificate_api.not_found".into(),
));
}
let revoked = state
.store
@@ -379,7 +387,10 @@ async fn certificate_api_revoke(
.await
.map_err(auth::internal)?;
if !revoked {
return Err(ApiError(StatusCode::NOT_FOUND, "certificate_api.not_found".into()));
return Err(ApiError(
StatusCode::NOT_FOUND,
"certificate_api.not_found".into(),
));
}
Ok(Json(json!({"revoked": true, "key_id": key_id})))
}