tunnerl
SOCKS4, SOCKS4a and SOCKS5 protocols implementation in Erlang/OTP.
Features
SOCKS v4 and SOCKS v4A
- connect command only
SOCKS v5
- only username authorization
- connect command only
- IPv4 and IPv6
Using
-
Add
tunnerlto your list of dependencies in rebar.config:
{deps, [
{tunnerl, "0.4.0"}
]}.-
Ensure
tunnerlis started before your application:
{applications, [tunnerl]}.- Configure it to use custom authorization handler::
{tunnerl, [
{protocols, [socks4, socks5]},
{auth, [16#02]}, % shows that only username authorization can be accepted
{auth_module, myapp_auth_handler},
{acceptors, 10},
{ip, {0, 0, 0, 0},
{port, 1080}
]}.-
Implement
myapp_auth_handler:
-module(myapp_auth_handler).
%% This simple handler module allows `user` with password `pass`
%% be authorized for socks4 and `root` with any password for both protocols.
%% It rejects any other users.
-export([auth/4]).
auth(socks4, <<"user">>, <<"pass">>, _Options) -> ok.
auth(_Proto, <<"root">>, _Password, _Options) -> ok.
auth(_Proto, _User, _Password, _Options) -> false.Testing
Build:
$ git clone https://github.com/surik/tunnerl.git
$ cd tunnerl
$ rebar3 compileRun tunnerl with simple predefined configuration with socks4/socks5 and no authorization:
$ rebar3 shell --name socks@127.0.0.1 --config tunnerl.config --apps tunnerlThere is a bunch of common tests which can be running:
$ rebar3 ctNote that IPv6 tests might not been working on your local machine.