From f1dd7aa84deb44ff76b78944291883149a6c37bb Mon Sep 17 00:00:00 2001 From: jeffrey Date: Mon, 31 Mar 2025 17:49:19 +0200 Subject: [PATCH] modmin --- Program.cs | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/Program.cs b/Program.cs index f1dbccd..87d53c6 100644 --- a/Program.cs +++ b/Program.cs @@ -11,29 +11,34 @@ namespace SharpDNSResolver { static void Main(string[] args) { - try + if (args.Count() == 0) { - if(args.Count() == 0) - { - Console.WriteLine("You must provide an host!"); - Environment.Exit(1); - } - string hostname = args[0]; - IPHostEntry hostEntry = Dns.GetHostEntry(hostname); - - Console.WriteLine($"Host : {hostEntry.HostName}"); - - Console.WriteLine("Ip address:"); - foreach (IPAddress ipAddress in hostEntry.AddressList) - { - Console.WriteLine($" {ipAddress}"); - } + Console.WriteLine("You must provide at least one host!"); + Console.WriteLine("Usage: [ host]"); + Environment.Exit(1); } - catch (System.Net.Sockets.SocketException ex) + + int cpt = 0; + string hostname; + IPHostEntry hostEntry; + for (cpt = 0; cpt < args.Length; cpt++) { - Console.WriteLine($"Error : {ex.Message}"); + try + { + hostname = args[cpt]; + hostEntry = Dns.GetHostEntry(hostname); + Console.WriteLine($"\nHost : {hostEntry.HostName}"); + Console.WriteLine("Ip address:"); + foreach (IPAddress ipAddress in hostEntry.AddressList) + { + Console.WriteLine($" {ipAddress}"); + } + } + catch (System.Net.Sockets.SocketException ex) + { + Console.WriteLine($"Error : {ex.Message}"); + } } } } - }