Add files via upload
This commit is contained in:
parent
4697b15b69
commit
718f87ec31
2 changed files with 57 additions and 3 deletions
34
src/helpers/avToggle.ts
Normal file
34
src/helpers/avToggle.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
// src/helpers/avToggle.ts
|
||||
|
||||
import {
|
||||
ANTIVIRUS_ENABLED_DEFAULT,
|
||||
CLAMAV_CONFIGURED,
|
||||
} from "./env";
|
||||
|
||||
let antivirusEnabled = ANTIVIRUS_ENABLED_DEFAULT;
|
||||
|
||||
/**
|
||||
* Is ClamAV configured at all (CLAMAV_URL set)?
|
||||
*/
|
||||
export function isAntivirusAvailable(): boolean {
|
||||
return CLAMAV_CONFIGURED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is antivirus scanning currently enabled (and available)?
|
||||
*/
|
||||
export function isAntivirusEnabled(): boolean {
|
||||
return CLAMAV_CONFIGURED && antivirusEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change current antivirus enabled/disabled state.
|
||||
* If CLAMAV is not configured, this is effectively a no-op and remains false.
|
||||
*/
|
||||
export function setAntivirusEnabled(enabled: boolean): void {
|
||||
if (!CLAMAV_CONFIGURED) {
|
||||
antivirusEnabled = false;
|
||||
return;
|
||||
}
|
||||
antivirusEnabled = enabled;
|
||||
}
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
// src/helpers/env.ts
|
||||
|
||||
export const ACCOUNT_REGISTRATION =
|
||||
process.env.ACCOUNT_REGISTRATION?.toLowerCase() === "true" || false;
|
||||
|
||||
export const HTTP_ALLOWED = process.env.HTTP_ALLOWED?.toLowerCase() === "true" || false;
|
||||
export const HTTP_ALLOWED =
|
||||
process.env.HTTP_ALLOWED?.toLowerCase() === "true" || false;
|
||||
|
||||
export const ALLOW_UNAUTHENTICATED =
|
||||
process.env.ALLOW_UNAUTHENTICATED?.toLowerCase() === "true" || false;
|
||||
|
|
@ -10,7 +13,8 @@ export const AUTO_DELETE_EVERY_N_HOURS = process.env.AUTO_DELETE_EVERY_N_HOURS
|
|||
? Number(process.env.AUTO_DELETE_EVERY_N_HOURS)
|
||||
: 24;
|
||||
|
||||
export const HIDE_HISTORY = process.env.HIDE_HISTORY?.toLowerCase() === "true" || false;
|
||||
export const HIDE_HISTORY =
|
||||
process.env.HIDE_HISTORY?.toLowerCase() === "true" || false;
|
||||
|
||||
export const WEBROOT = process.env.WEBROOT ?? "";
|
||||
|
||||
|
|
@ -24,5 +28,21 @@ export const MAX_CONVERT_PROCESS =
|
|||
export const UNAUTHENTICATED_USER_SHARING =
|
||||
process.env.UNAUTHENTICATED_USER_SHARING?.toLowerCase() === "true" || false;
|
||||
|
||||
export const CLAMAV_URL = process.env.CLAMAV_URL;
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
// ClamAV / Antivirus integration
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
|
||||
// REST endpoint of benzino77/clamav-rest-api, e.g.
|
||||
// CLAMAV_URL=http://192.168.68.134:3000/api/v1/scan
|
||||
export const CLAMAV_URL = process.env.CLAMAV_URL ?? "";
|
||||
|
||||
// True only if CLAMAV_URL is non-empty
|
||||
export const CLAMAV_CONFIGURED = CLAMAV_URL.length > 0;
|
||||
|
||||
// Default AV toggle value:
|
||||
// - If ANTIVIRUS_ENABLED_DEFAULT=false → force disabled
|
||||
// - Otherwise: enabled only when CLAMAV is configured
|
||||
export const ANTIVIRUS_ENABLED_DEFAULT =
|
||||
process.env.ANTIVIRUS_ENABLED_DEFAULT?.toLowerCase() === "false"
|
||||
? false
|
||||
: CLAMAV_CONFIGURED;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue