mirror of
https://github.com/sadoyan/aralez.git
synced 2026-04-30 23:08:40 +08:00
Improvements and cleanup
This commit is contained in:
@@ -63,13 +63,12 @@ pub async fn start(fp: String, mut toreturn: Sender<Configuration>) {
|
||||
consul: None,
|
||||
typecfg: "".to_string(),
|
||||
extraparams: config.extraparams.clone(),
|
||||
globals: Default::default(),
|
||||
};
|
||||
|
||||
clone_dashmap_into(&upstreams, &prev_upstreams);
|
||||
clone_dashmap_into(&upstreams, &tosend.upstreams);
|
||||
tosend.headers = headers.clone();
|
||||
tosend.globals = config.globals.clone();
|
||||
tosend.extraparams.authentication = config.extraparams.authentication.clone();
|
||||
tosend.typecfg = config.typecfg.clone();
|
||||
tosend.consul = config.consul.clone();
|
||||
toreturn.send(tosend).await.unwrap();
|
||||
|
||||
@@ -12,8 +12,10 @@ pub fn load_configuration(d: &str, kind: &str) -> Option<Configuration> {
|
||||
headers: Default::default(),
|
||||
consul: None,
|
||||
typecfg: "".to_string(),
|
||||
extraparams: Extraparams { stickysessions: false },
|
||||
globals: Default::default(),
|
||||
extraparams: Extraparams {
|
||||
stickysessions: false,
|
||||
authentication: DashMap::new(),
|
||||
},
|
||||
};
|
||||
toreturn.upstreams = UpstreamsDashMap::new();
|
||||
toreturn.headers = Headers::new();
|
||||
@@ -58,9 +60,9 @@ pub fn load_configuration(d: &str, kind: &str) -> Option<Configuration> {
|
||||
let cfg = DashMap::new();
|
||||
if let Some(k) = globals.get("authorization") {
|
||||
cfg.insert("authorization".to_string(), k.to_owned());
|
||||
toreturn.globals = Some(cfg);
|
||||
toreturn.extraparams.authentication = cfg;
|
||||
} else {
|
||||
toreturn.globals = None;
|
||||
toreturn.extraparams.authentication = DashMap::new();
|
||||
}
|
||||
}
|
||||
match parsed.provider.as_str() {
|
||||
@@ -131,5 +133,10 @@ pub fn parce_main_config(path: &str) -> AppConfig {
|
||||
for (k, v) in cfg {
|
||||
reply.insert(k.to_string(), v.to_string());
|
||||
}
|
||||
if let Some((ip, port_str)) = cfo.config_address.split_once(':') {
|
||||
if let Ok(port) = port_str.parse::<u16>() {
|
||||
cfo.local_server = Option::from((ip.to_string(), port));
|
||||
}
|
||||
}
|
||||
cfo
|
||||
}
|
||||
|
||||
@@ -13,9 +13,10 @@ pub struct ServiceMapping {
|
||||
pub real: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Extraparams {
|
||||
pub stickysessions: bool,
|
||||
pub authentication: DashMap<String, Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
@@ -51,7 +52,6 @@ pub struct Configuration {
|
||||
pub consul: Option<Consul>,
|
||||
pub typecfg: String,
|
||||
pub extraparams: Extraparams,
|
||||
pub globals: Option<DashMap<String, Vec<String>>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -66,4 +66,5 @@ pub struct AppConfig {
|
||||
pub proxy_address_tls: Option<String>,
|
||||
pub tls_certificate: Option<String>,
|
||||
pub tls_key_file: Option<String>,
|
||||
pub local_server: Option<(String, u16)>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user