mirror of
https://github.com/sadoyan/aralez.git
synced 2026-04-30 14:58:38 +08:00
86 lines
2.5 KiB
Rust
86 lines
2.5 KiB
Rust
use dashmap::DashMap;
|
|
use serde::{Deserialize, Serialize};
|
|
use std::collections::HashMap;
|
|
use std::sync::atomic::AtomicUsize;
|
|
|
|
pub type InnerMap = (String, u16, bool, bool, bool);
|
|
pub type UpstreamsDashMap = DashMap<String, DashMap<String, (Vec<InnerMap>, AtomicUsize)>>;
|
|
pub type UpstreamsIdMap = DashMap<String, InnerMap>;
|
|
pub type Headers = DashMap<String, DashMap<String, Vec<(String, String)>>>;
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct ServiceMapping {
|
|
pub proxy: String,
|
|
pub real: String,
|
|
}
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct Extraparams {
|
|
pub sticky_sessions: bool,
|
|
pub to_https: Option<bool>,
|
|
pub authentication: DashMap<String, Vec<String>>,
|
|
pub rate_limit: Option<isize>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Consul {
|
|
pub servers: Option<Vec<String>>,
|
|
pub services: Option<Vec<ServiceMapping>>,
|
|
pub token: Option<String>,
|
|
}
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct Config {
|
|
pub provider: String,
|
|
pub sticky_sessions: bool,
|
|
pub to_https: Option<bool>,
|
|
pub upstreams: Option<HashMap<String, HostConfig>>,
|
|
pub globals: Option<HashMap<String, Vec<String>>>,
|
|
pub headers: Option<Vec<String>>,
|
|
pub authorization: Option<HashMap<String, String>>,
|
|
pub consul: Option<Consul>,
|
|
pub rate_limit: Option<isize>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct HostConfig {
|
|
pub paths: HashMap<String, PathConfig>,
|
|
pub rate_limit: Option<isize>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct PathConfig {
|
|
pub servers: Vec<String>,
|
|
pub to_https: Option<bool>,
|
|
pub headers: Option<Vec<String>>,
|
|
pub rate_limit: Option<isize>,
|
|
}
|
|
#[derive(Debug)]
|
|
pub struct Configuration {
|
|
pub upstreams: UpstreamsDashMap,
|
|
pub headers: Headers,
|
|
pub consul: Option<Consul>,
|
|
pub typecfg: String,
|
|
pub extraparams: Extraparams,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct AppConfig {
|
|
pub hc_interval: u16,
|
|
pub hc_method: String,
|
|
pub upstreams_conf: String,
|
|
pub log_level: String,
|
|
pub master_key: String,
|
|
pub config_address: String,
|
|
pub proxy_address_http: String,
|
|
pub config_api_enabled: bool,
|
|
pub config_tls_address: Option<String>,
|
|
pub config_tls_certificate: Option<String>,
|
|
pub config_tls_key_file: Option<String>,
|
|
pub proxy_address_tls: Option<String>,
|
|
pub proxy_port_tls: Option<u16>,
|
|
pub local_server: Option<(String, u16)>,
|
|
pub proxy_certificates: Option<String>,
|
|
pub file_server_address: Option<String>,
|
|
pub file_server_folder: Option<String>,
|
|
}
|