GithubHelp home page GithubHelp logo

surik / tunnerl Goto Github PK

View Code? Open in Web Editor NEW
27.0 4.0 2.0 49 KB

SOCKS4, SOCKS4a and SOCKS5 protocols implementation in Erlang/OTP.

License: MIT License

Erlang 100.00%
erlang-socks-server erlang socks4 socks5 sosck4a proxy

tunnerl's Introduction

Tunnerl - SOCKS Proxy Implementation in Erlang/OTP

Build Status

Tunnerl is a versatile SOCKS4, SOCKS4a, and SOCKS5 proxy protocol implementation in Erlang/OTP. It enables you to create a powerful and flexible proxy server to facilitate secure and efficient communication across various network environments.

Features

tunnerl offers a range of features for proxying TCP connections, making it a valuable tool for network communication. These features include:

  • SOCKS Protocol Support:
    • SOCKS4: A protocol for TCP proxy across firewalls (socks4.protocol).
      • Supports the connect command only.
    • SOCKS 4A: A Simple Extension to SOCKS 4 Protocol (socks4a.protocol).
    • SOCKS Protocol Version 5 (RFC1928):
      • Supports the connect command only.
      • Username/Password Authentication for SOCKS V5 (RFC1929).
      • ATYPs: IPv4, IPv6, and domain.

Getting Started

Follow these steps to integrate Tunnerl into your Erlang or Elixir application:

  1. Add tunnerl to your list of dependencies in rebar.config:
{deps, [
    {tunnerl, "1.0.0"}
]}.
  1. Ensure tunnerl is started before your application:
{applications, [tunnerl]}.
  1. Configure tunnerl to use custom handler::
{tunnerl, [
    {protocols, [socks4, socks5]},
    {handler, myapp_handler},
    {acceptors, 10},
    {ip, {0, 0, 0, 0}},
    {port, 1080}
]}.
  1. Implement your own myapp_handler module. This module defines how tunnerl handles authentication and connection requests based on your application's requirements.
-module(myapp_handler).

%% This simple handler module accepts username authentication and
%% allows user with password "pass" do connect command.
%% Also, is accepts all connections on Socks4 for "root".

-export([auth_methods/0,
         auth/1,
         handle_command/1]).

auth_methods() -> [username].

auth(#{username := <<"user">>,
       password := <<"pass">>}) ->
    accept;
auth(_) -> reject.

handle_command(#{protocol := socks4,
                 command := connect,
                 username := <<"root">>}) ->
    accept;
handle_command(#{protocol := socks5,
                 command := connect,
                 username := <<"user">>}) ->
    accept;
handle_command(_) ->
    reject.

Testing

To test tunnerl, follow these steps:

  1. Clone the tunnerl repository and compile the code:
$ git clone https://github.com/surik/tunnerl.git
$ cd tunnerl
$ rebar3 compile
  1. Run Tunnerl with a predefined configuration that includes SOCKS4 and SOCKS5 support with no authentication:
$ rebar3 shell --name [email protected] --config tunnerl.config --apps tunnerl
  1. You can run a series of common tests to ensure everything is working as expected:
$ rebar3 ct

Note: IPv6 tests may not work on all local machines.

tunnerl's People

Contributors

surik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tunnerl's Issues

Undefined outgoing socket

2016-05-08 04:55:14.103 [error] emulator Error in process <0.1240.0> on node tunnex@sun with exit value:
{function_clause,[{prim_inet,setopts,[undefined,[{active,once}]],[]},{socks_protocol,loop,1,[{file,"src/socks_protocol.erl"},{line,44}]}]}

lists:filtermap нет в Erlang R16

Можно заменить на lists:filter или генератор списков.

Также не помешало бы прикрутить xref, чтобы проверять такие вещи.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.