Skip to content

Commit

Permalink
Merge pull request #50 from tinuwalther/develop
Browse files Browse the repository at this point in the history
Update to version 0.7.72
  • Loading branch information
tinuwalther authored Nov 9, 2022
2 parents 3bb10e8 + b0f0bd6 commit b03cb03
Show file tree
Hide file tree
Showing 7 changed files with 4,855 additions and 43 deletions.
31 changes: 18 additions & 13 deletions Code/Classes/02-PsNetDig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,28 @@ Class PsNetDig {
[Array] $ipv6address = $null
[String] $TargetName = $null

$dnsreturn = [System.Net.Dns]::GetHostEntry($InputString)
if(-not([String]::IsNullOrEmpty($dnsreturn))){
$TargetName = $dnsreturn.hostname
$collection = $dnsreturn.AddressList
}

foreach($item in $collection){
if($($item.AddressFamily) -eq [System.Net.Sockets.AddressFamily]::InterNetwork){
$ipv4address += $item.IPAddressToString
try{
$dnsreturn = [System.Net.Dns]::GetHostEntry($InputString)
if(-not([String]::IsNullOrEmpty($dnsreturn))){
$TargetName = $dnsreturn.hostname
$collection = $dnsreturn.AddressList
}
if($($item.AddressFamily) -eq [System.Net.Sockets.AddressFamily]::InterNetworkV6){
$ipv6address += $item.IPAddressToString
foreach($item in $collection){
if($($item.AddressFamily) -eq [System.Net.Sockets.AddressFamily]::InterNetwork){
$ipv4address += $item.IPAddressToString
}
if($($item.AddressFamily) -eq [System.Net.Sockets.AddressFamily]::InterNetworkV6){
$ipv6address += $item.IPAddressToString
}
}
$duration = $([math]::round(((New-TimeSpan $($start) $(Get-Date)).TotalMilliseconds),0))
return [PsNetDigType]::New($true, $InputString, $TargetName, $ipv4address, $ipv6address, $duration)
}catch{
$TargetName = ($($_.Exception.Message) -split ': ')[1] -replace '"'
$duration = $([math]::round(((New-TimeSpan $($start) $(Get-Date)).TotalMilliseconds),0))
return [PsNetDigType]::New($false, $InputString, $TargetName, $null, $null, $duration)
}

$duration = $([math]::round(((New-TimeSpan $($start) $(Get-Date)).TotalMilliseconds),0))
return [PsNetDigType]::New($true, $InputString, $TargetName, $ipv4address, $ipv6address, $duration)
}
#endregion

Expand Down
8 changes: 1 addition & 7 deletions Code/Functions/Public/Test-PsNetDig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,7 @@ function Test-PsNetDig{
$resultset += [PsNetDig]::dig($item)
}
catch {
$Message = [PsNetError]::New("$($function)($item)", $_)
$SubMessage = $Message.Substring($Message.IndexOf(':')+2)
if($SubMessage){
$resultset += $SubMessage -replace '"'
}else{
$resultset += $Message
}
$resultset += [PsNetError]::New("$($function)($item)", $_)
$error.Clear()
}
}
Expand Down
Loading

0 comments on commit b03cb03

Please sign in to comment.