Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions cargo-dist/templates/installer/installer.ps1.j2
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,44 @@ function Get-Arch() {
}
}

function WebProxyFromUrl {
param([string]$ProxyUrl)

if ([string]::IsNullOrWhiteSpace($ProxyUrl)) {
return $null
}

try {
# Parse the proxy URL
$uri = [System.Uri]$ProxyUrl

# Create WebProxy instance
$webProxy = New-Object System.Net.WebProxy($uri)

# Set credentials if provided in URL
if (-not [string]::IsNullOrEmpty($uri.UserInfo)) {
$userInfo = $uri.UserInfo.Split(':')
$username = [System.Uri]::UnescapeDataString($userInfo[0])
$password = if ($null -eq $userInfo[1]) { "" } else { [System.Uri]::UnescapeDataString($userInfo[1]) }
$webProxy.Credentials = New-Object System.Net.NetworkCredential($username, $password)
}

return $webProxy
}
catch {
Write-Verbose("Failed to parse proxy URL '$ProxyUrl': $($_.Exception.Message)")
return $null
}
}

function WebProxyFromEnvironment {
$httpsProxy = [System.Environment]::GetEnvironmentVariable("HTTPS_PROXY")
$allProxy = [System.Environment]::GetEnvironmentVariable("ALL_PROXY")
$proxyUrl = if (-not [string]::IsNullOrWhiteSpace($httpsProxy)) { $httpsProxy } else { $allProxy }
$webProxy = WebProxyFromUrl -ProxyUrl $proxyUrl
return $webProxy
}

function Download($download_url, $platforms) {
$arch = Get-TargetTriple $platforms

Expand All @@ -228,6 +266,10 @@ function Download($download_url, $platforms) {
Write-Verbose " from $url"
Write-Verbose " to $dir_path"
$wc = New-Object Net.Webclient
$proxy = WebProxyFromEnvironment
if ($null -ne $proxy) {
$wc.Proxy = $proxy
}
if ($auth_token) {
$wc.Headers["Authorization"] = "Bearer $auth_token"
}
Expand Down
42 changes: 42 additions & 0 deletions cargo-dist/tests/snapshots/akaikatana_basic.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions cargo-dist/tests/snapshots/akaikatana_bins.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions cargo-dist/tests/snapshots/akaikatana_two_bin_aliases.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions cargo-dist/tests/snapshots/akaikatana_updaters.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions cargo-dist/tests/snapshots/axolotlsay_action_commit.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading