tlaloc

所属分类:聚类算法
开发工具:JavaScript
文件大小:20KB
下载次数:0
上传日期:2016-11-23 07:57:59
上 传 者sh-1993
说明:  用Node.js编写的去中心化Tor Socks5代理集群服务器。
(Decentralized Tor Socks5 proxy cluster server written in Node.js.)

文件列表:
.babelrc (74, 2016-11-15)
.eslintignore (23, 2016-11-15)
.eslintrc (525, 2016-11-15)
.npmignore (8, 2016-11-15)
.travis.yml (156, 2016-11-15)
LICENSE (1082, 2016-11-15)
bin (0, 2016-11-15)
bin\tlaloc (3368, 2016-11-15)
index.js (317, 2016-11-15)
package.json (1400, 2016-11-15)
src (0, 2016-11-15)
src\client (0, 2016-11-15)
src\client\index.js (4183, 2016-11-15)
src\client\proxy-link.js (2498, 2016-11-15)
src\cluster (0, 2016-11-15)
src\cluster\index.js (3436, 2016-11-15)
src\cluster\proxy-supply.js (3139, 2016-11-15)
src\cluster\ths-instance.js (1484, 2016-11-15)
src\constants.js (697, 2016-11-15)
src\pubsub.js (3188, 2016-11-15)
test (0, 2016-11-15)
test\client.js (5314, 2016-11-15)
test\cluster.js (3380, 2016-11-15)
test\env.js (58, 2016-11-15)
test\mocha.opts (43, 2016-11-15)
test\proxy-supply.js (3496, 2016-11-15)
test\pubsub.js (1118, 2016-11-15)
test\util (0, 2016-11-15)
test\util\get-own-ip.js (399, 2016-11-15)
test\util\get-proxy-ip.js (523, 2016-11-15)
test\util\ip-regex.js (146, 2016-11-15)

# Tlaloc [![Build Status](https://travis-ci.org/d-oliveros/tlaloc.svg?branch=master)](https://travis-ci.org/d-oliveros/tlaloc) [![Dependencies Status](https://david-dm.org/d-oliveros/tlaloc.svg)](https://david-dm.org/d-oliveros/tlaloc) Tlaloc is a Node.js program that lets you create multiple tor processes across servers, and manage them at scale using a central Redis pub/sub interface. It exposes a redis pub/sub communication channel for exposing available tor hidden service running in the cluster. It also lets you lock into a particular proxy, ensuring you are the only owner of that IP. ## Requirements A Tor client. Tor is available for a multitude of systems. On OSX you can install with homebrew ``` brew install tor tor # This should start the tor process ``` On Windows download the tor expert bundle (not the browser), unzip it and run tor.exe. ``` ./Tor/tor.exe # This should start the tor process ``` See [TorProject.org](https://www.torproject.org/download/download.html.en) for linux bundles and detailed installation guides for all platforms. Make sure not to install the browser, but the tor standalone command. ## Setup Install Tor. Make sure "Tor" is in your `$PATH`, try running "tor" in the terminal to confirm it. Then install Tlaloc ``` npm install -g tlaloc ``` ## Usage #### Cluster server ``` $ tlaloc --help Usage: tlaloc [options] Options: -h, --help output usage information -V, --version output the version number -i, --instances number of tor processes to run. Default: 4 -d, --data-dir data dir to use for the tor processes. Default: "currentDir + /tordata" -hn, --host IP address or hostname of this server. Default: "127.0.0.1" -p, --port starting port to start binding tor on. Default: 10770 -rp, --redis-port redis port. Default: 6379 -rh, --redis-host redis host. Default: "127.0.0.1" Examples: Start Tlaloc using a specified data dir: $ tlaloc --data-dir ~/tordata Use a redis pub/sub located in a remote host: $ tlaloc -rp 6779 -rh myredis.somedomain.com Starts with 30 Tor processes, providing 30 different random IPs: $ tlaloc -i 30 Starts with 30 Tor processes, exposes this server hostname to clients $ tlaloc -i 30 --host cluster1.mydomain.com ``` The default options are: ``` { dataDir: '/var/tmp' or '/tmp' or `${process.cwd()}/data`, torInstances: 4, host: '127.0.0.1', port: 10700 redis: { port: 6379, host: '127.0.0.1' } } ``` You can also configure tlaloc with environmental variables: ``` TLALOC_TOR_INSTANCES="20" # Sets the number of tor processes TLALOC_DATADIR="/var/tmp" # Sets the data directory TLALOC_HOST="cluster1.mydomain.com" # Sets the cluster hostname TLALOC_PORT="10900" # Sets the starting port range TLALOC_REDIS_HOST="127.0.0.1" # Sets the redis host TLALOC_REDIS_PORT="6379" # Sets the redis host # Then, you can just run "tlaloc" and these options will be used # Scaling horizontally is better done through environmental variables ``` Tlaloc will start a cluster of tor processes, write a dedicated torrc files in the data directory, create a connection to the central redis pub/sub interface, and start listening for proxy requests. It will serve tor proxy endpoints on request via the redis publish/subscribe flow. You can use the client in 'tlaloc/client' to easily request a proxy from the tor pool in the redis pub/sub, as described below. #### Client library Install tlaloc locally in your project ```bash npm install --save tlaloc ``` Use it in your code ```js import Client from 'tlaloc/client'; const client = new Client(); // these are the defaults const redisConfig = { host: '127.0.0.1', port: 6379 } client.connect(redisConfig) .then(() => client.getProxy()) .then((proxy) => { console.log(proxy.host); // the host of the tor cluster console.log(proxy.port); // the port bound to the remote tor instance console.log(proxy.active); // The tor host is still alive // Now use this host and port to make requests through a socks5 proxy // eg. using the 'socks5-https-client' module const shttp = require('socks5-https-client'); shttp.get({ hostname: 'api.ipify.org', socksHost: proxy.host, socksPort: proxy.port, path: '/', rejectUnauthorized: false }, (res) => { res.setEncoding('utf8'); res.on('readable', () => { console.log(`My tor IP is ${res.read()}`); } }); }); ``` ## Scaling Tlaloc is designed to allow for easy horizontal scaling. There's no central server managing the clusters, so in order to increase the available tor proxies in the pool, you just need to start more Tlaloc clusters in different servers, and configure them to use the same redis pub/sub interface. You have to make sure to expose each server's IP addresses correctly through TLALOC_HOST (or the command-line option). Failing to do so will make the clusters expose themselves without their IP address, and clients won't be able to reach the proxies. ## Tests ``` mocha ``` Cheers.

近期下载者

相关文件


收藏者