Esempio n. 1
0
        public void Start(IPEndPoint local, IPEndPoint remote, string _walletaddress, ref string _console)
        {
            IsRuning = true;
            _mainSocket.Bind(local);
            _mainSocket.Listen(500);

            walletaddress = _walletaddress;
            console       = _console;
            new Thread(() =>
            {
                try
                {
                    while (IsRuning)
                    {
                        var source      = _mainSocket.Accept();
                        var destination = new TcpForwarderSlim();

                        destinations.Add(destination);
                        var state = new State(source, destination._mainSocket);
                        destination.Connect(remote, source, writelog);
                        source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceive, state);
                    }
                }
                catch { }
            }).Start();
        }
Esempio n. 2
0
 private void ChangeStartState()
 {
     if (Started)
     {
         btnStartProxy.BackColor = Color.Green;
         btnStartProxy.Text      = "Start Proxy";
         Started = false;
         proxy.Stop();
         proxy = null;
     }
     else
     {
         btnStartProxy.BackColor = Color.Red;
         btnStartProxy.Text      = "Stop Proxy";
         Started = true;
         StartProxy();
     }
 }
Esempio n. 3
0
        void StartProxy()
        {
            string Error = "";

            if (String.IsNullOrEmpty(Properties.Settings.Default.PoolHost))
            {
                Error += "- Pool host is reqiured" + Environment.NewLine;
            }
            if (String.IsNullOrEmpty(Properties.Settings.Default.WalletAddress))
            {
                Error += "- My Wallet address is reqiured" + Environment.NewLine;
            }
            if (Error != "")
            {
                MessageBox.Show(Error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Started = false;
                btnStartProxy.BackColor = Color.Green;
                btnStartProxy.Text      = "Start Proxy";
                return;
            }
            string activity = String.Format("Start proxy connect to {0}:{1}", Properties.Settings.Default.PoolHost, Properties.Settings.Default.PoolPort);

            logger.Info(activity);
            consoleLog.AppendText(activity + Environment.NewLine);


            try
            {
                IPHostEntry hostEntry;


                proxy           = new TcpForwarderSlim();
                hostEntry       = Dns.GetHostEntry(Properties.Settings.Default.PoolHost);
                proxy.writelog += new TcpForwarderSlim.ConsoleEventMsg(proxy_writelog);
                proxy.Start(new IPEndPoint(IPAddress.Any, Convert.ToInt32(Properties.Settings.Default.ListenPort)),
                            new IPEndPoint(hostEntry.AddressList[0], Convert.ToInt32(Properties.Settings.Default.PoolPort)), Properties.Settings.Default.WalletAddress, ref consoleMsg);
            }
            catch (Exception ex)
            {
                ChangeStartState();
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                logger.Error(ex.Message);
            }
        }