Giter VIP home page Giter VIP logo

lua-resty-socks5's Introduction

lua-resty-socks5

Lua SOCKS5 client for the ngx_lua based on the cosocket API

Related project: onion2web.

Paper (in Russian).

Installation

$ sudo luarocks install socks5

Reference

This module contains the following functions:

  • socks5.auth(cosocket) - authenticate to SOCKS5 server (method "no authentication" is used). Cosocket must be connected to SOCKS5 server

  • socks5.connect(cosocket, host, port) - tell SOCKS5 server to connect to target host:port. Host must be domain name

  • socks5.handle_request(socks5host, socks5port, request_changer?, response_changer?, change_only_html?) - creates cosocket, authenticates to SOCKS5 server (defined by socks5host, socks5port), connects to target host:port (defined in ngx.req), receive request headers and body, send them through SOCKS5 server to target, then receive response headers and body, send them to client.

    Optional function request_changer is applied to request before sending it to target. Optional function response_changer is applied to response before sending it to client.

    The proxy can operate in two modes:

    • whole-page: read whole HTTP response and then send it to the client;
    • streaming: read response in small chunks.

    If response_changer is not used, streaming mode is used. If response_changer is used and change_only_html is truthy, then whole-page is used for HTML pages and streaming is used otherwise.

How to use this module to proxy all requests through Tor:

server {
    listen 80;
    server_name ip4.me; # must be in request header
    location / {
        default_type text/html;
        content_by_lua '
        require("socks5").handle_request("127.0.0.1", 9050)
        ';
    }
}

lua-resty-socks5's People

Contributors

starius avatar

Watchers

 avatar  avatar

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.