Created
December 22, 2013 22:17
-
-
Save lucamauri/8089109 to your computer and use it in GitHub Desktop.
Query WHOIS databases for data on domain names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Class clsWhoIs | |
Public Enum registry | |
whois_arin_net = 0 | |
whois_ripe_net = 1 | |
whois_apnic_net = 2 | |
End Enum | |
Function test(ByVal ipAddress As String, ByVal queryTo As registry) As String | |
Dim tcpc As New TcpClient() | |
Dim strDomain As String | |
Dim arrDomain As Byte() | |
Dim s As Stream | |
Dim sr As StreamReader | |
Dim result As New StringBuilder | |
Dim line As String | |
Try | |
tcpc.Connect(System.Enum.GetName(GetType(registry), queryTo).ToString.Replace("_", "."), 43) | |
strDomain = ipAddress & Environment.NewLine | |
arrDomain = Encoding.ASCII.GetBytes(strDomain.ToCharArray()) | |
s = tcpc.GetStream() | |
s.Write(arrDomain, 0, strDomain.Length) | |
sr = New StreamReader(tcpc.GetStream(), Encoding.ASCII) | |
Do | |
line = sr.ReadLine() | |
If line IsNot Nothing AndAlso line.Length > 0 Then | |
Select Case line.Substring(0, 1) | |
Case "%", " ", "*" | |
Case Else | |
result.Append(line) | |
result.Append("<br />") | |
End Select | |
End If | |
Loop Until line Is Nothing | |
Return result.ToString | |
Catch ex As Exception | |
Return ex.ToString | |
Finally | |
tcpc.Close() | |
End Try | |
End Function | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment