コード例 #1
0
ファイル: Miner.cs プロジェクト: AnonymousPoolRouter/Router
        // The running function of each thread.
        private void Run()
        {
            try
            {
                // Try to connect to the proxy.
                ProxyConnection = new Socks5ProxyClient(configuration.GetProxyAddress(), int.Parse(configuration.GetProxyPort().ToString()), "", "");

                // Get the information for the address.
                poolInformation = GetPoolInformationForAddress();

                // Try to connect to the pool
                PoolConnection = ProxyConnection.CreateConnection(
                    poolInformation.hostname,
                    poolInformation.port
                    );

                // Write to the console that the pool has beenc onnected.
                Program.ConsoleWriteLineWithColorAndTime(ConsoleColor.Yellow, (String.Format("Network traffic from Miner {0} will appear from {1}.", id, GetProxyRemoteAddress())));
                Program.ConsoleWriteLineWithColorAndTime(ConsoleColor.Green, "Miner has successfully connected to their desired pool: " + GetPoolInformationFromMiner().hostname);

                // Configure Timeouts
                SetTimeouts();
            }
            catch (Exception exception)
            {
                Program.ConsoleWriteLineWithColorAndTime(ConsoleColor.Red, "Failed to establish a connection to the pool, the miner will be disconnected.");
                Console.WriteLine(exception.ToString());
            }

            if (PoolConnection != null && proxyResolvedRemoteAddress != null)
            {
                while (MinerConnection.Connected && PoolConnection.Connected)
                {
                    // Small sleep so we don't use 100% of the cpu
                    Thread.Sleep(10);

                    // Exchange the data.
                    ExchangeData();
                }
            }

            // See you, space cowboy.
            dispose = true;
        }
コード例 #2
0
ファイル: Miner.cs プロジェクト: minernl/PoolOverSocks5
        // The working thread.
        private void Run()
        {
            try
            {
                // Try to connect to the proxy.
                ProxyConnection = new Socks5ProxyClient(configuration.GetProxyAddress(), configuration.GetProxyPort(), "", "");

                // Try to connect to the pool
                PoolConnection = ProxyConnection.CreateConnection(configuration.GetPoolAddress(), configuration.GetPoolPort());

                // Write to the console that the pool has beenc onnected.
                Program.ConsoleWriteLineWithColor(ConsoleColor.Green, "Successfully connected to your pool!");
                Program.ConsoleWriteLineWithColor(ConsoleColor.Green, "The new miner is ready to mine!");
            }
            catch (Exception exception)
            {
                Program.ConsoleWriteLineWithColor(ConsoleColor.Red, "Failed to establish a connection to the pool, the miner will be disconnected.");
                Console.WriteLine(exception.ToString());
            }

            // Main routine that sleeps and exchanges data to prevent high cpu usage.
            while (MinerConnection.Connected && PoolConnection.Connected)
            {
                // Small sleep so we don't use 100% of the cpu
                Thread.Sleep(10);

                // Exchange the data.
                ExchangeData();
            }

            // See you, space cowboy.
            wantsToBeDisposed = true;
        }