private void SendStreamHostsResult(object sender, IQ iq, object data) { // <iq xmlns="jabber:client" type="result" to="[email protected]/Psi" id="aab6a"> // <query xmlns="http://jabber.org/protocol/bytestreams"> // <streamhost-used jid="[email protected]/Psi" /> // </query> // </iq> if (iq.Type == IqType.result) { ByteStream bs = iq.Query as ByteStream; if (bs != null) { Jid sh = bs.StreamHostUsed.Jid; if (sh != null & sh.Equals(m_XmppCon.MyJID, new agsXMPP.Collections.FullJidComparer())) { // direct connection SendFile(null); } //if (sh != null & sh.Equals(new Jid(PROXY), new agsXMPP.Collections.FullJidComparer())) if (sh != null) { m_Sid = iq.Query.Attributes["sid"].ToString(); _p2pSocks5Socket = new JEP65Socket(); _p2pSocks5Socket.Address = PROXY; _p2pSocks5Socket.Port = 7777; _p2pSocks5Socket.Target = m_To; _p2pSocks5Socket.Initiator = m_XmppCon.MyJID; _p2pSocks5Socket.SID = m_Sid; _p2pSocks5Socket.ConnectTimeout = 5000; _p2pSocks5Socket.SyncConnect(); if (_p2pSocks5Socket.Connected) { ActivateBytestream(new Jid("proxy." + PROXY)); } //_proxySocks5Socket = new JEP65Socket(); //_proxySocks5Socket.Address = PROXY; //_proxySocks5Socket.Port = 7777; //_proxySocks5Socket.Target = m_To; //_proxySocks5Socket.Initiator = m_XmppCon.MyJID; //_proxySocks5Socket.SID = m_Sid; //_proxySocks5Socket.ConnectTimeout = 5000; //_proxySocks5Socket.SyncConnect(); //if (_proxySocks5Socket.Connected) // ActivateBytestream(new Jid(PROXY)); } } } }
private void HandleStreamHost(ByteStream bs, IQ iq) //private void HandleStreamHost(object obj) { //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; } else { } } } } }
private void SendStreamHostsResult(object sender, IQ iq, object data) { if (iq.Type == IqType.result) { ByteStream bs = iq.Query as ByteStream; if (bs != null) { Jid sh = bs.StreamHostUsed.Jid; if (sh != null) { if (sh.Equals(Account.Instance.Self.FullJid, new FullJidComparer())) { // direct connection SendFile(null); } if (_streamHostProxy != null && sh.Equals(_streamHostProxy.Jid, new FullJidComparer())) { _p2pSocks5Socket = new JEP65Socket(); _p2pSocks5Socket.ConnectTimeout = ConnectionTimeout; _p2pSocks5Socket.Address = _streamHostProxy.Host; _p2pSocks5Socket.Port = _streamHostProxy.Port; _p2pSocks5Socket.Target = Contact.FullJid; _p2pSocks5Socket.Initiator = Account.Instance.Self.FullJid; _p2pSocks5Socket.SID = _sid; _p2pSocks5Socket.SyncConnect(); if (_p2pSocks5Socket.Connected) { ActivateBytestream(_streamHostProxy.Jid); } } } } } else { State = FileTransferState.Cancelled; } }
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; } } } } }
private void SendStreamHostsResult(object sender, IQ iq, object data) { // <iq xmlns="jabber:client" type="result" to="[email protected]/Psi" id="aab6a"> // <query xmlns="http://jabber.org/protocol/bytestreams"> // <streamhost-used jid="[email protected]/Psi" /> // </query> // </iq> if (iq.Type == IqType.result) { ByteStream bs = iq.Query as ByteStream; if (bs != null) { Jid sh = bs.StreamHostUsed.Jid; if (sh != null & sh.Equals(m_XmppCon.MyJID, new agsXMPP.Collections.FullJidComparer())) { // direct connection SendFile(null); } if (sh != null & sh.Equals(new Jid(PROXY), new agsXMPP.Collections.FullJidComparer())) { _p2pSocks5Socket = new JEP65Socket(); _p2pSocks5Socket.Address = PROXY; _p2pSocks5Socket.Port = 7777; _p2pSocks5Socket.Target = m_To; _p2pSocks5Socket.Initiator = m_XmppCon.MyJID; _p2pSocks5Socket.SID = m_Sid; _p2pSocks5Socket.ConnectTimeout = 5000; _p2pSocks5Socket.SyncConnect(); if (_p2pSocks5Socket.Connected) ActivateBytestream(new Jid(PROXY)); } } } }
//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; } } } } }