1 use crate::{commons::actor::ActorDef, daemon::auth::common::NoResourceType};
2 
3 pub const KRILL_VERSION: &str = env!("CARGO_PKG_VERSION");
4 pub const KRILL_VERSION_MAJOR: &str = env!("CARGO_PKG_VERSION_MAJOR");
5 pub const KRILL_VERSION_MINOR: &str = env!("CARGO_PKG_VERSION_MINOR");
6 pub const KRILL_VERSION_PATCH: &str = env!("CARGO_PKG_VERSION_PATCH");
7 pub const KRILL_SERVER_APP: &str = "Krill";
8 pub const KRILL_CLIENT_APP: &str = "Krill Client";
9 pub const KRILL_PUBC_CLIENT_APP: &str = "Krill Publication Server Client";
10 
11 #[cfg(not(feature = "multi-user"))]
12 pub const KRILL_DEFAULT_CONFIG_FILE: &str = "./defaults/krill.conf";
13 #[cfg(feature = "multi-user")]
14 pub const KRILL_DEFAULT_CONFIG_FILE: &str = "./defaults/krill-multi-user.conf";
15 
16 const KRILL_ENV_TEST: &str = "KRILL_TEST";
17 const KRILL_ENV_TEST_ANN: &str = "KRILL_TEST_ANN";
18 pub const KRILL_ENV_UPGRADE_ONLY: &str = "KRILL_UPGRADE_ONLY";
19 pub const KRILL_ENV_FORCE_RECOVER: &str = "KRILL_FORCE_RECOVER";
20 pub const KRILL_ENV_LOG_LEVEL: &str = "KRILL_LOG_LEVEL";
21 pub const KRILL_ENV_ADMIN_TOKEN: &str = "KRILL_ADMIN_TOKEN";
22 pub const KRILL_ENV_ADMIN_TOKEN_DEPRECATED: &str = "KRILL_AUTH_TOKEN";
23 pub const KRILL_ENV_SERVER_PORT: &str = "KRILL_SERVER_PORT";
24 pub const KRILL_ENV_HTTP_LOG_INFO: &str = "KRILL_HTTP_LOG_INFO";
25 
enable_test_mode()26 pub fn enable_test_mode() {
27     std::env::set_var(KRILL_ENV_TEST, "1");
28 }
29 
test_mode_enabled() -> bool30 pub fn test_mode_enabled() -> bool {
31     std::env::var(KRILL_ENV_TEST).is_ok()
32 }
33 
enable_test_announcements()34 pub fn enable_test_announcements() {
35     std::env::set_var(KRILL_ENV_TEST_ANN, "1");
36 }
37 
test_announcements_enabled() -> bool38 pub fn test_announcements_enabled() -> bool {
39     std::env::var(KRILL_ENV_TEST_ANN).is_ok()
40 }
41 
42 pub const CASERVER_DIR: &str = "cas";
43 pub const CA_OBJECTS_DIR: &str = "ca_objects";
44 
45 pub const PUBSERVER_DFLT: &str = "0";
46 pub const PUBSERVER_DIR: &str = "pubd";
47 pub const PUBSERVER_CONTENT_DIR: &str = "pubd_objects";
48 pub const PUBSERVER_BACKUP_DIR: &str = "pubd_bk";
49 
50 pub const REPOSITORY_DIR: &str = "repo";
51 pub const REPOSITORY_RRDP_DIR: &str = "rrdp";
52 pub const REPOSITORY_RRDP_ARCHIVE_DIR: &str = "archive";
53 pub const RRDP_FIRST_SERIAL: u64 = 1; // RFC 8182 says we MUST use 1 as the first serial
54 pub const REPOSITORY_RSYNC_DIR: &str = "rsync";
55 
56 pub const STATUS_DIR: &str = "status";
57 
58 pub const KRILL_CLI_SERVER_ARG: &str = "server";
59 pub const KRILL_CLI_SERVER_ENV: &str = "KRILL_CLI_SERVER";
60 pub const KRILL_CLI_SERVER_DFLT: &str = "https://localhost:3000/";
61 
62 pub const KRILL_CLI_ADMIN_TOKEN_ARG: &str = "token";
63 pub const KRILL_CLI_TOKEN_ENV: &str = "KRILL_CLI_TOKEN";
64 pub const KRILL_CLI_FORMAT_ARG: &str = "format";
65 pub const KRILL_CLI_FORMAT_ENV: &str = "KRILL_CLI_FORMAT";
66 pub const KRILL_CLI_API_ARG: &str = "api";
67 pub const KRILL_CLI_API_ENV: &str = "KRILL_CLI_API";
68 pub const KRILL_CLI_MY_CA_ARG: &str = "ca";
69 pub const KRILL_CLI_MY_CA_ENV: &str = "KRILL_CLI_MY_CA";
70 
71 pub const REQUEUE_DELAY_SECONDS: i64 = 300;
72 pub const CA_REFRESH_SECONDS_MIN: u32 = 600;
73 pub const CA_REFRESH_SECONDS_MAX: u32 = 3600;
74 pub const CA_SUSPEND_MIN_HOURS: i64 = 2;
75 
76 pub const KRILL_HTTPS_ROOT_CERTS_ENV: &str = "KRILL_HTTPS_ROOT_CERTS";
77 
78 pub const ID_CERTIFICATE_VALIDITY_YEARS: i32 = 15;
79 
80 pub const BGP_RIS_REFRESH_MINUTES: i64 = 60;
81 
82 pub const HTTP_CLIENT_TIMEOUT_SECS: u64 = 120;
83 pub const HTTP_USER_AGENT_TRUNCATE: usize = 256; // Will truncate received user-agent values at this size.
84 pub const OPENID_CONNECT_HTTP_CLIENT_TIMEOUT_SECS: u64 = 30;
85 
86 pub const NO_RESOURCE: NoResourceType = NoResourceType;
87 
88 pub const ACTOR_DEF_KRILL: ActorDef = ActorDef::system("krill", "admin");
89 pub const ACTOR_DEF_ANON: ActorDef = ActorDef::anonymous();
90 pub const ACTOR_DEF_ADMIN_TOKEN: ActorDef = ActorDef::system("admin-token", "admin");
91 pub const ACTOR_DEF_TESTBED: ActorDef = ActorDef::system("testbed", "testbed");
92 
93 pub const SCHEDULER_INTERVAL_SECONDS_REPUBLISH: u32 = 600;
94 pub const SCHEDULER_INTERVAL_SECONDS_ROA_RENEW: u32 = 3600;
95 
96 #[cfg(test)]
97 pub const ACTOR_DEF_TEST: ActorDef = ActorDef::system("test", "admin");
98 
99 // Note: These must match the values used by Lagosta.
100 #[cfg(feature = "multi-user")]
101 pub const PW_HASH_LOG_N: u8 = 13;
102 #[cfg(feature = "multi-user")]
103 pub const PW_HASH_R: u32 = 8;
104 #[cfg(feature = "multi-user")]
105 pub const PW_HASH_P: u32 = 1;
106