Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Page: previous  1  2  3  4  5  6  7  next
Avatar
Alan #16
Member since May 2006 · 9 posts
Group memberships: Members
Show profile · Link to this post
In reply to post ID 999
Also in my test, initiator and target connect Socks5 proxy server running on  82.165.34.23, port 7777
Avatar
mayprog #17
Member since Mar 2006 · 61 posts
Group memberships: Members
Show profile · Link to this post
In reply to post ID 999
Dear Alan, I am Mayprog... not Alex but i am trying to harnest the ByteStreams beast some days now, just like you.
I have the same problems with you.

I an sending a file to Spark but when i sent the activate to the proxy it receives not-allowed error.
According to Jep0065 this happens if one of the parties is not connected to the proxy.
I am shure Spark is connected so possibly its me, but I AM!

I would like to ask you, on the SOCKS5 implementation when you send the CONNECT commad on the adress field you put the plain SHA1 bytes or as the RFC says the first octet is the number of the Address octets?

As for you saying that you know the Proxys streamhost, i think it would be better to get it when your app starts and use it since then, as you might sime time wanted to change your settings on the file transfer on the server.
Are you sure about port number,jid and ip of the proxy server and if he is active???

Also i have noticed a big complication in the Jep0065, it says that the Target should send the StreamHost he used not after he is connected to the proxy server but after he authenticates to it. Possibly the Target will not get the OK '00' REPLY from socks proxy for the CONNECT command before the Initiator Activates the bytestream to the proxy.
Is that right?

God(Alex) helps us ...
Avatar
Alan #18
Member since May 2006 · 9 posts
Group memberships: Members
Show profile · Link to this post
Hi Mayprog, in my code, the SOCKS5 connect command I send looks like

buf[0] = 0x05;
buf[1] = 0x01;
buf[2] = 0x00;
buf[3] = 0x03;  

buf[4] = (byte) 20; // the length of the address

byte[5] to byte[24] contains the SHA1 hash value of sID + initiator Jid + target Jid
                 
buf[25] = 0x0;
buf[26] = 0x0;

we need the length of the address in byte 4 otherwise the proxy server wont be able to parse the data correctly.

Also my understanding is the full handshake process to find out the socks5 proxy host and port specified in the JEP0065 is necassary if you want your IM client being able to communicate with other IM client for file transfer. But if you only plan to transfer file between your own IM clients, we can assume the proxy host is known hence same some handshake procedure. (Hence my handshake starts with example 11 in the JEP0065). Maybe I am wrong here since I didnt get it working :-(

For the proxy host and port I used, I used the IQs to query, and that is the value shown on the response saying this is the proxy and port. So I assume they are working there.

Let's pray God (Alex) helps us out, my 3 days long weekend was all spent on this I am really keen to see it working
Avatar
mayprog #19
Member since Mar 2006 · 61 posts
Group memberships: Members
Show profile · Link to this post
You are lucky Alan, i have spent almost a week now and still it doesn't work!
From the code you send me i understand that you also set the number of adress octets, well i suppose that is right.
What about the REPLY, if you look into jep0065 you'll see the following:

Example 18. Proxy Informs Initiator of Activation

<iq type='result'
    from='proxy.host3'
    to='initiator@host1/foo'
    id='activate'/>
   
The Proxy MUST then send SOCKS5 acknowledgement of the connection to the Target.

Example 19. StreamHost Acknowledges Connection to Target

STATUS = X'00'


So, I suppose,according to Jep0065 the SOCKS5server wont sent the OK '00' REPLY to the CONNECT comamand to the Target untill the Initiator activates the stream,is that right?
So, being the Target, if i wait for a CONNECT reply from SOCKS5 server, in order to Send to the Initiator the StreamHost used, there will be a problem, beacuse i want ever get the CONNECT command, and i want ever sent the StreamHost used and the Initiaror want ever Activate the stream.
So, i have to send the StreamHost used before i sent the CONNECT command to the Proxy?

How do you handle this?
Avatar
Alex #20
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello mayprog, Alan, and all the others with SOCKS5 filetransfer problems

I am traveling currently and should be back at the office on thursday or friday. Because there are so many people who have problems with file transfers i will extend the MiniClient with basic file transfer stuff. So if you can wait some days i should have some sample code.

Alex
Avatar
mayprog #21
Member since Mar 2006 · 61 posts
Group memberships: Members
Show profile · Link to this post
OK Alex,
that would be great!

Keep on the good work.
Avatar
Alan #22
Member since May 2006 · 9 posts
Group memberships: Members
Show profile · Link to this post
Thanks Alex.

Mayprog: I just got the activation of the bytestream working. The JEP0065 spec isnt very clear on the Example 14. Target Connects to StreamHost

CMD = X'01'
ATYP = X'03'
DST.ADDR = SHA1 Hash of: (SID + Initiator JID + Target JID)
DST.PORT = 0

in which it doesnt specify that the SHA1 hash result need to be converted from binary to hex string before it is sent to the SOCKS5 proxy server.
That is the SHA1 returns 20 bytes binary, and we need to send 41 bytes for the DST.ADDR.
In my program, the connect command looks like

         command = new byte[47];
         buf[0] = 0x05;
         buf[1] = 0x01;
         buf[2] = 0x00;
         buf[3] = 0x03;  
         buf[4] = 40;
        
         // byte[5] to byte[44] is the ASCII hex representation of the SHA1 result            
                          
         buf[45] = 0;
         buf[46] = 0;

I've got a activation response from the proxy by sending this command from the initiator and target. Hope that works for you :-)
Avatar
Alex #23
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
yes, you will find the functions for this kind of hashing in the Namespace agsXMPP.util in Hash.cs.

Alex
Avatar
mayprog #24
Member since Mar 2006 · 61 posts
Group memberships: Members
Show profile · Link to this post
Alan you are great!

Thanks very much!
Avatar
Alan #25
Member since May 2006 · 9 posts
Group memberships: Members
Show profile · Link to this post
I just got a problem when I actual do the file transfer over the socket through the proxy.

But i am not sure how the proxy server and target would know the initiator finishes the transmission?

With the code I got so far, the initiator closes the socket when it finishes sending. But the data was not transmitted to the receiver by the proxy after the close of the send socket. Instead, if the initiator tries to send a second file (by opening another file transfer session), the target receives the first file!

:-( Seems I got a serious misunderstanding on how the windows socket works.
Avatar
mayprog #26
Member since Mar 2006 · 61 posts
Group memberships: Members
Show profile · Link to this post
Is it possibly you close the socket (Shutdown it) synchronously althought you send the data asynchronously (by Begin Send and End Send)?
If you do that, possibly the socket will close even if EndSend has not come yet for the last transmition....

Also a question, how do you build the string address you send to the server, like this?:
StringBuilder b = new StringBuilder();
foreach(byte b in hashed from SHA1 bytes array)
{
    b.Append(b);
}
string sRet = b.ToString();
return System.Encoding.UTF8.GetBytes(sRet);
??
I am curious because as you managed to do it work, i don't want to get into another trouble now!!!!

Thanks!
This post was edited on 2006-06-14, 17:47 by mayprog.
Avatar
mayprog #27
Member since Mar 2006 · 61 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #25
Well, I used the previous formula and the result array had 53 usign ASCII.GetBytes() and 51 using UTF8.GetBytes() bytes.
It din't work!!!

Do you see Alan somtehing wrong in my code?

Thanks!
Avatar
mayprog #28
Member since Mar 2006 · 61 posts
Group memberships: Members
Show profile · Link to this post
Now i understand that i din't convert it to hex string but to string representation!
Well, i will try again!

Thanks anyway!
Avatar
mayprog #29
Member since Mar 2006 · 61 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #25
Alan, it worked!!!!

After 1 week i am getting files from Spark!!!
This is great, really thanks!

I used the following code:
            string sToHash = sId+sInitiatorJid+sTargetJid;

            SHA1 sha = SHA1.Create();
            byte[] hashedBytes = sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes(sToHash));

            StringBuilder bd = new StringBuilder();
            foreach(byte b in hashedBytes)
            {
                bd.AppendFormat("{0:x}",b);
            }

            string sRet = bd.ToString();
            byte []  ret = System.Text.Encoding.UTF8.GetBytes( sRet );
            return ret;

Of course i should thank Alex too, for helping as so much!
Avatar
mayprog #30
Member since Mar 2006 · 61 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #25
Alan, i have a similar problem with you....
Althought the transmition of the data is doing well, the data is not sended all to the Target alhtought i am sure that the Initirator send them.

Can you help?
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Page: previous  1  2  3  4  5  6  7  next
Forum: agsXMPP RSS