Refactor socks package. Add support for socks4/4a.

Related to #2567 
This change is backward incompatible.