Beispiel #1
0
        void XmppCon_OnIq(object sender, agsXMPP.protocol.client.IQ iq)
        {
            //if (InvokeRequired)
            //{
            //    // Windows Forms are not Thread Safe, we need to invoke this :(
            //    // We're not in the UI thread, so we need to call BeginInvoke
            //    BeginInvoke(new StreamHandler(XmppCon_OnIq), new object[] { sender, e });
            //    return;
            //}

            // <iq xmlns="jabber:client" from="[email protected]/Psi" to="[email protected]/SharpIM" type="set" id="aac9a">
            //  <query xmlns="http://jabber.org/protocol/bytestreams" sid="s5b_8596bde0de321957" mode="tcp">
            //   <streamhost port="8010" jid="[email protected]/Psi" host="192.168.74.142" />
            //   <streamhost port="7777" jid="proxy.ag-software.de" host="82.165.34.23">
            //   <proxy xmlns="http://affinix.com/jabber/stream" /> </streamhost>
            //   <fast xmlns="http://affinix.com/jabber/stream" />
            //  </query>
            // </iq>


            if (iq.Query != null && iq.Query.GetType() == typeof(agsXMPP.protocol.extensions.bytestreams.ByteStream))
            {
                agsXMPP.protocol.extensions.bytestreams.ByteStream bs = iq.Query as agsXMPP.protocol.extensions.bytestreams.ByteStream;
                // check is this is for the correct file
                if (bs.Sid == m_Sid)
                {
                    Thread t = new Thread(
                        delegate() { HandleStreamHost(bs, iq); }
                        );
                    t.Name = "LoopStreamHosts";
                    t.Start();
                }
            }
        }
Beispiel #2
0
 private void XmppCon_OnIq(object sender, agsXMPP.protocol.client.IQ iq)
 {
     if (iq.Query != null && iq.Query.GetType() == typeof(agsXMPP.protocol.extensions.bytestreams.ByteStream))
     {
         agsXMPP.protocol.extensions.bytestreams.ByteStream bs = iq.Query as agsXMPP.protocol.extensions.bytestreams.ByteStream;
         // check is this is for the correct file
         if (bs.Sid == m_Sid)
         {
             Thread t = new Thread(
                 delegate() { HandleStreamHost(bs, iq); }
                 );
             t.Name = "LoopStreamHosts";
             t.Start();
         }
     }
 }
        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;
                        }
                    }
                }
            }
        }
Beispiel #4
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;
                        }
                    }
                }

            }
        }