From 49e2a7bc45d4e7e589a931313a151727b5cadd36 Mon Sep 17 00:00:00 2001 From: Chawye Hsu Date: Mon, 31 Jul 2023 14:13:38 +0800 Subject: [PATCH] feat(libscoop|config) support parsing `private_hosts` field This may be used in tweaking http connection of pacakge downloads, which is not currently implemented, the parsing works though. Signed-off-by: Chawye Hsu --- crates/libscoop/src/config.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/libscoop/src/config.rs b/crates/libscoop/src/config.rs index 90f2fe6..badd327 100644 --- a/crates/libscoop/src/config.rs +++ b/crates/libscoop/src/config.rs @@ -138,6 +138,18 @@ pub struct ConfigInner { #[serde(skip_serializing_if = "Option::is_none")] no_junctions: Option, + /// A list of private hosts. + /// + /// # Note + /// + /// Array of private hosts that need additional authentication. For example, + /// if you want to access a private GitHub repository, you need to add the + /// host to this list with 'match' and 'headers' strings. + /// + /// Refer to: https://github.com/ScoopInstaller/Scoop/pull/4254 + #[serde(skip_serializing_if = "Option::is_none")] + private_hosts: Option>, + #[serde(skip_serializing_if = "Option::is_none")] proxy: Option, @@ -163,6 +175,16 @@ pub struct ConfigInner { use_external_7zip: Option, } +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct PrivateHosts { + /// A string defining the host to match. + #[serde(rename = "match")] + match_: String, + + /// A string defining HTTP headers. + headers: String, +} + impl Config { /// Initialize the config with default values. /// @@ -292,6 +314,7 @@ impl Default for Config { show_manifest: Default::default(), use_lessmsi: Default::default(), no_junctions: Default::default(), + private_hosts: Default::default(), proxy: Default::default(), // default_root_path: default::root_path(), root_path: default::root_path(),