-
Notifications
You must be signed in to change notification settings - Fork 369
/
Copy pathProgram.cs
58 lines (52 loc) · 1.67 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
using MultiMiner.Xgminer.Data;
using MultiMiner.Engine.Helpers;
using MultiMiner.Engine.Data.Configuration;
using System.Collections.Generic;
using System;
using System.Net.Sockets;
namespace MultiMiner.PoolChecker
{
class Program
{
static void Main(string[] args)
{
TimeSpan timeout = new TimeSpan(0, 0, 5);
List<Coin> configurations = new List<Coin>(); ;
DonationPools.Seed(configurations);
foreach (Coin coin in configurations)
{
foreach (MiningPool pool in coin.Pools)
{
Uri uri = new Uri(pool.Host);
if (!IsPortOpen(uri.Host, pool.Port, timeout))
{
Console.WriteLine(String.Format("{0} pool {1} (port {2}) is defunct.", coin.PoolGroup.Id, pool.Host, pool.Port));
}
}
}
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
private static bool IsPortOpen(string host, int port, TimeSpan timeout)
{
try
{
using (var client = new TcpClient())
{
var result = client.BeginConnect(host, port, null, null);
var success = result.AsyncWaitHandle.WaitOne(timeout);
if (!success)
{
return false;
}
client.EndConnect(result);
}
}
catch
{
return false;
}
return true;
}
}
}