Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/starius/lua-resty-socks5
Lua SOCKS5 client for the ngx_lua based on the cosocket API
https://github.com/starius/lua-resty-socks5
Last synced: 19 days ago
JSON representation
Lua SOCKS5 client for the ngx_lua based on the cosocket API
- Host: GitHub
- URL: https://github.com/starius/lua-resty-socks5
- Owner: starius
- License: mit
- Created: 2014-11-11T21:53:55.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-03T23:13:11.000Z (over 8 years ago)
- Last Synced: 2024-02-14T17:33:15.536Z (9 months ago)
- Language: Lua
- Size: 32.2 KB
- Stars: 33
- Watchers: 6
- Forks: 13
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-resty - lua-resty-socks5
README
lua-resty-socks5
================Lua SOCKS5 client for the `ngx_lua` based on the cosocket API
Related project:
[onion2web](https://github.com/starius/onion2web).[Paper](http://habrahabr.ru/post/243055/) (in Russian).
Installation
------------```bash
$ 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:
```nginx
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)
';
}
}
```