WIP
This commit is contained in:
parent
528d725cf8
commit
770b488a91
2 changed files with 33 additions and 3 deletions
|
@ -364,6 +364,36 @@ fn create_new_server_config(
|
|||
}
|
||||
};
|
||||
|
||||
let http_proxy_bypass_hosts = match default_yml.get("proxyBypassHosts") {
|
||||
Some(hosts) => Some(
|
||||
hosts
|
||||
.as_vec()
|
||||
.ok_or(Error::InvalidConfig("proxyBypassHosts is not an array"))?
|
||||
.iter()
|
||||
.map(|host| {
|
||||
host.as_str()
|
||||
.ok_or(Error::InvalidConfig(
|
||||
"proxyBypassHosts contains non-string items",
|
||||
))
|
||||
.map(|s| s.to_owned())
|
||||
})
|
||||
.collect::<Result<Vec<String>, Error>>()?,
|
||||
),
|
||||
None => None,
|
||||
};
|
||||
|
||||
let http_proxy = match default_yml.get("proxyUrl") {
|
||||
Some(url) => Some(server::Proxy {
|
||||
enabled: true,
|
||||
url: url
|
||||
.as_str()
|
||||
.ok_or(Error::InvalidConfig("proxyUrl is not a string"))?
|
||||
.to_string(),
|
||||
bypass_hosts: http_proxy_bypass_hosts,
|
||||
}),
|
||||
None => None,
|
||||
};
|
||||
|
||||
let mut server_config = server::Config {
|
||||
config_revision: Revision::V1,
|
||||
server_info: Some(server::ServerInfo {
|
||||
|
@ -373,7 +403,7 @@ fn create_new_server_config(
|
|||
contact_info: meta.maintainer_email.to_owned(),
|
||||
open_registrations: !meta.disable_registration,
|
||||
repository_url,
|
||||
default_reaction: meta.default_reaction.to_owned(),
|
||||
default_reaction: Some(meta.default_reaction.to_owned()),
|
||||
}),
|
||||
timeline: Some(server::Timeline {
|
||||
local: !meta.disable_local_timeline,
|
||||
|
@ -398,7 +428,7 @@ fn create_new_server_config(
|
|||
.and_then(|v| v.as_i64())
|
||||
.ok_or(Error::InvalidConfig("port"))? as u16,
|
||||
},
|
||||
http_proxy: todo!(),
|
||||
http_proxy,
|
||||
media_proxy: todo!(),
|
||||
summaly_proxy: todo!(),
|
||||
smtp_proxy: todo!(),
|
||||
|
|
|
@ -59,7 +59,7 @@ pub struct Proxy {
|
|||
pub enabled: bool,
|
||||
#[validate(url)]
|
||||
pub url: String,
|
||||
pub allowlist: Option<Vec<String>>,
|
||||
pub bypass_hosts: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Validate, Debug, Clone)]
|
||||
|
|
Loading…
Reference in a new issue