Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
DevoTalk committed Jul 24, 2024
1 parent 830299c commit 7fdf4e8
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions fast cf ip scanner/Services/IPService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public IPService(FastCFIPScannerDatabase db)
_db = db;
}
#region Test Ips
public async Task<List<IPModel>> GetIpValid(string[] ips, IpOptionModel ipOptions, string protcol)
public async Task<List<IPModel>> GetIpValid(string[] ips, IpOptionModel ipOptions, string protocol)
{
var validIps = new List<IPModel>();
switch (protcol)
switch (protocol)
{
case "Http test (recommended)":
validIps = await GetValidIPWithHttpTest(ips, ipOptions);
Expand Down Expand Up @@ -137,7 +137,7 @@ async Task TestConnectionAsync(string ip)
{
var ports = new List<string>();
var stopwatch = new Stopwatch();
var totolTimeOut = 0;
var totalTimeOut = 0;
var totalPing = 0;
for (int i = 0; i < ipOptions.CountOfRepeatTestForEachIp; i++)
{
Expand All @@ -163,13 +163,13 @@ async Task TestConnectionAsync(string ip)
}
else
{
totolTimeOut++;
totalTimeOut++;
}
}
}
catch
{
totolTimeOut++;
totalTimeOut++;
}
}
}
Expand All @@ -183,7 +183,7 @@ async Task TestConnectionAsync(string ip)
IP = ip,
Ping = ping,
Ports = string.Join(",", ports),
CountOfTimeout = totolTimeOut
CountOfTimeout = totalTimeOut
});
}
}
Expand Down Expand Up @@ -214,7 +214,7 @@ public async Task<List<IPModel>> GetValidIPWithUDPTest(string[] ips, int maxPing
{
var validIp = new ConcurrentBag<IPModel>();
var randips = GetRandomIp(ips);
foreach (var ipAddresse in randips)
foreach (var ipAddress in randips)
{
var t = new Task(() =>
{
Expand All @@ -224,7 +224,7 @@ public async Task<List<IPModel>> GetValidIPWithUDPTest(string[] ips, int maxPing
var client = new UdpClient();

stopwatch.Start();
client.Connect(ipAddresse, 443);
client.Connect(ipAddress, 443);
stopwatch.Stop();

var ping = Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds);
Expand All @@ -233,7 +233,7 @@ public async Task<List<IPModel>> GetValidIPWithUDPTest(string[] ips, int maxPing
{
validIp.Add(new IPModel
{
IP = ipAddresse.ToString(),
IP = ipAddress.ToString(),
Ping = ping,
});
}
Expand Down Expand Up @@ -370,11 +370,11 @@ public List<string> GetRandomIp(string[] ips, int ipCount = 20, int ipRangeCount
}
var randomIps = new List<string>();
var countOfEachRange = ipCount / ipRangeCount;
foreach (var iprange in randomIpRange)
foreach (var ipRange in randomIpRange)
{
for (int i = 1; i < countOfEachRange; i++)
{
randomIps.Add(iprange + random.Next(255));
randomIps.Add(ipRange + random.Next(255));
}
}
return randomIps;
Expand Down

0 comments on commit 7fdf4e8

Please sign in to comment.