Ejemplo n.º 1
0
        private void HandleStreamHost(ByteStream bs, IQ iq)
        {
            //IQ iq = obj as IQ;
            //ByteStream bs = iq.Query as agsXMPP.protocol.extensions.bytestreams.ByteStream;;
            //ByteStream bs = iq.Query as ByteStream;
            if (bs != null)
            {
                _proxySocks5Socket = new JEP65Socket(_fileLength);
                _proxySocks5Socket.ConnectTimeout = ConnectionTimeout;
                _proxySocks5Socket.OnConnect += m_s5Sock_OnConnect;
                _proxySocks5Socket.OnReceive += m_s5Sock_OnReceive;
                _proxySocks5Socket.OnDisconnect += m_s5Sock_OnDisconnect;

                StreamHost[] streamhosts = bs.GetStreamHosts();
                //Scroll through the possible sock5 servers and try to connect
                //foreach (StreamHost sh in streamhosts)
                //this is done back to front in order to make sure that the proxy JID is chosen first
                //this is necessary as at this stage the application only knows how to connect to a
                //socks 5 proxy.

                foreach (StreamHost sHost in streamhosts)
                {
                    if (sHost.Host != null)
                    {
                        _proxySocks5Socket.Address = sHost.Host;
                        _proxySocks5Socket.Port = sHost.Port;
                        _proxySocks5Socket.Target = Account.Instance.Self.FullJid;
                        _proxySocks5Socket.Initiator = Contact.FullJid;
                        _proxySocks5Socket.SID = _sid;
                        _proxySocks5Socket.ConnectTimeout = ConnectionTimeout;
                        _proxySocks5Socket.SyncConnect();

                        if (_proxySocks5Socket.Connected)
                        {
                            SendStreamHostUsedResponse(sHost, iq);
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //private void HandleStreamHost(object obj)
        private void HandleStreamHost(ByteStream bs, IQ iq)
        {
            //IQ iq = obj as IQ;
            //ByteStream bs = iq.Query as agsXMPP.protocol.extensions.bytestreams.ByteStream;;
            //ByteStream bs = iq.Query as ByteStream;
            if (bs != null)
            {
                _proxySocks5Socket = new JEP65Socket();
                _proxySocks5Socket.OnConnect += new ObjectHandler(m_s5Sock_OnConnect);
                _proxySocks5Socket.OnReceive += new agsXMPP.net.BaseSocket.OnSocketDataHandler(m_s5Sock_OnReceive);
                _proxySocks5Socket.OnDisconnect += new ObjectHandler(m_s5Sock_OnDisconnect);

                StreamHost[] streamhosts = bs.GetStreamHosts();
                //Scroll through the possible sock5 servers and try to connect
                //foreach (StreamHost sh in streamhosts)
                //this is done back to front in order to make sure that the proxy JID is chosen first
                //this is necessary as at this stage the application only knows how to connect to a
                //socks 5 proxy.

                foreach (StreamHost sHost in streamhosts)
                {
                    if (sHost.Host != null)
                    {
                        _proxySocks5Socket.Address = sHost.Host;
                        _proxySocks5Socket.Port = sHost.Port;
                        _proxySocks5Socket.Target = m_XmppCon.MyJID;
                        _proxySocks5Socket.Initiator = m_From;
                        _proxySocks5Socket.SID = m_Sid;
                        _proxySocks5Socket.ConnectTimeout = 5000;
                        _proxySocks5Socket.SyncConnect();
                        if (_proxySocks5Socket.Connected)
                        {
                            SendStreamHostUsedResponse(sHost, iq);
                            break;
                        }
                    }
                }

            }
        }