-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
189 lines (153 loc) · 6.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
using ProxyChecker.ProxyService;
using ProxyChecker.Settings;
using ProxyFinderAndChecker;
using Spectre.Console;
using System.Diagnostics;
#region Configurations
string RunTimePath = Environment.CurrentDirectory;
string ProxyFolder = Path.Combine(RunTimePath, "Proxies");
string CheckedPath = Path.Combine(ProxyFolder, "CheckedProxy");
if (!Directory.Exists(ProxyFolder)) Directory.CreateDirectory(ProxyFolder);
if (!Directory.Exists(CheckedPath)) Directory.CreateDirectory(CheckedPath);
SettingFileConfigure.CreateSettingFile();
var ProxyListFiles = new List<string>();
var files = Directory.GetFiles(ProxyFolder, "*.txt");
foreach (var file in files)
{
ProxyListFiles.Add(file.Split("Proxies")[1].Substring(1));
}
#endregion
#region About
Console.WriteLine("");
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine(@" ____ ________ __
/ __ \_________ _ ____ __ / ____/ /_ ___ _____/ /_____ _____
/ /_/ / ___/ __ \| |/_/ / / / / / / __ \/ _ \/ ___/ //_/ _ \/ ___/
/ ____/ / / /_/ /> </ /_/ / / /___/ / / / __/ /__/ ,< / __/ /
/_/ /_/ \____/_/|_|\__, / \____/_/ /_/\___/\___/_/|_|\___/_/
/____/ ");
Logger.Note(Color.Purple, "Coded By : MohmmadMahdi Khoubrouy", "Github : https://github.com/miticyber", "If you like it, please star the project on GitHub");
Logger.Note(Color.Orange1, $"Current Timeout Value : {SettingFileConfigure.GetTimeOut()} Seconds ", $"Current BotThread Value : {SettingFileConfigure.GetBotThread()}");
#endregion
#region Main Menu
var SectionSelected = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("[green]Please select the section you want :backhand_index_pointing_down:[/]")
.PageSize(10)
.HighlightStyle(Style.Plain.Foreground(Color.Red3_1))
.MoreChoicesText("[grey](Move up and down to reveal more Section)[/]")
.AddChoices(new[] {
"Proxy Checker","Setting","Exit"
})); ;
if (SectionSelected == "Proxy Checker")
{
#region Proxy Section
if (ProxyListFiles.Count() <= 0)
{
Logger.Log("ProxyList File Not Found In Folder Proxies", Color.Red);
Logger.Note(Color.Cyan1, "For Working this app please first create ProxyList", "Copy to Proxies Folder and then Run app");
Logger.Note(Color.Khaki1, "Press enter for exit...");
Console.ReadKey();
}
else
{
Console.WriteLine("");
var selectedFile = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("What's your [green]ProxyList file[/]?")
.PageSize(10)
.MoreChoicesText("[grey](Move up and down to reveal more fruits)[/]")
.AddChoices(ProxyListFiles));
var readFile = FileWorker.ReadFile(Path.Combine(ProxyFolder, selectedFile));
Logger.Log($"{readFile.Count()} Proxy Found !", Color.Green);
Console.WriteLine("");
var SelectedProxyType = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("What's your [blue]ProxyList Type[/]?")
.PageSize(10)
.MoreChoicesText("[grey](Move up and down to reveal more fruits)[/]")
.AddChoices(new[]
{
"http","socks4","socks5"
}));
var ProxyCheckerService = new CheckerService();
ProxyCheckerService.StartCheckProxyService(SettingFileConfigure.GetBotThread(), readFile, SelectedProxyType,
new RegistrarSetting()
.SetGoodPath(Path.Combine(CheckedPath, selectedFile)));
while (true)
{
Thread.Sleep(1000);
if (ProxyCheckerService.GetThreadAlive() <= 0)
{
Logger.Note(Color.Aqua, "All proxies were checked ..", $"Good = {ProxyCheckerService.GetGoodCount()} ", $"Bad = {ProxyCheckerService.GetBadCount()}", "Press enter to exit");
Console.ReadKey();
break;
}
}
}
#endregion
}
else if (SectionSelected == "Setting")
{
#region Setting Section
var SettingItem = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("[green]Please select the section you want [/]")
.PageSize(10)
.HighlightStyle(Style.Plain.Foreground(Color.Red3_1))
.MoreChoicesText("[grey](Move up and down to reveal more Section)[/]")
.AddChoices(new[] {
"BotThread","TimeOut","Exit"
})); ;
if (SettingItem == "BotThread")
{
#region BotThread Section
Logger.Note(Color.Aqua, $"Current BotThread value: {SettingFileConfigure.GetBotThread()}");
var BotThreadNumber = AnsiConsole.Ask<int>(" [royalblue1]What is your desired new[/] [red]number[/] for [green]Bot Thread[/] ?");
if (BotThreadNumber > 0)
{
SettingFileConfigure.SetBotThread(BotThreadNumber);
AnsiConsole.MarkupLine("[italic]The new value was [green]successfully[/] set[/]");
}
else
{
AnsiConsole.MarkupLine("[bold][red]Input cannot be less than zero or zero[/][/]");
AnsiConsole.MarkupLine("[italic]The new value was [red]failed[/] set[/]");
}
#endregion
}
else if (SettingItem == "TimeOut")
{
Logger.Note(Color.Aqua, $"Current TimeOut value: {SettingFileConfigure.GetTimeOut()}");
var TimeOutValue = AnsiConsole.Ask<int>(" [bold][green]What is the amount of[/] [red]timeout[/] [green]based on[/] [red]seconds[/] [/] ?");
if (TimeOutValue > 0)
{
SettingFileConfigure.SetTimeOut(TimeOutValue);
AnsiConsole.MarkupLine("[italic]The new value was [green]successfully[/] set[/]");
}
else
{
AnsiConsole.MarkupLine("[bold][red]Input cannot be less than zero or zero[/][/]");
AnsiConsole.MarkupLine("[italic]The new value was [red]failed[/] set[/]");
}
}
else if (SettingItem == "Exit")
{
#region Exit Section
AnsiConsole.MarkupLine("[italic][aqua] Ok GoodBye .. [/][/]");
Thread.Sleep(1500);
Environment.Exit(0);
#endregion
}
#endregion
}
else if (SectionSelected == "Exit")
{
#region Exit Section
AnsiConsole.MarkupLine("[italic][aqua] Ok GoodBye .. [/][/]");
Thread.Sleep(1500);
Environment.Exit(0);
#endregion
}
#endregion
Console.ReadKey();