示例#1
0
        public void forwardFrame(IPFrame frame)
        {
            var id       = RandomString(10);
            var udpFrame = (UDPFrame)frame.EncapsulatedFrame;
            var e        = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("192.168.1.220"), udpFrame.DestinationPort);

            logger.Debug("{0} Source Port: {1}", id, udpFrame.SourcePort);
            logger.Debug("{0} Dest Port: {1}", id, udpFrame.DestinationPort);
            ProxySocket socket;
            var         cacheKey = string.Format("{0}:{1}->{2}", udpFrame.SourcePort, udpFrame.DestinationPort, e.ToString());

            if (!natTable.TryGetValue(cacheKey, out socket))
            {
                socket = new ProxySocket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                socket.ProxyEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("192.168.1.150"), 1080);
                socket.ProxyType     = ProxyTypes.Socks5;
                socket.Connect(e);
                Task.Run(() =>
                {
                    try
                    {
                        logger.Debug("{0} Create a new UDP Receive Task", id);
                        var buffer = new byte[8192];
                        ProxySocket tmp;
                        while (natTable.TryGetValue(cacheKey, out tmp))
                        {
                            logger.Debug("start receive");
                            var bytesReceived = socket.Receive(buffer);
                            logger.Debug("{0} Received packet", id);
                            natTable.Add(cacheKey, socket);
                            var receivedIPFrame                = new IPv4Frame();
                            receivedIPFrame.SourceAddress      = frame.DestinationAddress;
                            receivedIPFrame.DestinationAddress = frame.SourceAddress;
                            receivedIPFrame.Protocol           = IPProtocol.UDP;
                            var receivedUDPFrame               = new UDPFrame();
                            receivedUDPFrame.SourcePort        = udpFrame.DestinationPort;
                            receivedUDPFrame.DestinationPort   = udpFrame.SourcePort;
                            logger.Debug("{0} RSource Port: {1}", id, receivedUDPFrame.SourcePort);
                            logger.Debug("{0} RDest Port: {1}", id, receivedUDPFrame.DestinationPort);
                            receivedUDPFrame.EncapsulatedFrame = new RawDataFrame(buffer, 0, bytesReceived);
                            receivedIPFrame.EncapsulatedFrame  = receivedUDPFrame;
                            receivedUDPFrame.Checksum          = receivedUDPFrame.CalculateChecksum(receivedIPFrame.GetPseudoHeader());
                            tap.Write(receivedIPFrame.FrameBytes, 0, receivedIPFrame.Length);
                            tap.Flush();
                            logger.Debug("{0} wrote", id);
                        }
                    }
                    catch (SocketException err)
                    {
                        logger.Error(err);
                    }
                });
            }
            natTable.Add(cacheKey, socket);
            socket.BeginSend(udpFrame.EncapsulatedFrame.FrameBytes, 0, udpFrame.EncapsulatedFrame.FrameBytes.Length, 0, ar =>
            {
                socket.EndSend(ar);
                logger.Debug("{0} Sent to Dest", id);
            }, null);
        }
示例#2
0
        /// <summary>
        ///   Opens the connection to the XMPP server.
        /// </summary>
        private void Connect()
        {
            try
            {
                if (ConnectionString.ResolveHostName)
                {
                    // ReSharper disable RedundantBaseQualifier
                    base.ResolveHostName();
                    // ReSharper restore RedundantBaseQualifier
                }

                var hostadd      = Dns.GetHostEntry(HostName).AddressList[0];
                var hostEndPoint = new IPEndPoint(hostadd, ConnectionString.PortNumber);

                socket = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                if (ConnectionString.UseProxy)
                {
                    IPAddress proxyadd      = Dns.GetHostEntry(ConnectionString.ProxyServer).AddressList[0];
                    var       proxyEndPoint = new IPEndPoint(proxyadd, ConnectionString.ProxyPortNumber);

                    switch (ConnectionString.ProxyType)
                    {
                    case "SOCKS4":
                        socket.ProxyType = ProxyTypes.Socks4;
                        break;

                    case "SOCKS5":
                        socket.ProxyType = ProxyTypes.Socks5;
                        break;

                    default:
                        socket.ProxyType = ProxyTypes.None;
                        break;
                    }

                    socket.ProxyEndPoint = proxyEndPoint;
                    socket.ProxyUser     = ConnectionString.ProxyUserName;

                    if (!String.IsNullOrWhiteSpace(ConnectionString.ProxyPassword))
                    {
                        socket.ProxyPass = ConnectionString.ProxyPassword;
                    }
                }

                // Disables the Nagle algorithm for send coalescing.
                socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1);

                // Make the socket to connect to the Server
                socket.Connect(hostEndPoint);

                // Create the Stream Instance
                networkStream = new NetworkStream(socket, false);
            }
            catch (Exception ex)
            {
                throw new XmppException(
                          String.Format("Unable to connect to XMPP server {0}", ConnectionString.HostName), ex);
            }
        }
示例#3
0
        /// <summary>
        /// 连接到服务器
        /// </summary>
        public bool Connect()
        {
            if (socket != null && socket.Connected)
            {
                return(true);
            }
            int retry = 0;

Connect:
            try
            {
                socket = GetSocket();
                socket.Connect(epServer);
                BeginDataReceive(this.socket);
                return(true);
            }
            catch (Exception e)
            {
                retry++;
                if (retry < 3)
                {
                    goto Connect;
                }
                policy.OnConnectServerError(e);
                return(false);
            }
        }
示例#4
0
        private protected override ArxOne.Ftp.FtpClient _getClient()
        {
            var client = new ArxOne.Ftp.FtpClient(this.Uri != null ? this.Uri : new Uri("ftp://" + this.Host), this.Credentials, new FtpClientParameters()
            {
                ConnectTimeout = TimeSpan.FromSeconds(60),
                ProxyConnect   = e =>
                {
                    var s = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
                    {
                        ProxyEndPoint = new IPEndPoint(IPAddress.Parse(_config.IpAddress), _config.Port),
                        ProxyUser     = _config.UserName,
                        ProxyPass     = _config.Password,
                        ProxyType     = _config.Type
                    };

                    switch (e)
                    {
                    case DnsEndPoint dns:
                        s.Connect(dns.Host, dns.Port);
                        break;

                    case IPEndPoint ip:
                        s.Connect(ip);
                        break;

                    default: throw new NotSupportedException();
                    }

                    return(s);
                }
            });
示例#5
0
 public void Connect(string host, int port)
 {
     ReceivedLength         = 0;
     Encryption.Initialized = false;
     Socket = SocketFactory.CreateSocket();
     Socket.BeginConnect(host, port, ConnectCallback, null);
 }
示例#6
0
        private SocksHttpWebResponse InternalGetResponse()
        {
            var response = new StringBuilder();

            using (var _socksConnection =
                       new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
            {
                var proxyUri  = Proxy.GetProxy(RequestUri);
                var ipAddress = GetProxyIpAddress(proxyUri);
                _socksConnection.ProxyEndPoint = new IPEndPoint(ipAddress, proxyUri.Port);
                _socksConnection.ProxyType     = ProxyTypes.Socks5;

                // open connection
                _socksConnection.Connect(RequestUri.Host, 80);
                // send an HTTP request
                _socksConnection.Send(Encoding.ASCII.GetBytes(RequestMessage));
                // read the HTTP reply
                var buffer = new byte[1024];

                var bytesReceived = _socksConnection.Receive(buffer);
                while (bytesReceived > 0)
                {
                    response.Append(Encoding.ASCII.GetString(buffer, 0, bytesReceived));
                    bytesReceived = _socksConnection.Receive(buffer);
                }
            }
            return(new SocksHttpWebResponse(response.ToString()));
        }
示例#7
0
        /// <summary>
        /// </summary>
        /// <param name="ar">The ar.</param>
        protected virtual void EndDataReceive(IAsyncResult ar)
        {
            if (this.socket == null || !this.socket.Connected)
            {
                return;
            }
            int cnt = 0;

            try
            {
                ProxySocket socket = (ProxySocket)ar.AsyncState;
                cnt = socket.EndReceive(ar);
                if (cnt != 0)
                {
                    ByteBuffer byteBuffer = new ByteBuffer(receiveBuf, 0, cnt);
                    try
                    {
                        policy.PushIn(byteBuffer);
                    }
                    catch (Exception e)
                    {
                        policy.PushIn(policy.CreateErrorPacket(ErrorPacketType.RUNTIME_ERROR, this.Name, e));
                    }

                    //创建一个新的字节对象
                    receiveBuf.Initialize();
                }
                BeginDataReceive(socket);
            }
            catch (Exception e)
            {
                policy.OnNetworkError(e);
            }
        }
        /// <summary>
        /// Called when an incoming connection has been accepted.
        /// </summary>
        /// <param name="ar"></param>
        protected virtual void EndAcceptCallback(IAsyncResult ar)
        {
            ProxySocket listenSocket = (ProxySocket)ar.AsyncState;

            try
            {
                dcSocket = listenSocket.EndAccept(ar);

                DCState = DirectConnectionState.Foo;

                Trace.WriteLineIf(Settings.TraceSwitch.TraceInfo,
                                  "I have listened on " + dcSocket.LocalEndPoint + " and setup a DC with " + dcSocket.RemoteEndPoint, GetType().Name);

                // Stop listening
                StopListening();

                // Begin accepting messages
                Processor.BeginDataReceive(dcSocket);

                OnConnected();
            }
            catch (Exception ex)
            {
                Trace.WriteLineIf(Settings.TraceSwitch.TraceError, GetType().ToString() + " Error: " + ex.Message);
            }
        }
示例#9
0
 public IOCPClient(string ip, int port, bool isservice = true, string daili = "", ProxyTypes pt = ProxyTypes.None)
 {
     try
     {
         bool_1        = isservice;
         proxySocket_0 = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         proxySocket_0.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, new LingerOption(true, 0));
         if (daili.Trim().Length > 0)
         {
             string[] array = daili.Split('|');
             if (pt == ProxyTypes.Https)
             {
                 array = daili.Split(':');
             }
             proxySocket_0.ProxyEndPoint = new IPEndPoint(IPAddress.Parse(array[0]), Convert.ToInt32(array[1]));
             if (array.Length > 2)
             {
                 proxySocket_0.ProxyUser = array[2];
                 proxySocket_0.ProxyPass = array[3];
             }
         }
         proxySocket_0.ProxyType = pt;
         arc4_0 = null;
         arc4_1 = null;
         IPAddress address = IPAddress.Parse(ip);
         ipendPoint_0      = new IPEndPoint(address, port);
         timer_0           = new System.Timers.Timer(15000.0);
         timer_0.Elapsed  += timer_0_Elapsed;
         timer_0.AutoReset = true;
     }
     catch
     {
         throw new Exception("GJCW");
     }
 }
        public override void Disconnect()
        {
            // clean up the socket properly
            if (socket != null)
            {
                ProxySocket pSocket = socket;
                socket = null;

                try
                {
                    if (IsSocketConnected(pSocket))
                    {
                        pSocket.Shutdown(SocketShutdown.Both);
                    }
                }
                catch (Exception)
                {
                }
                finally
                {
                    pSocket.Close();
                }

                // We don't need to call OnDisconnect here since EndReceiveCallback will be call automatically later on. (This is not valid if disconnected remotelly)
                // We need to call OnDisconnect after EndReceiveCallback if disconnected locally.
                // We call Disconnect() when OnDisconnected event fired.
            }
        }
示例#11
0
文件: Form1.cs 项目: alien88/wrenbot
        public void _OnGameEnter(ProxySocket Socket, uint ClientSerial, NewProxy Proxy, uint PSerial)
        {
            BlackMagic M = EnableMagic(Socket.Name, Socket);

            Clients[ClientSerial].Magic          = M;
            Clients[ClientSerial].Aisling.Serial = PSerial;
        }
示例#12
0
    static void Main(string[] args)
    {
        // create a new ProxySocket
        ProxySocket s = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

        // set the proxy settings
        s.ProxyEndPoint = new IPEndPoint(IPAddress.Parse("10.0.0.5"), 1080);
        s.ProxyUser     = "******";
        s.ProxyPass     = "******";
        s.ProxyType     = ProxyTypes.Socks5;            // if you set this to ProxyTypes.None,
        // the ProxySocket will act as a normal Socket
        // connect to the remote server
        // (note that the proxy server will resolve the domain name for us)
        s.Connect("www.mentalis.org", 80);
        // send an HTTP request
        s.Send(Encoding.ASCII.GetBytes("GET / HTTP/1.0\r\nHost: www.mentalis.org\r\n\r\n"));
        // read the HTTP reply
        int recv = 0;

        byte [] buffer = new byte[1024];
        recv = s.Receive(buffer);
        while (recv > 0)
        {
            Console.Write(Encoding.ASCII.GetString(buffer, 0, recv));
            recv = s.Receive(buffer);
        }
        // wait until the user presses enter
        Console.WriteLine("Press enter to continue...");
        Console.ReadLine();
    }
示例#13
0
        private void AddRolePage(ProxySocket proxySocket)
        {
            if (InvokeRequired)
            {
                Invoke(new Action <ProxySocket>(AddRolePage), proxySocket);
            }
            else
            {
                if (_dicProxySocket.ContainsKey(proxySocket.PlayerInfo.Username))
                {
                    var rc = (RoleControl)tcAccount.TabPages[proxySocket.PlayerInfo.Username].Controls[0];
                    proxySocket.SetRoleControl(rc);
                    rc.SetProxySocket(proxySocket);
                    _dicProxySocket[proxySocket.PlayerInfo.Username] = proxySocket;
                    return;
                }
                var role = new RoleControl();
                proxySocket.SetRoleControl(role);
                role.SetProxySocket(proxySocket);
                _dicProxySocket.Add(proxySocket.PlayerInfo.Username, proxySocket);

                var tp = new TabPage(proxySocket.PlayerInfo.Username);
                tp.Name = proxySocket.PlayerInfo.Username;
                tp.Controls.Add(role);
                role.Dock = DockStyle.Fill;
                tcAccount.TabPages.Add(tp);
            }
        }
示例#14
0
        public ServerEntity Handle(ServerEntity request1, bool request2, ServerAcceptCallback request3)
        {
            return(_repository.ActionResult(x => x.Port == request1.Port, x =>
            {
                if (x.IsRunning == request2)
                {
                    throw new Exception($"server running state is already : {x.IsRunning}");
                }

                if (request2)
                {
                    ProxySocket Socket = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    Socket.ProxyEndPoint = new IPEndPoint(IPAddress.Parse("109.248.110.177"), 24532);
                    Socket.ProxyUser = "******";
                    Socket.ProxyPass = "******";
                    Socket.ProxyType = ProxyTypes.Socks5;
                    x.Socket = Socket;
                    x.Socket.Bind(new IPEndPoint(IPAddress.Any, x.Port));
                    x.Socket.Listen(10);

                    x.Socket.BeginAccept(request3.Callback, x.Socket);
                }
                else
                {
                    x.Socket.Dispose();
                }

                x.IsRunning = request2;

                logger.Info($"server running state : {x.IsRunning}");

                return x;
            }));
        }
示例#15
0
        public MyTcp1225(string ip, int port, ProxyTypes pt = ProxyTypes.None, string daili = "", string localip = "")
        {
            ipendPoint_0 = new IPEndPoint(IPAddress.Parse(ip), port);
            clientSocket = new ProxySocket(ipendPoint_0.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            clientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, new LingerOption(true, 0));
            IPAddress address;

            if (!string.IsNullOrWhiteSpace(localip) && IPAddress.TryParse(localip, out address))
            {
                IPEndPoint localEP = new IPEndPoint(address, 0);
                clientSocket.Bind(localEP);
            }
            if (!string.IsNullOrWhiteSpace(daili) && daili.Trim().Length > 0)
            {
                string[] array = daili.Split('|');
                if (pt == ProxyTypes.Https)
                {
                    array = daili.Split(':');
                }
                clientSocket.ProxyEndPoint = new IPEndPoint(IPAddress.Parse(array[0]), Convert.ToInt32(array[1]));
                if (array.Length > 2)
                {
                    clientSocket.ProxyUser = array[2];
                    clientSocket.ProxyPass = array[3];
                }
            }
            clientSocket.ProxyType = pt;
            list_0 = new List <byte>();
        }
示例#16
0
 /// <summary>
 /// 关闭连接
 /// </summary>
 public void Close()
 {
     if (socket != null && socket.Connected)
     {
         ((IDisposable)socket).Dispose();
         this.socket = null;
     }
 }
        /// <summary>
        /// Forcefully closes the socket.
        /// </summary>
        public void Close() {
            // get the socket.
            if (ProxySocket != null) {
                ProxySocket.Close();

                Dispose(true);
            }
        }
示例#18
0
        private static void ConfigureSocksProxy(ProxySocket proxySocket, IPEndPoint requestedEndPoint)
        {
            // TODO: Make this configurable
            proxySocket.ProxyType = ProxyTypes.Socks5Udp;
            var address = IPAddress.Parse(Settings.Default.ProxyAddress);

            proxySocket.ProxyEndPoint = new IPEndPoint(address, Settings.Default.ProxyPort);
        }
示例#19
0
 public void Connect(string host, int port)
 {
     _receivedLength         = 0;
     _encryption.Initialized = false;
     _socket = _socketFactory.CreateSocket();
     Log.Info($"Connecting to {host}:{port}");
     _socket.BeginConnect(host, port, ConnectCallback, null);
 }
示例#20
0
 public BotForm(Form1 _Form, NewProxy _Proxy, uint _ClientSerial, ProxySocket _Socket)
 {
     InitializeComponent();
     this.BaseForm     = _Form;
     this.Proxy        = _Proxy;
     this.Socket       = _Socket;
     this.ClientSerial = _ClientSerial;
 }
示例#21
0
 protected virtual void BeginDataReceive(ProxySocket socket)
 {
     if (this.socket == null || !this.socket.Connected)
     {
         return;
     }
     receiveBuf.Initialize();
     socket.BeginReceive(receiveBuf, 0, receiveBuf.Length, SocketFlags.None, new AsyncCallback(EndDataReceive), socket);
 }
示例#22
0
 protected virtual void BeginDataReceive(ProxySocket socket)
 {
     if (this.socket == null || !this.socket.Connected)
     {
         return;
     }
     receiveBuf = new ByteBuffer();
     socket.BeginReceive(receiveBuf.ByteArray, 0, receiveBuf.ByteArray.Length, SocketFlags.None, new AsyncCallback(EndDataReceive), socket);
 }
 /// <summary>
 /// Sends a buffer.
 /// </summary>
 public bool SendAsync(IMessageSocketAsyncEventArgs args) {
     if (!(args is ProxyMessageSocketAsyncEventArgs eventArgs)) {
         throw new ArgumentNullException(nameof(args));
     }
     if (ProxySocket == null) {
         throw new InvalidOperationException("The socket is not connected.");
     }
     eventArgs._args.SocketError = SocketError.Unknown;
     return ProxySocket.SendAsync(eventArgs._args);
 }
示例#24
0
 protected override Org.Mentalis.Network.ProxySocket.ProxySocket GetSocket()
 {
     if (socket == null)
     {
         socket           = new ProxySocket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
         socket.ProxyType = ProxyTypes.None;
         //socket.SetSocketOption(SocketOptionLevel.Udp, SocketOptionName.SendTimeout, 3000);
     }
     return(socket);
 }
示例#25
0
        public override void Callback(IAsyncResult result)
        {
            if (_proxy.IsRunning)
            {
                _proxy.Socket = (ProxySocket)result.AsyncState;

                Socket _client_socket = _proxy.Socket.EndAccept(result);

                ClientEntity client = _client_creator.Handle(_client_socket.RemoteEndPoint as IPEndPoint);
                client = _client_linker.Handle(client, _client_socket);

                ClientEntity remote = _client_creator.Handle(_proxy.IpRedirectedStack.Dequeue());
                ProxySocket  Socket = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                Socket.ProxyEndPoint = new IPEndPoint(IPAddress.Parse("109.248.110.177"), 24532);
                Socket.ProxyUser     = "******";
                Socket.ProxyPass     = "******";
                Socket.ProxyType     = ProxyTypes.Socks5;
                remote = _client_linker.Handle(remote, new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp));
                DofusRetroProxyClientReceiveCallback remote_rcv_callback = new DofusRetroProxyClientReceiveCallback(remote, client, _client_repository, _client_creator, _client_linker, _client_connector, _client_disconnector, _client_sender, _proxy, Account, ProxyTagEnum.Server);
                remote = _client_connector.Handle(remote, new ClientConnectCallback(remote, remote_rcv_callback));

                //ProxyManager.Instance.Clients[_proxy.Port].Client = _client_sender;
                //ProxyManager.Instance.Clients[_proxy.Port].Proxy = _proxy;
                //ProxyManager.Instance.Clients[_proxy.Port].ClientDofus = client;
                //ProxyManager.Instance.Clients[_proxy.Port].Remote = remote;

                //Client = _client_sender;
                //ClientDofus = client;
                //RemoteServer = remote;
                Account.SetSender(_client_sender, remote, client);

                // wait remote client to connect
                try
                {
                    while (!remote.IsRunning)
                    {
                        ;
                    }
                }
                catch (Exception e)
                {
                    logger.Error(e);
                    return;
                }

                if (client.IsRunning)
                {
                    client = _client_receiver.Handle(client, new DofusRetroProxyClientReceiveCallback(client, remote, _client_repository, _client_creator, _client_linker, _client_connector, _client_disconnector, _client_sender, _proxy, Account, ProxyTagEnum.Client));

                    logger.Info("client connected");
                }

                _proxy.Socket.BeginAccept(Callback, _proxy.Socket);
            }
        }
示例#26
0
        void btnTestProxy_Click(object sender, System.EventArgs e)
        {
            if (txtProxyIpAddress.Text.Trim() == "")
            {
                MsgBox.Warning("Sorry,the IP address can't be empty");
                return;
            }
            if (this.txtProxyUserName.Text.Trim() == "")
            {
                MsgBox.Warning("Sorry,the user name can't be empty");
                return;
            }
            if (this.txtProxyPortNumber.Text.Trim() == "")
            {
                MsgBox.Warning("Sorry,the port number can't be empty");
                return;
            }

            using (var cursor = new WaitCursor())
            {
                using (ProxySocket socket = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
                {
                    IPEndPoint          endPoint      = new IPEndPoint(IPAddress.Parse(txtIpAddress.Text), Convert.ToInt32(txtPortNumber.Text));
                    IPEndPoint          proxyEndPoint = new IPEndPoint(IPAddress.Parse(this.txtProxyIpAddress.Text), Convert.ToInt32(this.txtProxyPortNumber.Text));
                    ProxyTypes          proxyType     = (ProxyTypes)Enum.Parse(typeof(ProxyTypes), ddlProxyType.SelectedItem.ToString());
                    TcpConnectionParams Params        = new TcpConnectionParams(endPoint, proxyEndPoint, proxyType, txtProxyUserName.Text, txtProxyPassword.Text);
                    socket.ProxyEndPoint = Params.ProxyEndPoint;
                    socket.ProxyType     = Params.ProxyType;
                    socket.ProxyUser     = Params.ProxyUser;
                    socket.ProxyPass     = Params.ProxyPassword;

                    try
                    {
                        socket.Connect(Params.EndPoint);
                        MsgBox.Warning("Test successful");
                    }
                    catch
                    {
                        MsgBox.Warning("Sorry,test failed,please try again");
                    }
                    finally
                    {
                        try
                        {
                            socket.Shutdown(SocketShutdown.Both);
                            socket.Close();
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
示例#27
0
文件: Form1.cs 项目: alien88/wrenbot
 public ListViewItem GetItemFromSocket(ProxySocket Socket)
 {
     foreach (ListViewItem s in listView1.Items)
     {
         if (Socket.Name.ToLower() == s.SubItems[0].Text.ToLower())
         {
             return(s);
         }
     }
     return(null);
 }
示例#28
0
        public ItemProcesser(ProxySocket socket)
        {
            _socket = socket;

            _dicReplaceItem.Add(34281, 34285);
            _dicReplaceItem.Add(34330, 34285);
            _dicReplaceItem.Add(34339, 34285);
            _dicReplaceItem.Add(34282, 34286);
            _dicReplaceItem.Add(34331, 34286);
            _dicReplaceItem.Add(34340, 34286);
        }
示例#29
0
 protected override ProxySocket GetSocket()
 {
     //if (socket == null)
     {
         socket               = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         socket.ProxyType     = (ProxyTypes)(int)proxy.ProxyType;
         socket.ProxyEndPoint = QQPort.GetEndPoint(this.proxy.ProxyHost, this.proxy.ProxyPort);
         //socket.SetSocketOption(SocketOptionLevel.Udp, SocketOptionName.SendTimeout, 3000);
     }
     return(socket);
 }
示例#30
0
        public void SetProxySocket(ProxySocket proxySocket)
        {
            _socket = proxySocket;

            bagItemBox1.SetProxy(_socket);

            _socket.PlayerInfo.AutoSellItemUpdated += PlayerInfo_AutoSellItemUpdated;
            _socket.PlayerInfo.AutoDropItemUpdated += PlayerInfo_AutoDropItemUpdated;
            _socket.PlayerInfo.InfoUpdated         += PlayerInfoInfoUpdated;

            _socket.PlayerInfo.EnergyUpdated   += PlayerInfo_EnergyUpdated;
            _socket.PlayerInfo.TreasureUpdated += PlayerInfo_TreasureUpdated;
        }