@ -937,42 +937,51 @@ if ($mirrors_response.StatusCode -eq 200) {
}
}
#write-host " dict: $($dict_mirrors | out-String) "
#write-host " dict: $($dict_mirrors | out-String) "
write-host " host_list: $host_list "
write-host " host_list: $host_list "
if ($PSVersionTable.PSEdition - e q " D e s k t o p " ) {
$automation_name = " punkshell+julian@precisium.com.au_target_by_latency "
#powershell.exe
#we seem to need -ErrorAction Ignore for bad/unresponsive host entries - but unlike with pwsh, we don't get any corresponding entry in the test_results, and -Quiet doesn't seem to give us results either REVIEW
$trace = test-netconnection gitea1.intx.com.au -Hops 6 -TraceRoute -ErrorAction Ignore
$test_results = Test-Connection $host_list -Count 1 -ErrorAction Ignore
if ((${trace}.PingSucceeded) - a n d ( $ { t r a c e } . T r a c e R o u t e . C o u n t - l t 5 ) ) {
for ($i = 0; $i -lt $test_results.Count; $i++) {
$dict_mirrors[" gitea1.intx.com.au " ][" latency " ] = 2
$result = $test_results[$i]
#short-circuit for hosts very near gitea1.intx.com.au
if ($result) {
#don't even test others. This is primarily for hosts at intx.com.au and associated entities - which are more likely to use punkshell than anyone else.
$targethost = $result.Address
} else {
if ($result.StatusCode - e q 0 ) {
if ($PSVersionTable.PSEdition - e q " D e s k t o p " ) {
$dict_mirrors[$targethost][" latency " ] = $result.ResponseTime
#powershell.exe
#we seem to need -ErrorAction Ignore for bad/unresponsive host entries - but unlike with pwsh, we don't get any corresponding entry in the test_results, and -Quiet doesn't seem to give us results either REVIEW
$test_results = Test-Connection $host_list -Count 1 -ErrorAction Ignore
for ($i = 0; $i -lt $test_results.Count; $i++) {
$result = $test_results[$i]
if ($result) {
$targethost = $result.Address
if ($result.StatusCode - e q 0 ) {
$dict_mirrors[$targethost][" latency " ] = $result.ResponseTime
} else {
$dict_mirrors[$targethost][" latency " ] = 999999
}
} else {
} else {
$targethost = $host_list[$i]
$dict_mirrors[$targethost][" latency " ] = 999999
$dict_mirrors[$targethost][" latency " ] = 999999
}
}
} else {
$targethost = $host_list[$i]
$dict_mirrors[$targethost][" latency " ] = 999999
}
}
}
} else {
} else {
#pwsh.exe
#pwsh.exe
$test_results = Test-Connection -TargetName $host_list -Count 1 -Ipv4 -Detailed -TcpPort 443 -Quiet
$test_results = Test-Connection -TargetName $host_list -Count 1 -Ipv4 -Detailed -TcpPort 443 -Quiet
for ($i = 0; $i -lt $test_results.Count; $i++) {
for ($i = 0; $i -lt $test_results.Count; $i++) {
$result = $test_results[$i]
$result = $test_results[$i]
if ($result) {
if ($result) {
$targethost = $result.Target
$targethost = $result.Target
if ($result.Status - e q " S u c c e s s " ) {
if ($result.Status - e q " S u c c e s s " ) {
$dict_mirrors[$targethost][" latency " ] = $result.Latency
$dict_mirrors[$targethost][" latency " ] = $result.Latency
} else {
$dict_mirrors[$targethost][" latency " ] = 999999
}
} else {
} else {
$targethost = $host_list[$i]
$dict_mirrors[$targethost][" latency " ] = 999999
$dict_mirrors[$targethost][" latency " ] = 999999
}
}
} else {
$targethost = $host_list[$i]
$dict_mirrors[$targethost][" latency " ] = 999999
}
}
}
}
}
}
$list_mirror_dicts = @()
$list_mirror_dicts = @()
@ -984,7 +993,6 @@ if ($mirrors_response.StatusCode -eq 200) {
$sorted_mirror_dicts = $list_mirror_dicts | Sort-Object -Property { [int]$_.latency }
$sorted_mirror_dicts = $list_mirror_dicts | Sort-Object -Property { [int]$_.latency }
#Write-Host " Sorted by latency: $($sorted_mirror_dicts | Format-Table -AutoSize | Out-String) "
#Write-Host " Sorted by latency: $($sorted_mirror_dicts | Format-Table -AutoSize | Out-String) "
Write-Host " Sorted by latency: $($sorted_mirror_dicts | Out-String) "
Write-Host " Sorted by latency: $($sorted_mirror_dicts | Out-String) "
$automation_name = " punkshell+julian@precisium.com.au_target_by_latency "
foreach ($hostinfo in $sorted_mirror_dicts) {
foreach ($hostinfo in $sorted_mirror_dicts) {
$uristring = $hostinfo.uri
$uristring = $hostinfo.uri