use crate::utils::file_size_utils::FileSize; /// Name of the cookie that contains session information pub const SESSION_COOKIE_NAME: &str = "X-auth-token"; /// Maximum session duration after inactivity, in seconds pub const MAX_INACTIVITY_DURATION: u64 = 60 * 30; /// Maximum session duration (6 hours) pub const MAX_SESSION_DURATION: u64 = 3600 * 6; /// The routes that can be accessed without authentication pub const ROUTES_WITHOUT_AUTH: [&str; 5] = [ "/", "/api/server/static_config", "/api/auth/local", "/api/auth/start_oidc", "/api/auth/finish_oidc", ]; /// Allowed ISO mimetypes pub const ALLOWED_ISO_MIME_TYPES: [&str; 4] = [ "application/x-cd-image", "application/x-iso9660-image", "application/octet-stream", "application/vnd.efi.iso", ]; /// ISO max size pub const ISO_MAX_SIZE: FileSize = FileSize::from_gb(10); /// Allowed uploaded disk images formats pub const ALLOWED_DISK_IMAGES_MIME_TYPES: [&str; 4] = [ "application/x-qemu-disk", "application/x-raw-disk-image", "application/gzip", "application/octet-stream", ]; /// Disk image max size pub const DISK_IMAGE_MAX_SIZE: FileSize = FileSize::from_gb(10 * 1000); /// Min VM memory size pub const MIN_VM_MEMORY: FileSize = FileSize::from_mb(100); /// Max VM memory size pub const MAX_VM_MEMORY: FileSize = FileSize::from_gb(64); /// Disk name min length pub const DISK_NAME_MIN_LEN: usize = 2; /// Disk name max length pub const DISK_NAME_MAX_LEN: usize = 10; /// Disk size min (B) pub const DISK_SIZE_MIN: FileSize = FileSize::from_mb(50); /// Disk size max (B) pub const DISK_SIZE_MAX: FileSize = FileSize::from_gb(20000); /// Cloud init generated disk image prefix pub const CLOUD_INIT_IMAGE_PREFIX_NAME: &str = "virtweb-cloudinit-autogen-image"; /// Net nat entry comment max size pub const NET_NAT_COMMENT_MAX_SIZE: usize = 250; /// Network mac address default prefix pub const NET_MAC_ADDR_PREFIX: &str = "52:54:00"; /// Built-in network filter rules pub const BUILTIN_NETWORK_FILTER_RULES: [&str; 24] = [ "allow-arp", "allow-dhcp", "allow-dhcp-server", "allow-dhcpv6", "allow-dhcpv6-server", "allow-incoming-ipv4", "allow-incoming-ipv6", "allow-ipv4", "allow-ipv6", "clean-traffic", "clean-traffic-gateway", "no-arp-ip-spoofing", "no-arp-mac-spoofing", "no-arp-spoofing", "no-ip-multicast", "no-ip-spoofing", "no-ipv6-multicast", "no-ipv6-spoofing", "no-mac-broadcast", "no-mac-spoofing", "no-other-l2-traffic", "no-other-rarp-traffic", "qemu-announce-self", "qemu-announce-self-rarp", ]; /// List of valid network chains pub const NETWORK_CHAINS: [&str; 8] = ["root", "mac", "stp", "vlan", "arp", "rarp", "ipv4", "ipv6"]; /// Directory where nat rules are stored, inside storage directory pub const STORAGE_NAT_DIR: &str = "nat"; /// Environment variable that is set to run VirtWeb in NAT configuration mode pub const NAT_MODE_ENV_VAR_NAME: &str = "NAT_MODE"; /// Nat hook file path pub const NAT_HOOK_PATH: &str = "/etc/libvirt/hooks/network"; /// Directory where API tokens are stored, inside storage directory pub const STORAGE_TOKENS_DIR: &str = "tokens"; /// API token name min length pub const API_TOKEN_NAME_MIN_LENGTH: usize = 3; /// API token name max length pub const API_TOKEN_NAME_MAX_LENGTH: usize = 30; /// API token description min length pub const API_TOKEN_DESCRIPTION_MIN_LENGTH: usize = 5; /// API token description max length pub const API_TOKEN_DESCRIPTION_MAX_LENGTH: usize = 30; /// API token right path max length pub const API_TOKEN_RIGHT_PATH_MAX_LENGTH: usize = 255; /// Qemu image program path pub const PROGRAM_QEMU_IMAGE: &str = "/usr/bin/qemu-img"; /// IP program path pub const PROGRAM_IP: &str = "/usr/sbin/ip"; /// Copy program path pub const PROGRAM_COPY: &str = "/bin/cp"; /// Gzip program path pub const PROGRAM_GZIP: &str = "/usr/bin/gzip"; /// XZ program path pub const PROGRAM_XZ: &str = "/usr/bin/xz"; /// Bash program pub const PROGRAM_BASH: &str = "/usr/bin/bash"; /// DD program pub const PROGRAM_DD: &str = "/usr/bin/dd"; /// cloud-localds program pub const PROGRAM_CLOUD_LOCALDS: &str = "/usr/bin/cloud-localds";