예제 #1
0
        private void SendStreamHosts()
        {
            ByteStreamIq bsIq = new ByteStreamIq();
            bsIq.To = Contact.FullJid;
            bsIq.Type = IqType.set;

            bsIq.Query.Sid = _sid;

            string hostname = Dns.GetHostName();

            IPHostEntry iphe = Dns.GetHostEntry(hostname);

            foreach (IPAddress address in iphe.AddressList)
            {
                if (address.AddressFamily == AddressFamily.InterNetwork)
                {
                    bsIq.Query.AddStreamHost(Account.Instance.Self.FullJid, address.ToString(), MyPort);
                }
            }

            if (_streamHostProxy != null)
            {
                bsIq.Query.AddStreamHost(_streamHostProxy);
            }

            _p2pSocks5Socket = new JEP65Socket();
            _p2pSocks5Socket.ConnectTimeout = ConnectionTimeout;
            _p2pSocks5Socket.Initiator = _xmppConnection.MyJID;
            _p2pSocks5Socket.Target = Contact.FullJid;
            _p2pSocks5Socket.SID = _sid;
            _p2pSocks5Socket.OnConnect += _socket_OnConnect;
            //_p2pSocks5Socket.OnDisconnect += _socket_OnDisconnect;
            _p2pSocks5Socket.Listen(MyPort);

            _xmppConnection.IqGrabber.SendIq(bsIq, new IqCB(SendStreamHostsResult), null);
        }
예제 #2
0
        private void SendStreamHostUsedResponse(StreamHost sh, IQ iq)
        {
            ByteStreamIq bsIQ = new ByteStreamIq(IqType.result, Contact.FullJid);
            bsIQ.Id = iq.Id;

            bsIQ.Query.StreamHostUsed = new StreamHostUsed(sh.Jid);
            _xmppConnection.Send(bsIQ);
        }
예제 #3
0
        private void DiscoProxy()
        {
            ByteStreamIq bsIq = new ByteStreamIq();
            bsIq.To = new Jid(_proxyUrl);
            bsIq.Type = IqType.get;

            _xmppConnection.IqGrabber.SendIq(bsIq, new IqCB(OnProxyDiscoResult), null);
        }
예제 #4
0
        private void ActivateBytestream(Jid streamHost)
        {
            ByteStreamIq bsIq = new ByteStreamIq();

            bsIq.To = streamHost;
            bsIq.Type = IqType.set;

            bsIq.Query.Sid = _sid;
            bsIq.Query.Activate = new Activate(Contact.FullJid);

            _xmppConnection.IqGrabber.SendIq(bsIq, new IqCB(ActivateBytestreamResult), null);
        }
예제 #5
0
        private void SendStreamHostUsedResponse(StreamHost sh, IQ iq)
        {
            ByteStreamIq bsIQ = new ByteStreamIq(IqType.result, m_From);
            bsIQ.Id = iq.Id;

            bsIQ.Query.StreamHostUsed = new StreamHostUsed(sh.Jid);
            m_XmppCon.Send(bsIQ);
        }
예제 #6
0
        private void SendStreamHosts()
        {
            /*
             Recv:
            <iq xmlns="jabber:client" from="[email protected]/Psi" to="[email protected]/SharpIM"
            type="set" id="aab6a"> <query xmlns="http://jabber.org/protocol/bytestreams" sid="s5b_405645b6f2b7c681"
            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>
            */

            ByteStreamIq bsIq = new ByteStreamIq();
            bsIq.To = m_To;
            bsIq.Type = IqType.set;

            bsIq.Query.Sid = m_Sid;

            string hostname = System.Net.Dns.GetHostName();

            System.Net.IPHostEntry iphe = System.Net.Dns.Resolve(hostname);

            for (int i = 0; i < iphe.AddressList.Length; i++)
            {
                Console.WriteLine("IP address: {0}", iphe.AddressList[i].ToString());
                //bsIq.Query.AddStreamHost(m_XmppCon.MyJID, iphe.AddressList[i].ToString(), 1000);
            }

            bsIq.Query.AddStreamHost(new Jid(PROXY), PROXY, 7777);

            _p2pSocks5Socket = new JEP65Socket();
            _p2pSocks5Socket.Initiator = m_XmppCon.MyJID;
            _p2pSocks5Socket.Target = m_To;
            _p2pSocks5Socket.SID = m_Sid;
            _p2pSocks5Socket.OnConnect += new ObjectHandler(_socket_OnConnect);
            _p2pSocks5Socket.OnDisconnect += new ObjectHandler(_socket_OnDisconnect);
            _p2pSocks5Socket.Listen(1000);

            m_XmppCon.IqGrabber.SendIq(bsIq, new IqCB(SendStreamHostsResult), null);
        }
예제 #7
0
        /*
            4.9 Activation of Bytestream

            In order for the bytestream to be used, it MUST first be activated by the StreamHost. If the StreamHost is the Initiator, this is straightforward and does not require any in-band protocol. However, if the StreamHost is a Proxy, the Initiator MUST send an in-band request to the StreamHost. This is done by sending an IQ-set to the Proxy, including an <activate/> element whose XML character data specifies the full JID of the Target.

            Example 17. Initiator Requests Activation of Bytestream

            <iq type='set'
                from='initiator@host1/foo'
                to='proxy.host3'
                id='activate'>
              <query xmlns='http://jabber.org/protocol/bytestreams' sid='mySID'>
                <activate>target@host2/bar</activate>
              </query>
            </iq>

            Using this information, with the SID and from address on the packet, the Proxy is able to activate the stream by hashing the SID + Initiator JID + Target JID. This provides a reasonable level of trust that the activation request came from the Initiator.

            If the Proxy can fulfill the request, it MUST then respond to the Initiator with an IQ-result.

            Example 18. Proxy Informs Initiator of Activation

            <iq type='result'
                from='proxy.host3'
                to='initiator@host1/foo'
                id='activate'/>

        */
        private void ActivateBytestream(Jid streamHost)
        {
            ByteStreamIq bsIq = new ByteStreamIq();

            bsIq.To     = streamHost;
            bsIq.Type   = IqType.set;

            bsIq.Query.Sid = m_Sid;
            bsIq.Query.Activate = new Activate(m_To);

            m_XmppCon.IqGrabber.SendIq(bsIq, new IqCB(ActivateBytestreamResult), null);
        }