Skip to content

Commit

Permalink
🐛 Address @tlynchpin's review
Browse files Browse the repository at this point in the history
 - Typo/logic bug: ProxyServer should be ProxyServerPort

 - Support multi-protocol, multi-proxy configs (;-separated)

 - Ignores pathological config (enabled proxy, blank proxy host)
  • Loading branch information
AlainODea committed Nov 20, 2018
1 parent d271c7c commit c5e50af
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions bin/Install-OktaAwsCli.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,26 @@ function With-Okta {
$env:OKTA_PROFILE = $Profile
$InternetOptions = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
if ($InternetOptions.ProxyEnable) {
if ($InternetOptions.ProxyServer) {
$ProxyString = $InternetOptions.ProxyServer
$InternetOptions = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
$ProxyStrings = $InternetOptions.ProxyServer.Split(";")
$Proxies = @{}
ForEach ($ProxyString in $ProxyStrings) {
if ($ProxyString.Contains("=")) {
($ProxyProtocol,$ProxyServerPort) = $ProxyString.Split("=")
} else {
($ProxyProtocol,$ProxyServerPort) = ("http", $ProxyString)
}
($ProxyHost, $ProxyPort) = $ProxyServer.Split(":")
($ProxyHost, $ProxyPort) = $ProxyServerPort.Split(":")
$Proxies[$ProxyProtocol] = ($ProxyHost, $ProxyPort)
}
if ($Proxies.socks) {
($ProxyHost, $ProxyPort) = $Proxies.socks
} elseif ($Proxies.https) {
($ProxyHost, $ProxyPort) = $Proxies.https
} elseif ($Proxies.http) {
($ProxyHost, $ProxyPort) = $Proxies.http
}
($ProxyHost, $ProxyPort)
if ($InternetOptions.ProxyOverride) {
$NonProxyHosts = [System.String]::Join("|", ($InternetOptions.ProxyOverride.Replace("<local>", "").Split(";") | Where-Object {$_}))
} else {
Expand Down

0 comments on commit c5e50af

Please sign in to comment.