Skip to content

Commit

Permalink
feat(libscoop|config) support parsing private_hosts field
Browse files Browse the repository at this point in the history
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 <su+git@chawyehsu.com>
  • Loading branch information
chawyehsu committed Jul 31, 2023
1 parent aec7fdc commit 49e2a7b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions crates/libscoop/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ pub struct ConfigInner {
#[serde(skip_serializing_if = "Option::is_none")]
no_junctions: Option<bool>,

/// 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<Vec<PrivateHosts>>,

#[serde(skip_serializing_if = "Option::is_none")]
proxy: Option<String>,

Expand All @@ -163,6 +175,16 @@ pub struct ConfigInner {
use_external_7zip: Option<bool>,
}

#[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.
///
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 49e2a7b

Please sign in to comment.