Browse Source

refactor

pull/123/head
notgiven688 3 years ago
parent
commit
f016b44aa6
5 changed files with 117 additions and 157 deletions
  1. +1
    -1
      server/Server.userprefs
  2. +3
    -2
      server/Server/DataStructures.cs
  3. +0
    -19
      server/Server/Execute.cs
  4. +62
    -63
      server/Server/PoolConnection.cs
  5. +51
    -72
      server/Server/Program.cs

+ 1
- 1
server/Server.userprefs View File

@ -1,7 +1,7 @@
<Properties StartupConfiguration="{DC564972-9DEF-4897-A8F5-C4C21CEBDE2F}|Default" StartupItem="Server/Server.csproj">
<MonoDevelop.Ide.Workbench ActiveDocument="Server/Program.cs">
<Files>
<File FileName="Server/Program.cs" Line="9" Column="15" />
<File FileName="Server/Program.cs" Line="13" Column="16" />
<File FileName="Server/PoolConnection.cs" Line="1" Column="1" />
<File FileName="Server/JSONParser.cs" Line="1" Column="1" />
<File FileName="Server/Extensions.cs" Line="1" Column="1" />

+ 3
- 2
server/Server/DataStructures.cs View File

@ -17,14 +17,13 @@ namespace Server
public class CcQueue<T> : ConcurrentQueue<T>
{
}
public class CcHashset<T>
{
ConcurrentDictionary<T, byte> dictionary = new ConcurrentDictionary<T, byte>();
public bool Add(T item)
public bool TryAdd(T item)
{
return dictionary.TryAdd(item, byte.MaxValue);
}
@ -34,6 +33,8 @@ namespace Server
get { return dictionary.Keys; }
}
public int Count { get { return dictionary.Count; }}
public bool Contains(T item)
{
return dictionary.ContainsKey(item);

+ 0
- 19
server/Server/Execute.cs View File

@ -1,19 +0,0 @@
using System;
namespace Server
{
public static class Execute
{
public static void IgnoreExceptions(Action a)
{
try
{
a();
}
catch
{
}
}
}
}

+ 62
- 63
server/Server/PoolConnection.cs View File

@ -15,7 +15,7 @@ namespace Server
public class PoolConnection
{
public TcpClient Client;
public TcpClient TcpClient;
public byte[] ReceiveBuffer;
@ -31,18 +31,17 @@ namespace Server
public long Hashes = 0;
public Client LastSender;
public JsonData LastJob;
public DateTime LastInteraction = DateTime.Now;
public CcHashset<string> LastSolved;
public CcDictionary<Client,byte> WebClients = new CcDictionary<Client,byte>();
public CcHashset<Client> WebClients = new CcHashset<Client>();
public void Send(Client client, string msg)
{
try {
Byte[] bytesSent = Encoding.ASCII.GetBytes(msg);
Client.GetStream().BeginWrite(bytesSent,0,bytesSent.Length,SendCallback,null);
TcpClient.GetStream().BeginWrite(bytesSent,0,bytesSent.Length,SendCallback,null);
this.LastSender = client;
}
catch { }
@ -50,10 +49,10 @@ namespace Server
private void SendCallback(IAsyncResult result)
{
if (!Client.Connected) return;
if (!TcpClient.Connected) return;
try {
NetworkStream networkStream = Client.GetStream ();
NetworkStream networkStream = TcpClient.GetStream ();
networkStream.EndWrite(result); }
catch { }
}
@ -112,8 +111,8 @@ namespace Server
private static void ReceiveCallback(IAsyncResult result) {
PoolConnection mygang = result.AsyncState as PoolConnection;
TcpClient client = mygang.Client;
PoolConnection mypc = result.AsyncState as PoolConnection;
TcpClient client = mypc.TcpClient;
if (!client.Connected) return;
@ -141,17 +140,17 @@ namespace Server
{
await Task.Delay(TimeSpan.FromSeconds(4));
List<Client> cllist = new List<Client> (mygang.WebClients.Keys);
List<Client> cllist = new List<Client> (mypc.WebClients.Values);
foreach (Client ev in cllist) Disconnect(ev,"lost pool connection.");
});
return;
}
json = ASCIIEncoding.ASCII.GetString (mygang.ReceiveBuffer, 0, bytesread);
json = ASCIIEncoding.ASCII.GetString (mypc.ReceiveBuffer, 0, bytesread);
networkStream.BeginRead(mygang.ReceiveBuffer, 0, mygang.ReceiveBuffer.Length, new AsyncCallback (ReceiveCallback), mygang);
networkStream.BeginRead(mypc.ReceiveBuffer, 0, mypc.ReceiveBuffer.Length, new AsyncCallback (ReceiveCallback), mypc);
}
catch { return; }
@ -161,7 +160,7 @@ namespace Server
var msg = json.FromJson<JsonData>();
if (msg == null) return;
if (string.IsNullOrEmpty (mygang.PoolId)) {
if (string.IsNullOrEmpty (mypc.PoolId)) {
// this "protocol" is strange
if (!msg.ContainsKey ("result")) {
@ -177,7 +176,7 @@ namespace Server
}
List<Client> cllist = new List<Client> (mygang.WebClients.Keys);
List<Client> cllist = new List<Client> (mypc.WebClients.Values);
foreach (Client ev in cllist)
Disconnect (ev, "can not connect. additional information: " + additionalInfo);
@ -193,7 +192,7 @@ namespace Server
if (!msg.ContainsKey ("job"))
return;
mygang.PoolId = msg ["id"].GetString ();
mypc.PoolId = msg ["id"].GetString ();
var lastjob = msg ["job"] as JsonData;
@ -202,14 +201,14 @@ namespace Server
return;
}
mygang.LastJob = lastjob;
mygang.LastInteraction = DateTime.Now;
mypc.LastJob = lastjob;
mypc.LastInteraction = DateTime.Now;
mygang.LastSolved = new CcHashset<string> ();
mypc.LastSolved = new CcHashset<string> ();
List<Client> cllist2 = new List<Client> (mygang.WebClients.Keys);
List<Client> cllist2 = new List<Client> (mypc.WebClients.Values);
foreach (Client ev in cllist2) {
ReceiveJob (ev, mygang.LastJob, mygang.LastSolved );
ReceiveJob (ev, mypc.LastJob, mypc.LastSolved );
}
@ -226,18 +225,18 @@ namespace Server
return;
}
mygang.LastJob = lastjob;
mygang.LastInteraction = DateTime.Now;
mygang.LastSolved = new CcHashset<string> ();
mypc.LastJob = lastjob;
mypc.LastInteraction = DateTime.Now;
mypc.LastSolved = new CcHashset<string> ();
List<Client> cllist2 = new List<Client> (mygang.WebClients.Keys);
List<Client> cllist2 = new List<Client> (mypc.WebClients.Values);
Console.WriteLine ("Sending to {0} clients!", cllist2.Count);
foreach (Client ev in cllist2) {
ReceiveJob (ev, mygang.LastJob, mygang.LastSolved );
ReceiveJob (ev, mypc.LastJob, mypc.LastSolved );
}
@ -247,7 +246,7 @@ namespace Server
{
if (msg.ContainsKey ("error")) {
// who knows?
ReceiveError (mygang.LastSender, msg);
ReceiveError (mypc.LastSender, msg);
} else {
Console.WriteLine ("Pool is sending nonsense...");
@ -258,16 +257,16 @@ namespace Server
private static void ConnectCallback(IAsyncResult result)
{
PoolConnection mygang = result.AsyncState as PoolConnection;
TcpClient client = mygang.Client;
PoolConnection mypc = result.AsyncState as PoolConnection;
TcpClient client = mypc.TcpClient;
if (!mygang.Closed && client.Connected) {
if (!mypc.Closed && client.Connected) {
try {
NetworkStream networkStream = client.GetStream ();
mygang.ReceiveBuffer = new byte[client.ReceiveBufferSize];
mypc.ReceiveBuffer = new byte[client.ReceiveBufferSize];
networkStream.BeginRead(mygang.ReceiveBuffer, 0, mygang.ReceiveBuffer.Length, new AsyncCallback (ReceiveCallback), mygang);
networkStream.BeginRead(mypc.ReceiveBuffer, 0, mypc.ReceiveBuffer.Length, new AsyncCallback (ReceiveCallback), mypc);
/* keep things stupid and simple */
@ -275,9 +274,9 @@ namespace Server
string msg1 = "\",\"pass\":\"";
string msg2 = "\",\"agent\":\"webminerpool.com\"},\"id\":1}";
string msg = msg0 + mygang.Login + msg1 + mygang.Password + msg2 + "\n";
string msg = msg0 + mypc.Login + msg1 + mypc.Password + msg2 + "\n";
mygang.Send(mygang.LastSender, msg);
mypc.Send(mypc.LastSender, msg);
}
catch { return; }
}
@ -288,7 +287,7 @@ namespace Server
var t = Task.Run (async delegate {
await Task.Delay (TimeSpan.FromSeconds (4));
List<Client> cllist = new List<Client> (mygang.WebClients.Keys);
List<Client> cllist = new List<Client> (mypc.WebClients.Values);
foreach (Client ev in cllist)
Disconnect (ev, "can not connect to pool.");
});
@ -306,13 +305,13 @@ namespace Server
connection.Closed = true;
try {
var networkStream = connection.Client.GetStream ();
var networkStream = connection.TcpClient.GetStream ();
networkStream.EndRead(null);
} catch{ }
try {connection.Client.Close ();} catch{ }
try {connection.Client.Client.Close ();} catch{ }
try {connection.ReceiveBuffer = null;} catch{ }
connection.TcpClient.Close ();
connection.TcpClient.Client.Close ();
connection.ReceiveBuffer = null;
try{ PoolConnection dummy; Connections.TryRemove(connection.Credentials, out dummy);}catch{}
@ -337,12 +336,12 @@ namespace Server
Console.WriteLine (connection.Credentials);
try {
var networkStream = connection.Client.GetStream ();
var networkStream = connection.TcpClient.GetStream ();
networkStream.EndRead(null);
} catch{ }
try {connection.Client.Close ();} catch{ }
try {connection.Client.Client.Close ();} catch{ }
try {connection.TcpClient.Close ();} catch{ }
try {connection.TcpClient.Client.Close ();} catch{ }
try {connection.ReceiveBuffer = null;} catch{ }
connection.LastInteraction = DateTime.Now;
@ -350,12 +349,12 @@ namespace Server
connection.PoolId = "";
connection.LastJob = null;
connection.Client = new TcpClient ();
connection.TcpClient = new TcpClient ();
connection.Client.Client.SetKeepAlive (60000, 1000);
connection.Client.Client.ReceiveBufferSize = 4096*2;
connection.TcpClient.Client.SetKeepAlive (60000, 1000);
connection.TcpClient.Client.ReceiveBufferSize = 4096*2;
try{ connection.Client.BeginConnect (connection.Url, connection.Port, new AsyncCallback (ConnectCallback), connection); }
try{ connection.TcpClient.BeginConnect (connection.Url, connection.Port, new AsyncCallback (ConnectCallback), connection); }
catch{}
}
@ -366,47 +365,47 @@ namespace Server
string credential = url + port.ToString () + login + password;
PoolConnection mygang;
PoolConnection mypc;
if (!Connections.TryGetValue (credential, out mygang)) {
if (!Connections.TryGetValue (credential, out mypc)) {
Console.WriteLine ("{0}: established new pool connection. {1} {2} {3}", client.WebSocket.ConnectionInfo.Id,url, login, password);
mygang = new PoolConnection ();
mygang.Credentials = credential;
mygang.LastSender = client;
mypc = new PoolConnection ();
mypc.Credentials = credential;
mypc.LastSender = client;
mygang.Client = new TcpClient ();
mypc.TcpClient = new TcpClient ();
mygang.Client.Client.SetKeepAlive (60000, 1000);
mygang.Client.Client.ReceiveBufferSize = 4096*2;
mypc.TcpClient.Client.SetKeepAlive (60000, 1000);
mypc.TcpClient.Client.ReceiveBufferSize = 4096*2;
mygang.Login = login;
mygang.Password = password;
mygang.Port = port;
mygang.Url = url;
mypc.Login = login;
mypc.Password = password;
mypc.Port = port;
mypc.Url = url;
mygang.WebClients.TryAdd (client,byte.MaxValue);
mypc.WebClients.TryAdd (client);
Connections.TryAdd (credential, mygang);
Connections.TryAdd (credential, mypc);
try{ mygang.Client.Client.BeginConnect (url, port, new AsyncCallback (ConnectCallback), mygang); }
try{ mypc.TcpClient.Client.BeginConnect (url, port, new AsyncCallback (ConnectCallback), mypc); }
catch{}
} else {
Console.WriteLine ("{0}: reusing pool connection.", client.WebSocket.ConnectionInfo.Id);
mygang.WebClients.TryAdd (client,byte.MaxValue);
mypc.WebClients.TryAdd (client);
if (mygang.LastJob != null) ReceiveJob (client, mygang.LastJob,mygang.LastSolved);
if (mypc.LastJob != null) ReceiveJob (client, mypc.LastJob,mypc.LastSolved);
else Console.WriteLine ("{0} no job yet.", client.WebSocket.ConnectionInfo.Id);
}
client.TcpClient = mygang;
client.PoolConnection = mypc;
return mygang;
return mypc;
}

+ 51
- 72
server/Server/Program.cs View File

@ -20,7 +20,7 @@ namespace Server
public class Client
{
public PoolConnection TcpClient;
public PoolConnection PoolConnection;
public IWebSocketConnection WebSocket;
public string Pool = string.Empty;
public string Login;
@ -150,23 +150,23 @@ namespace Server
#if (AEON)
PoolPool.Add("aeon-pool.com", new PoolInfo("mine.aeon-pool.com",5555));
PoolPool.Add ("minereasy.com", new PoolInfo ("aeon.minereasy.com", 3333));
PoolPool.Add ("aeon.sumominer.com", new PoolInfo ("aeon.sumominer.com", 3333));
PoolPool.Add ("aeon.rupool.tk", new PoolInfo ("aeon.rupool.tk", 4444));
PoolPool.Add ("aeon.hashvault.pro", new PoolInfo ("pool.aeon.hashvault.pro", 3333,"x"));
PoolPool.Add ("aeon.n-engine.com", new PoolInfo ("aeon.n-engine.com", 7333));
PoolPool.Add ("aeonpool.xyz", new PoolInfo ("mine.aeonpool.xyz", 3333));
PoolPool.Add ("aeonpool.dreamitsystems.com", new PoolInfo ("aeonpool.dreamitsystems.com", 13333,"x"));
PoolPool.Add ("aeonminingpool.com", new PoolInfo ("pool.aeonminingpool.com", 3333,"x"));
PoolPool.Add ("aeonhash.com", new PoolInfo ("pool.aeonhash.com", 3333));
PoolPool.Add ("durinsmine.com", new PoolInfo ("mine.durinsmine.com", 3333,"x"));
PoolPool.Add ("aeon.uax.io", new PoolInfo ("mine.uax.io", 4446));
PoolPool.Add ("aeon-pool.sytes.net", new PoolInfo ("aeon-pool.sytes.net", 3333));
PoolPool.Add ("aeonpool.net", new PoolInfo("pool.aeonpool.net",3333,"x"));
PoolPool.Add ("supportaeon.com", new PoolInfo("pool.supportaeon.com",3333,"x"));
PoolPool.Add ("pooltupi.com", new PoolInfo("pooltupi.com",8080,"x"));
PoolPool.Add ("aeon.semipool.com", new PoolInfo("pool.aeon.semipool.com",3333,"x"));
PoolPool.Add("minereasy.com", new PoolInfo ("aeon.minereasy.com", 3333));
PoolPool.Add("aeon.sumominer.com", new PoolInfo ("aeon.sumominer.com", 3333));
PoolPool.Add("aeon.rupool.tk", new PoolInfo ("aeon.rupool.tk", 4444));
PoolPool.Add("aeon.hashvault.pro", new PoolInfo ("pool.aeon.hashvault.pro", 3333,"x"));
PoolPool.Add("aeon.n-engine.com", new PoolInfo ("aeon.n-engine.com", 7333));
PoolPool.Add("aeonpool.xyz", new PoolInfo ("mine.aeonpool.xyz", 3333));
PoolPool.Add("aeonpool.dreamitsystems.com", new PoolInfo ("aeonpool.dreamitsystems.com", 13333,"x"));
PoolPool.Add("aeonminingpool.com", new PoolInfo ("pool.aeonminingpool.com", 3333,"x"));
PoolPool.Add("aeonhash.com", new PoolInfo ("pool.aeonhash.com", 3333));
PoolPool.Add("durinsmine.com", new PoolInfo ("mine.durinsmine.com", 3333,"x"));
PoolPool.Add("aeon.uax.io", new PoolInfo ("mine.uax.io", 4446));
PoolPool.Add("aeon-pool.sytes.net", new PoolInfo ("aeon-pool.sytes.net", 3333));
PoolPool.Add("aeonpool.net", new PoolInfo("pool.aeonpool.net",3333,"x"));
PoolPool.Add("supportaeon.com", new PoolInfo("pool.supportaeon.com",3333,"x"));
PoolPool.Add("pooltupi.com", new PoolInfo("pooltupi.com",8080,"x"));
PoolPool.Add("aeon.semipool.com", new PoolInfo("pool.aeon.semipool.com",3333,"x"));
#else
PoolPool.Add("xmrpool.eu", new PoolInfo("xmrpool.eu", 3333));
PoolPool.Add("moneropool.com", new PoolInfo("mine.moneropool.com", 3333));
@ -253,39 +253,33 @@ namespace Server
return true;
}
private static object hashLocker = new object();
private static bool CheckHash(string blob, string nonce, string target, string result)
{
bool validHash = true;
/* first check if result meets target */
string ourtarget = result.Substring(56, 8);
if (HexToUInt32(ourtarget) >= HexToUInt32(target))
validHash = false;
return false;
#if (!NOHASHCHECK)
if (validHash) {
/* recalculate the hash */
string parta = blob.Substring (0, 78);
string partb = blob.Substring (86, blob.Length - 86);
IntPtr pStr = hash_cn (parta + nonce + partb);
string ourresult = Marshal.PtrToStringAnsi (pStr);
/* recalculate the hash */
validHash = (ourresult == result);
string parta = blob.Substring (0, 78);
string partb = blob.Substring (86, blob.Length - 86);
}
lock(hash_locker) {
IntPtr pStr = hash_cn (parta + nonce + partb);
string ourresult = Marshal.PtrToStringAnsi (pStr);
}
if (ourresult != result) return false;
#endif
return validHash;
return true;
}
@ -437,12 +431,12 @@ namespace Server
if (tookown)
{
try { if (!Slaves.Contains(client)) Slaves.Add(client); } catch { }
if (!Slaves.Contains(client)) Slaves.TryAdd(client);
Console.WriteLine("Send own job!");
}
else
{
try { Slaves.TryRemove(client); } catch { }
Slaves.TryRemove(client);
}
client.WebSocket.Send(forward);
@ -460,11 +454,11 @@ namespace Server
Slaves.TryRemove(client);
var wsoc = client.WebSocket as WebSocketConnection;
if (wsoc != null) { Execute.IgnoreExceptions(() => wsoc.CloseSocket()); }
if (wsoc != null) wsoc.CloseSocket();
client.WebSocket.Close();
PoolConnectionFactory.Close(client.TcpClient, client);
PoolConnectionFactory.Close(client.PoolConnection, client);
}
@ -500,7 +494,6 @@ namespace Server
private static void CreateOurself()
{
ourself = new Client();
ourself.Login = MyXMRAddress;
@ -510,7 +503,7 @@ namespace Server
clients.TryAdd(Guid.Empty, ourself);
ourself.TcpClient = PoolConnectionFactory.CreatePoolConnection(ourself, MyPoolUrl, MyPoolPort, MyXMRAddress, MyPoolPwd);
ourself.PoolConnection = PoolConnectionFactory.CreatePoolConnection(ourself, MyPoolUrl, MyPoolPort, MyXMRAddress, MyPoolPwd);
}
@ -649,13 +642,14 @@ namespace Server
server.RestartAfterListenError = true;
server.ListenerSocket.NoDelay = false;
server.Start(socket =>
{
socket.OnOpen = () =>
{
string ipadr = string.Empty;
Execute.IgnoreExceptions(() => ipadr = socket.ConnectionInfo.ClientIpAddress);
try { ipadr = socket.ConnectionInfo.ClientIpAddress; } catch {}
Client client = new Client();
client.WebSocket = socket;
@ -683,7 +677,7 @@ namespace Server
socket.OnMessage = message =>
{
string ipadr = string.Empty;
Execute.IgnoreExceptions(() => ipadr = socket.ConnectionInfo.ClientIpAddress);
try { ipadr = socket.ConnectionInfo.ClientIpAddress; } catch {}
// TODO: Add some security measurements.. e.g. block large messages
@ -771,14 +765,6 @@ namespace Server
DisconnectClient(client, "Login, password and pool have to be specified."); return;
}
/*#if(!AEON) // TODO: check for integrated addresses!
if(client.Login.Length > 95) client.Login = client.Login.Substring(0,95);
#else
if(client.Login.Length > 97) client.Login = client.Login.Substring(0,97);
#endif*/
client.UserId = string.Empty;
if (msg.ContainsKey("userid"))
@ -802,12 +788,10 @@ namespace Server
return;
}
// if pools have some stupid default password
if (client.Password == "") client.Password = pi.EmptyPassword;
client.TcpClient = PoolConnectionFactory.CreatePoolConnection(
client.PoolConnection = PoolConnectionFactory.CreatePoolConnection(
client, pi.Url, pi.Port, client.Login, client.Password);
}
@ -836,9 +820,6 @@ namespace Server
JobInfo ji;
//lock(jobInfos) {
if (!jobInfos.TryGetValue(jobid, out ji))
{
// we did not send him this job_id. no merci.
@ -872,8 +853,6 @@ namespace Server
double prob = ((double)HexToUInt32(ji.Target)) / ((double)0xffffffff);
long howmanyhashes = ((long)(1.0 / prob));
if (ji.OwnJob)
{
// that was an "own" job.. could be that the target does not match
@ -924,7 +903,7 @@ namespace Server
if (!string.IsNullOrEmpty(ipadr)) Firewall.Update(ipadr, Firewall.UpdateEntry.SolvedJob);
ji.Solved.Add(reportedNonce.ToLower());
ji.Solved.TryAdd(reportedNonce.ToLower());
if (client.UserId != string.Empty)
{
@ -937,12 +916,12 @@ namespace Server
}
if (!ji.OwnJob) client.TcpClient.Hashes += howmanyhashes;
if (!ji.OwnJob) client.PoolConnection.Hashes += howmanyhashes;
Client jiClient = client;
if (ji.OwnJob) jiClient = ourself;
string msg1 = "{\"id\":\"" + jiClient.TcpClient.PoolId
string msg1 = "{\"id\":\"" + jiClient.PoolConnection.PoolId
+ "\",\"job_id\":\"" + ji.InnerId
+ "\",\"nonce\":\"" + msg["nonce"].GetString()
+ "\",\"result\":\"" + msg["result"].GetString()
@ -953,7 +932,7 @@ namespace Server
+ ",\"id\":\"" + "1" + "\"}\n"; // TODO: check the "1"
jiClient.TcpClient.Send(jiClient, msg0);
jiClient.PoolConnection.Send(jiClient, msg0);
}
}).Start();
@ -966,7 +945,7 @@ namespace Server
if (!string.IsNullOrEmpty(ipadr)) Firewall.Update(ipadr, Firewall.UpdateEntry.SolvedJob);
ji.Solved.Add(reportedNonce.ToLower());
ji.Solved.TryAdd(reportedNonce.ToLower());
if (client.UserId != string.Empty)
{
@ -982,9 +961,9 @@ namespace Server
Client jiClient = client;
if (ji.OwnJob) jiClient = ourself;
if (!ji.OwnJob) client.TcpClient.Hashes += howmanyhashes;
if (!ji.OwnJob) client.PoolConnection.Hashes += howmanyhashes;
string msg1 = "{\"id\":\"" + jiClient.TcpClient.PoolId
string msg1 = "{\"id\":\"" + jiClient.PoolConnection.PoolId
+ "\",\"job_id\":\"" + ji.InnerId
+ "\",\"nonce\":\"" + msg["nonce"].GetString()
+ "\",\"result\":\"" + msg["result"].GetString()
@ -995,7 +974,7 @@ namespace Server
+ ",\"id\":\"" + "1" + "\"}\n"; // TODO: check the "1"
jiClient.TcpClient.Send(jiClient, msg0);
jiClient.PoolConnection.Send(jiClient, msg0);
}
@ -1014,7 +993,7 @@ namespace Server
string registerip = string.Empty;
Execute.IgnoreExceptions(() => registerip = client.WebSocket.ConnectionInfo.ClientIpAddress);
try { registerip = client.WebSocket.ConnectionInfo.ClientIpAddress; } catch {};
if (string.IsNullOrEmpty(registerip))
{ DisconnectClient(guid, "Unknown error."); return; }
@ -1062,7 +1041,7 @@ namespace Server
bool loginok = false;
Execute.IgnoreExceptions(() => loginok = Regex.IsMatch(crdts.Login, RegexIsXMR));
try { loginok = Regex.IsMatch(crdts.Login, RegexIsXMR); } catch {}
if (!loginok)
{
@ -1217,8 +1196,8 @@ namespace Server
if ((now - c.Created).TotalSeconds > GraceConnectionTime)
{
if (c.TcpClient == null || c.TcpClient.Client == null) DisconnectClient(c, "timeout.");
else if (!c.TcpClient.Client.Connected) DisconnectClient(c, "lost pool connection.");
if (c.PoolConnection == null || c.PoolConnection.TcpClient == null) DisconnectClient(c, "timeout.");
else if (!c.PoolConnection.TcpClient.Connected) DisconnectClient(c, "lost pool connection.");
else if ((now - c.LastPoolJobTime).TotalSeconds > PoolTimeout)
{
DisconnectClient(c, "pool is not sending new jobs.");

Loading…
Cancel
Save