-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathProgram.cs
140 lines (124 loc) · 5.74 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp2
{
internal class Program
{
public static void Log(string logMessage, TextWriter w)
{
w.Write($"{logMessage} at: ");
w.Write($"{DateTime.Now.ToLongTimeString()} {DateTime.Now.ToLongDateString()}");
w.WriteLine();
}
static void Main(string[] args)
{
int Timeouts = 0;
new Thread(() =>
{
var s = " "; // 8 spaces for the titles spacing, looks very messy but who cares.
Thread.CurrentThread.IsBackground = true;
for (int i = 0; i < int.MaxValue; i++)
//{
// Console.Title = $"Rapid IP Pinger | Time open : {i} seconds";
// Thread.Sleep(1000);
//}
{
var random = new Random();
var randomNumber = random.Next(1, 5);
if (randomNumber == 3)
{
Console.Title = "Hey bb "+s+" " +s+s+s+s+s+s+s+s+s+s+s+s+$" Time open: {i} seconds"+s+"|"+s+$"Total Timeouts: {Timeouts}";
Thread.Sleep(500);
Console.Title = "Hey bb "+s+" "+s+s+s+s+s+s+s+s+s+s+s+s+$" Time open: {i+1} seconds"+s+"|"+s+$"Total Timeouts: {Timeouts}";
Thread.Sleep(500);
}
else if (randomNumber == 2)
{
Console.Title = "Rapid IP / Host Pinger "+s+" "+s+s+s+s+s+s+s+s+s+$"Time open: {i} seconds"+s+"|"+s+$"Total Timeouts: {Timeouts}";
Thread.Sleep(500);
Console.Title = "Rapid IP / Host Pinger "+s+" "+s+s+s+s+s+s+s+s+s+$"Time open: {i+1} seconds"+s+"|"+s+$"Total Timeouts: {Timeouts}";
Thread.Sleep(500);
}
else if (randomNumber == 1)
{
Console.Title = "Consider Starring The Repo? github.com/0vm/Pinger "+s+" "+s+s+$" Time open: {i} seconds"+s+"|"+s+$"Total Timeouts: {Timeouts}";
Thread.Sleep(500);
Console.Title = "Consider Starring The Repo? github.com/0vm/Pinger "+s+" "+s+s+$" Time open: {i+1} seconds"+s+"|"+s+$"Total Timeouts: {Timeouts}";
Thread.Sleep(500);
}
else if (randomNumber == 4)
{
Console.Title = "Pro Tip: Click On The Console To Pause The Pinger " + s + " " + s + s + $" Time open: {i} seconds" + s + "|" + s + $"Total Timeouts: {Timeouts}";
Thread.Sleep(500);
Console.Title = "Pro Tip: Click On The Console To Pause The Pinger " + s + " " + s + s + $" Time open: {i + 1} seconds" + s + "|" + s + $"Total Timeouts: {Timeouts}";
Thread.Sleep(500);
}
}
}).Start();
int? log = 0;
Console.Write("Want to log the timeouts to a file? (y/n): ");
ConsoleKey response = Console.ReadKey(false).Key;
Console.WriteLine();
if (response == ConsoleKey.Y)
{
log = 1;
}
else
{
log = 0;
}
Console.Clear();
Console.Write("Enter Host: ");
string option = Console.ReadLine();
new Thread(() =>
{
Thread.CurrentThread.IsBackground = true;
while (true)
{
try
{
int timeout = 1500;
Ping ping = new Ping();
PingReply pingreply = ping.Send(option, timeout);
if (pingreply.Status == IPStatus.Success)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("Status: {0}", pingreply.Status);
Console.ForegroundColor = ConsoleColor.White; Console.Write(" | ");
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.Write("IP: {0}", pingreply.Address);
Console.ForegroundColor = ConsoleColor.White; Console.Write(" | ");
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("Latency: {0}ms", pingreply.RoundtripTime);
Console.WriteLine();
}else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(option + " Timed Out");
if (log == 1)
{
using (StreamWriter w = File.AppendText("log.txt"))
{
Log($"{option} Timed Out", w);
}
}
Timeouts++;
continue;
}
}
catch (PingException ex)
{
Console.WriteLine(ex);
}
}
}).Start();
Thread.Sleep(-1);
}
}
}