Total Pageviews

Friday 17 November 2017

利用blinksocks翻墙

A framework for building composable proxy protocol stack.
version downloads license dependencies devDependencies
Travis Coverage %e2%9d%a4
A framework for building composable proxy protocol stack.

Features

  • Cross-platform: running on Linux, Windows and macOS.
  • Lightweight proxy interface for Socks5/Socks4/Socks4a and HTTP(S).
  • Transmit data over raw TCP/UDP, real TLS or real WebSocket.
  • A variety of customizable protocols and functional middlewares: using presets.
  • External preset import.
  • Easy and powerful Access Control(ACL) and Traffic Control(TC).
  • Executable versions available: download here.
  • Out of the box distribution and deployment.
  • Support shadowsocks protocols.
  • Support shadowsocksR protocols.
  • Support v2ray vmess protocol.
  • Experimentaldynamic protocol stack.

Getting Started

Requirements

blinksocks is built on top of Node.js, if you want to use it in an ordinary way or do some hacking, please install Node.js(v6.x and above) on your operating system.

Install or Upgrade

You can get the latest blinksocks via package manager yarn or npm.
NOTE: Node.js comes with npm installed so you don't have to install npm individually.
latest stable version
$ npm install -g blinksocks
development version
$ npm install -g git+https://github.com/blinksocks/blinksocks.git
$ npm install -g git+https://github.com/blinksocks/blinksocks.git#v2.5.5

Run blinksocks

npm version(require Node.js)
$ blinksocks -c blinksocks.client.json
executable version(Node.js, not GUI)
$ ./blinksocks --help    // Linux and macOS
$ blinksocks.exe --help  // Windows
You can download precompiled executables for different platforms and launch it directly without having Node.js installed.
For configuring blinksocks, please refer to Configuration.

GUI ready(out-of-date)

For desktop use, you can download official blinksocks-desktop, a cross-platform GUI for blinksocks.

Documents

For Users

  1. Usage
  2. Configuration
  3. Presets

For Developers

  1. Preparation
  2. Guideline
  3. Custom Preset
  4. Benchmark
from  https://github.com/blinksocks/blinksocks
---------

我的补充说明

首先登陆linux vps,安装nodejs环境:
wget  https://nodejs.org/dist/v9.8.0/node-v9.8.0-linux-x64.tar.xz
tar Jxvf node-v9.8.0-linux-x64.tar.xz
cd node-v9.8.0-linux-x64

root@ar:~/node-v9.8.0-linux-x64# ls
CHANGELOG.md  LICENSE  README.md  bin  etc  include  lib  share
root@ar:~/node-v9.8.0-linux-x64# cd bin
root@ar:~/node-v9.8.0-linux-x64/bin# ls

node  npm  npx
root@ar:~/node-v9.8.0-linux-x64/bin#  echo 'export PATH=$PATH:/root/

node-v9.8.0-linux-x64/bin' >> /etc/profile && source /etc/profile
root@ar:~/node-v9.8.0-linux-x64/bin# cd ~
root@ar:~# ln -s /root/node-v9.8.0-linux-x64/bin/node /usr/bin/node
(这样,安装nodejs环境完成)
root@ar:~# npm install -g blinksocks
(这样blinksocks就安装完成了)
root@ar:~# blinksocks init
(此命令会在当前目录下,生成一对配置文件:blinksocks.client.jsonblinksocks.server.json)
root@ar:~# blinksocks --config blinksocks.server.json
会显示:
info: [hub] blinksocks server is running at tcp://0.0.0.0:63511
info: [hub] blinksocks udp server is running at udp://0.0.0.0:63511


不过,blinksocks --config blinksocks.server.json是在前台运行的,我们可以利用systemd来把blinksocks --config blinksocks.server.json运行为service:
nano /etc/systemd/system/blinksocks.service
其内容为:
[Unit]
Description=blinksocks
After=network.target


[Service]
ExecStart=/root/node-v9.8.0-linux-x64/bin/blinksocks --config /root/blinksocks.server.json
Restart=always


[Install]
WantedBy=multi-user.target


启动blinksocks:
systemctl daemon-reload
systemctl start blinksocks
这其实就是以daemon(service)方式启动blinksocks程序。
systemctl enable blinksocks

可以验证一下blinksocks是否在运行中:
root@ar:# ps aux|grep blinksocks
root 9511 15.0 3.0 1018788 32304 ? Ssl 09:20 0:00 node /root/node-v9.8.0-linux-x64/bin/blinksocks --config /root/blinksocks.server.json
root 9522 0.0 0.0 11072 816 pts/4 S+ 09:20 0:00 grep blinksocks
root@ar:# 
说明blinksocks是在运行中。
 (因为blinksocks是基于nodejs构建的程序,所以我们也可使用pm2来使得此命令blinksocks --config blinksocks.server.json在后台运行
先运行npm install -g pm2来安装pm2。
然后, pm2 start blinksocks -- -c /root/blinksocks.server.json
测试一下blinksocks是否在后台运行
root@ar:~/node-v9.8.0-linux-x64# ps aux|grep blinksocks
root      9210  0.5  3.1 1021552 32520 ?       Ssl  06:17   0:00 node /root/node-v9.8.0-linux-x64/bin/blinksocks                                                                 
root      9237  0.0  0.0  11072   816 pts/7    S+   06:19   0:00 grep blinksocks
root@ar:~/node-v9.8.0-linux-x64# 

这表明blinksocks是在后台运行。)

在本地机器mac上,下载https://nodejs.org/dist/v9.8.0/node-v9.8.0.pkg
双击该pkg文件,即可安装node环境。
然后npm install -g blinksocks
然后blinksocks init
(此命令会在当前目录下,生成一对配置文件:blinksocks.client.jsonblinksocks.server.json)
nano blinksocks.client.json
(把第2行的service的值改为socks5://127.0.0.1:2080
把第4行的service的值改为tcp://your_vps_ip:server_port
把第5行的key的值改为服务器上的配置文件blinksocks.server.json的第3行的key的值。)
blinksocks --config blinksocks.client.json
保持终端不要关闭。然后设置本地机器的浏览器的socks5代理服务器为127.0.0.1:2080 ,浏览器即可翻墙。

项目地址:https://github.com/blinksocks/blinksocks
https://github.com/blinksocks/blinksocks/issues/102

如果使用systemd来把blinksocks --config blinksocks.server.json运行为service失败,我们可以利用https://briteming.blogspot.com/2016/08/daemonize-daemon.html里面所说的daemonize来把命令运行为daemon。

No comments:

Post a Comment