جستجوی نام های دامنه (Whois) در ASP.NET
دوشنبه 23 دی 1387 5:36 PM
Using System.Net.Sockets;
Using System.Text;
Using System.IO
Using System.Text.RegularExpressions;
string StrSvr,StrDomain, Resp;
TcpClient TcpClt;
byte[] ArrDomain;
Stream TcpStr;
StreamReader TcpStrRdr;
if (DDLstSuffix.SelectedItem.Value == ".COM" || DDLstSuffix.SelectedItem.Value == ".NET" || DDLstSuffix.SelectedItem.Value == ".EDU")
{
StrSvr = "whois.internic.net";
StrDomain = TxtDomainName.Text.Trim() + DDLstSuffix.SelectedItem.Value+ "\r\n";
}
else if (DDLstSuffix.SelectedItem.Value == ".ORG")
{
StrSvr = "whois.publicinterestregistry.net";
StrDomain = TxtDomainName.Text.Trim() + DDLstSuffix.SelectedItem.Value+ "\r\n";
}
else if (DDLstSuffix.SelectedItem.Value == ".BIZ")
{
StrSvr = "whois.neulevel.biz";
StrDomain = TxtDomainName.Text.Trim() + DDLstSuffix.SelectedItem.Value+ "\r\n";
}
else if (DDLstSuffix.SelectedItem.Value == ".INFO")
{
StrSvr = "whois.afilias.info";
StrDomain = TxtDomainName.Text.Trim() + DDLstSuffix.SelectedItem.Value+ "\r\n";
}
else if ((DDLstSuffix.SelectedItem.Value == ".IR") || (DDLstSuffix.SelectedItem.Value == ".CO.IR") || (DDLstSuffix.SelectedItem.Value == ".NET.IR") || (DDLstSuffix.SelectedItem.Value == "ID.IR"))
{
StrSvr = "whois.nic.ir";
StrDomain = TxtDomainName.Text.Trim() + DDLstSuffix.SelectedItem.Value+ "\r\n";
}
TcpClient TcpClt = new TcpClient();
TcpClt.Connect(StrSvr,43);
TcpClient objTCPC = new TcpClient(StrSvr, 43);
ArrDomain = Encoding.ASCII.GetBytes(strDomain);
TcpStr = TcpClt.GetStream();
TcpStr.Write (ArrDomain,0,StrDomain.Length);
TcpStrRdr = new StreamReader(TcpClt.GetStream(),Encoding.ASCII);
Resp = Regex.Replace(TcpStrRdr.ReadToEnd(),"\n","
");
Resp = Resp.ToLower();
if (Regex.IsMatch(Resp,"no match") || Regex.IsMatch(Resp,"not found") || Regex.IsMatch(Resp,"no entries found"))
{
SearchRes = " دامنه مورد نظر موجود مي باشد ";
PnlOrder.Visible = true;
PnlOrderOk.Visible = false;
}
else
{
SearchRes = " دامنه مورد نظر موجود نمي باشد ";
PnlOrder.Visible = false;
PnlOrderOk.Visible = false;
}
TcpClt.Close();