private static void ConnectCallback(IAsyncResult result) { PoolConnection mypc = result.AsyncState as PoolConnection; TcpClient client = mypc.TcpClient; if (!mypc.Closed && client.Connected) { try { NetworkStream networkStream = client.GetStream(); mypc.ReceiveBuffer = new byte[client.ReceiveBufferSize]; networkStream.BeginRead(mypc.ReceiveBuffer, 0, mypc.ReceiveBuffer.Length, new AsyncCallback(ReceiveCallback), mypc); // keep things stupid and simple // https://github.com/xmrig/xmrig-proxy/blob/dev/doc/STRATUM_EXT.md#mining-algorithm-negotiation string msg0 = "{\"method\":\"login\",\"params\":{\"login\":\""; string msg1 = "\",\"pass\":\""; string msg2 = "\",\"agent\":\"webminerpool.com\""; string msg3 = ",\"algo\": [\"cn/0\",\"cn/1\",\"cn/2\",\"cn/3\",\"cn/r\",\"cn-lite/0\",\"cn-lite/1\",\"cn-lite/2\",\"cn-pico/trtl\",\"cn/rwz\",\"cn/half\"]"; string msg4 = ",\"algo-perf\": {\"cn/0\":100,\"cn/1\":96,\"cn/2\":84,\"cn/3\":84,\"cn/r\":37,\"cn-lite/0\":200,\"cn-lite/1\":200,\"cn-lite/2\":166,\"cn/rwz\":100,\"cn-pico/trtl\":630,\"cn/half\":120}}"; string msg5 = ",\"id\":1}"; string msg = msg0 + mypc.Login + msg1 + mypc.Password + msg2 + msg3 + msg4 + msg5 + "\n"; mypc.Send(mypc.LastSender, msg); } catch { return; } } else { // slow that down a bit Task.Run(async delegate { await Task.Delay(TimeSpan.FromSeconds(4)); List <Client> cllist = new List <Client>(mypc.WebClients.Values); foreach (Client ev in cllist) { Disconnect(ev, "can not connect to pool."); } }); } }
private static void ConnectCallback(IAsyncResult result) { PoolConnection mygang = result.AsyncState as PoolConnection; TcpClient client = mygang.Client; if (!mygang.Closed && client.Connected) { try { NetworkStream networkStream = client.GetStream(); mygang.ReceiveBuffer = new byte[client.ReceiveBufferSize]; networkStream.BeginRead(mygang.ReceiveBuffer, 0, mygang.ReceiveBuffer.Length, new AsyncCallback(ReceiveCallback), mygang); /* keep things stupid and simple */ string msg0 = "{\"method\":\"login\",\"params\":{\"login\":\""; string msg1 = "\",\"pass\":\""; string msg2 = "\",\"agent\":\"webminerpool.com\"},\"id\":1}"; string msg = msg0 + mygang.Login + msg1 + mygang.Password + msg2 + "\n"; mygang.Send(mygang.LastSender, msg); } catch { return; } } else { // slow that down a bit var t = Task.Run(async delegate { await Task.Delay(TimeSpan.FromSeconds(4)); List <Client> cllist = new List <Client> (mygang.WebClients.Keys); foreach (Client ev in cllist) { Disconnect(ev, "can not connect to pool."); } }); } }