-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
38 lines (35 loc) · 1.34 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using IPBlackListCheck.Library;
using System.Linq;
using System.Collections.Generic;
namespace IPBlackListCheck
{
class Program
{
static void Main(string[] args)
{
var ipsToCheck = new IPListRetriever().GetIpList().ToList();
Console.WriteLine($"Received {ipsToCheck.Count()} items to check");
var checkedIPs = new IPListingChecker().ValidateAddresses(ipsToCheck);
checkedIPs.ToList().ForEach(i => EchoIPConfig(i));
}
private static void EchoIPConfig(IPCheck check)
{
var oldColor = Console.ForegroundColor;
var newColor = oldColor;
string messagePrefix = "";
switch(check.Status)
{
case IPCheckStatus.BlackListed: newColor = ConsoleColor.Red; messagePrefix = "X"; break;
case IPCheckStatus.NotOnBlackList:
case IPCheckStatus.WhiteListed: newColor = ConsoleColor.Green; messagePrefix = "✓"; break;
case IPCheckStatus.Unknown: newColor = ConsoleColor.Yellow; messagePrefix = "?"; break;
case IPCheckStatus.Error: newColor = ConsoleColor.Yellow; messagePrefix = "X"; break;
default: break;
}
Console.ForegroundColor = newColor;
System.Console.WriteLine($"{messagePrefix} {(check.IPToCheck).PadRight(16)} {(check.Name).PadRight(20)} {check.Message}");
Console.ForegroundColor = oldColor;
}
}
}