PATCH: File transfers via ejabberd SOCKS5

File transfers are not working when using old versions of ejabberd. Prior to rev 1488, ejabberd sent out incorrect SOCKS5 connection replies (to work around bugs in old versions of Psi).

See https://forge.process-one.net/browse/ejabberd/trunk/src/mod_proxy65/mod_proxy65_ lib.erl?r1=1153&r2=1488.

This patch adds a workaround for this incorrect behaviour.

Index: source/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java

— source/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java (revision 10957)
+++ source/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java (working copy)
@@ -501,12 +501,21 @@
byte[] cmd = new byte[5];
in.read(cmd, 0, 5);

  •    byte[] addr = new byte[cmd[4]];
    
  •    in.read(addr, 0, addr.length);
    
  •    String digest = new String(addr);
    
  •    in.read();
    
  •    in.read();
    
  •   String digest = null;
    
  •   if (cmd[3] == 0) {
    
  •       // ejabberd < rev 1488 sends broken replies in order to make
    
  •       // old Psi clients happy.
    
  •       in.read();
    
  •   }
    
  •   else {
    
  •       byte[] addr = new byte[cmd[4]];
    
  •       in.read(addr, 0, addr.length);
    
  •       digest = new String(addr);
    
  •       in.read();
    
  •       in.read();
    
  •   }
    
  •    return digest;
    

    }

This patch was commited (with minor modifications) into the community patch repo at

http://repo.or.cz/w/Smack.git?h=refs/heads/smack-3.1.1

as commit

http://repo.or.cz/w/Smack.git?a=commit;h=236ecd762c1e1eefa5d13ae76b4ab9a06e1c595 4

Cheers,

Christopher