How to route traffic through a specific SOCKS proxy on a per-app basis?

I'm running a certain desktop app (actually via AIR if it makes any difference) which doesn't have any built-in proxy configuration settings.

I need to get all traffic just from this app directed through a secure SOCKS proxy. This implies I can't use the global network preferences, as these would affect many other apps.

Is there any way to force all network communication through a given SOCKS proxy on a per-app basis?

It would also be helpful to know if there's a way to perform such routing globally, based on specific IP addresses (as this could allow for some reasonable workaround).


Solution 1:

ProxyCap enables you to redirect your computer's network connections through proxy servers. You can tell ProxyCap which applications will connect to the Internet through a proxy and under what circumstances. This is done through a user friendly interface, without the need to reconfigure any of your Internet clients.

Key features:

  • Support for SOCKS4, SOCKS5 and HTTPS proxy servers
  • Direct support for SSH tunneling (specify a SSH server as the proxy server)
  • Support for TCP- and UDP-based network protocols
  • Proxy-side DNS support
  • Flexible routing rules
  • Support for proxy chains
  • IPv6 support
  • Support for 64-bit applications
  • Centralized management support

Solution 2:

In the article Watch hulu.com outside the US on Mac OS X, the author tried tsocks/dsocks/dante from macports, but none of them worked well. As this article was written in 2009, it is quite possible that these applications have since improved and may now work for you.

What the author finally found was Proxifier for Mac OS X, a native cocoa application which lets you tunnel a whole application through various kinds of proxies.

Its Proxification Rules menu has a "Process Only the Following" option, where one can add a rule for the applications you want to tunnel through the proxy (by default it'll try to socksify everything).