Compare commits
1 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
f1dd7aa84d |
23
Program.cs
23
Program.cs
|
|
@ -11,18 +11,23 @@ namespace SharpDNSResolver
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
try
|
if (args.Count() == 0)
|
||||||
{
|
{
|
||||||
if(args.Count() == 0)
|
Console.WriteLine("You must provide at least one host!");
|
||||||
{
|
Console.WriteLine("Usage: <prog.exe> <host1> [<host2> host<n>]");
|
||||||
Console.WriteLine("You must provide an host!");
|
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
string hostname = args[0];
|
|
||||||
IPHostEntry hostEntry = Dns.GetHostEntry(hostname);
|
|
||||||
|
|
||||||
Console.WriteLine($"Host : {hostEntry.HostName}");
|
|
||||||
|
|
||||||
|
int cpt = 0;
|
||||||
|
string hostname;
|
||||||
|
IPHostEntry hostEntry;
|
||||||
|
for (cpt = 0; cpt < args.Length; cpt++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
hostname = args[cpt];
|
||||||
|
hostEntry = Dns.GetHostEntry(hostname);
|
||||||
|
Console.WriteLine($"\nHost : {hostEntry.HostName}");
|
||||||
Console.WriteLine("Ip address:");
|
Console.WriteLine("Ip address:");
|
||||||
foreach (IPAddress ipAddress in hostEntry.AddressList)
|
foreach (IPAddress ipAddress in hostEntry.AddressList)
|
||||||
{
|
{
|
||||||
|
|
@ -35,5 +40,5 @@ namespace SharpDNSResolver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue