Monday, January 19, 2009

Using jgit with socks5 proxy on Ubuntu

I use jgit to store my git repositories on Amazon S3. On my laptop I also periodically connect to the internet through tetherbot, which uses a socks proxy (see earlier post for more details there). I finally figured out how to get jgit, and I suppose other java applications working with the proxy. Jgit is java based and you need to pass the right flags to java, as described at http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html. The flags are:-DsocksProxyHost=localhost -DsocksProxyPort=1080. I inserted the following code into the jgit program, before the exec .... $java_args part:
if (netstat -pl --numeric-ports 2>&1 | grep ':1080.*adb' > /dev/null); then
echo "Using Java socks5 proxy args"
java_args="$java_args -DsocksProxyHost=localhost -DsocksProxyPort=1080"
fi

I inserted the lines using emacs. For some reason, xemacs and nano garbled the file when I tried editing it with them.

3 comments:

  1. awesome, congrats on getting the flags to work!

    ReplyDelete
  2. can you write something more about how proxy works?

    ReplyDelete
  3. Hi donmaxoni,
    Are you referring to socks5 or the particular java flags?

    ReplyDelete