why2_chat/consts.rs
1/*
2This is part of WHY2
3Copyright (C) 2022-2026 Václav Šmejkal
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 3 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <https://www.gnu.org/licenses/>.
17*/
18
19use std::
20{
21 net::TcpStream,
22 sync::{ Arc, Mutex },
23};
24
25use zeroize::Zeroizing;
26
27//CONSTS
28pub const METADATA_URL: &str = "https://crates.io/api/v1/crates/why2-chat"; //URL FOR PROJECT METADATA
29
30pub const CONFIG_DIR: &str = env!("WHY2_CONFIG_DIR"); //DIRECTORY FOR CONFIG FILES
31pub const UPLOADS_DIR: &str = "WHY2-Uploads"; //DIRECTORY FOR FILE UPLOADS
32pub const SERVER_CONFIG: &str = "/server.toml"; //SERVER CONFIG FILE
33pub const CLIENT_CONFIG: &str = "/client.toml"; //CLIENT CONFIG FILE
34pub const SERVER_USERS_CONFIG: &str = "/server_users.toml"; //SERVER USERS CONFIG FILE
35
36pub const SERVER_KEYS_CONFIG: &str = "/server_keys.toml"; //SERVER PUBKEY CONFIG FILE
37pub const SERVER_KEYS_DIR: &str = "/server_keys"; //SERVER KEYS DIRECTORY
38pub const SERVER_SKEY: &str = "/private"; //SERVER PRIVATE KEY FILE
39pub const SERVER_PKEY: &str = "/public"; //SERVER PUBLIC KEY FILE
40pub const SERVER_PQ_SKEY: &str = "/private_pq"; //SERVER POST-QUANTUM PRIVATE KEY FILE
41pub const SERVER_PQ_PKEY: &str = "/public_pq"; //SERVER POST-QUANTUM PUBLIC KEY FILE
42
43pub const FETCH_TIMEOUT: u64 = 5000; //TIMOUT FOR FETCHING DATA (MS)
44
45pub const REKEY_INTERVAL: u64 = 600; //INTERVAL FOR RE-REKEYING (SECS)
46
47//DO NOT CHANGE CONSTS BELOW UNLESS YOU ARE ABSOLUTELY SURE WHAT ARE YOU DOING
48pub const UPLOAD_CHUNK_SIZE: usize = 1_048_576; //FILE UPLOAD CHUNK (1MB)
49
50//TYPES
51pub type SharedKeys = (Zeroizing<Vec<i64>>, Zeroizing<Vec<u8>>); //WHY2 KEY, HMAC
52pub type Streams<'a> = (&'a mut TcpStream, Arc<Mutex<TcpStream>>); //READ STREAM, WRITE STREAM