mirror of
https://github.com/sadoyan/aralez.git
synced 2026-04-30 06:48:37 +08:00
Add TLS to API server
This commit is contained in:
@@ -11,6 +11,9 @@ pub struct FromFileProvider {
|
||||
pub struct APIUpstreamProvider {
|
||||
pub address: String,
|
||||
pub masterkey: String,
|
||||
pub tls_address: Option<String>,
|
||||
pub tls_certificate: Option<String>,
|
||||
pub tls_key_file: Option<String>,
|
||||
}
|
||||
|
||||
pub struct ConsulProvider {
|
||||
@@ -25,7 +28,7 @@ pub trait Discovery {
|
||||
#[async_trait]
|
||||
impl Discovery for APIUpstreamProvider {
|
||||
async fn start(&self, toreturn: Sender<Configuration>) {
|
||||
webserver::run_server(self.address.clone(), self.masterkey.clone(), toreturn).await;
|
||||
webserver::run_server(self, toreturn).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,5 +150,15 @@ pub fn parce_main_config(path: &str) -> AppConfig {
|
||||
}
|
||||
}
|
||||
};
|
||||
// match cfo.config_tls_address.clone() {
|
||||
// Some(tls_cert) => {
|
||||
// if let Some((ip, port_str)) = tls_cert.split_once(':') {
|
||||
// if let Ok(port) = port_str.parse::<u16>() {
|
||||
// cfo.local_tls_server = Option::from((ip.to_string(), port));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// None => {}
|
||||
// };
|
||||
cfo
|
||||
}
|
||||
|
||||
@@ -65,9 +65,12 @@ pub struct AppConfig {
|
||||
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 master_key: String,
|
||||
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 tls_certificate: Option<String>,
|
||||
|
||||
Reference in New Issue
Block a user