Add new settings cors-allow-all

This commit is contained in:
2023-10-05 00:43:26 +00:00
committed by GitHub
parent 06ae4a023c
commit ab6ffba0b6
3 changed files with 15 additions and 1 deletions

View File

@@ -74,6 +74,18 @@ impl OptHelper {
self._cors_entries.get_ref().clone()
}
#[cfg(feature = "server")]
pub fn cors_allow_all(&self) -> bool {
if self.settings.get_ref().have_bool("cors-allow-all") {
return self
.settings
.get_ref()
.get_bool("cors-allow-all")
.unwrap_or(false);
}
false
}
#[cfg(feature = "db")]
/// Return the config of the database
pub fn db(&self) -> PixivDownloaderDbConfig {

View File

@@ -417,7 +417,7 @@ impl Default for CorsContext {
fn default() -> Self {
let helper = get_helper();
Self {
allow_all: false,
allow_all: helper.cors_allow_all(),
entries: helper.cors_entries(),
hosts: Vec::new(),
}

View File

@@ -62,6 +62,8 @@ pub fn get_settings_list() -> Vec<SettingDes> {
#[cfg(feature = "ugoira")]
SettingDes::new("ugoira-max-fps", gettext("The max fps when converting ugoira(GIF) to video."), JsonValueType::Number, Some(check_ugoira_max_fps)).unwrap(),
SettingDes::new("fanbox-page-number", gettext("Use page number for pictures' file name in fanbox."), JsonValueType::Boolean, None).unwrap(),
#[cfg(feature = "server")]
SettingDes::new("cors-allow-all", gettext("Whether to allow all domains to send CORS requests."), JsonValueType::Boolean, None).unwrap(),
]
}