Tue Dec 27, 2016

Uses of socks5map proxy tool

A colleague was coding a Chrome extension and was tired of constantly changing his hosts file to switch between production and localhost DNS resolution for a particular domain from which the extension loaded some assets.

That was the birth of socks5map, a quick SOCKS5 proxy that resolves requests to certain domains to specific addresses. Requests for domains not configured are resolved by system resolver.

If you use together socks5map and some proxy manager (ie. SwitchyOmega) then without leaving Chrome you can easily switch between development and production environments.

Uses of socks5map are not constrained to Chrome. You may use it also with any SOCKS5 client that allows server-side address resolution. For example with cURL you need to use flag --socks5-hostname.

For example, lets proxy domain overide-me.com to IP address 1.2.3.4:

# Start proxy listening on 127.0.0.1:9000 to route requests to \
# domain "overide-me.com" to IP "1.2.3.4" instead of DNS' address
socks5map -l 127.0.0.1:9000 -r overide-me.com:1.2.3.4

Then in another console you use cURL:

# This request will be routed to server at IP set \
# in socks5map (eg. 1.2.3.4)
curl --socks5-hostname 127.0.0.1:9000 \
    http://overide-me.com/resource/path