mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
win_wait_for: use loopback IP instead of hostname if 127.0.0.1 is used (#36762)
* win_wait_for: use loopback IP instead of hostname if 127.0.0.1 is used * removed reverse dns lookup in port check
This commit is contained in:
parent
4705edd1a7
commit
67ffde4ac1
1 changed files with 1 additions and 9 deletions
|
@ -54,17 +54,9 @@ if ($port -ne $null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Test-Port($hostname, $port) {
|
Function Test-Port($hostname, $port) {
|
||||||
# try and resolve the IP/Host, if it fails then just use the host passed in
|
|
||||||
try {
|
|
||||||
$resolve_hostname = ([System.Net.Dns]::GetHostEntry($hostname)).HostName
|
|
||||||
} catch {
|
|
||||||
# oh well just use the IP addres
|
|
||||||
$resolve_hostname = $hostname
|
|
||||||
}
|
|
||||||
|
|
||||||
$timeout = $connect_timeout * 1000
|
$timeout = $connect_timeout * 1000
|
||||||
$socket = New-Object -TypeName System.Net.Sockets.TcpClient
|
$socket = New-Object -TypeName System.Net.Sockets.TcpClient
|
||||||
$connect = $socket.BeginConnect($resolve_hostname, $port, $null, $null)
|
$connect = $socket.BeginConnect($hostname, $port, $null, $null)
|
||||||
$wait = $connect.AsyncWaitHandle.WaitOne($timeout, $false)
|
$wait = $connect.AsyncWaitHandle.WaitOne($timeout, $false)
|
||||||
|
|
||||||
if ($wait) {
|
if ($wait) {
|
||||||
|
|
Loading…
Reference in a new issue