Total Pageviews

Tuesday, 21 August 2018

利用socks代理服务器程序socksv5-by-mscdex翻墙

登陆linux vps.
首先安装nodejs环境。然后,
npm install socksv5
会显示:
npm WARN enoent ENOENT: no such file or directory, open '/root/package.json'
npm WARN root No description
npm WARN root No repository field.
npm WARN root No README data
npm WARN root No license field.
这些显示的内容无关紧要。

新建文件server-with-no-auth-by-mscdex.js
内容为:
var socks = require('socksv5');

var srv = socks.createServer(function(info, accept, deny) {
  accept();
});
srv.listen(10200, '0.0.0.0', function() {
  console.log('SOCKS server listening on port 10200');
});

srv.useAuth(socks.auth.None());

然后运行,
node server-with-no-auth-by-mscdex.js
会显示:

SOCKS server listening on port 10200

不过命令node server-with-no-auth-by-mscdex.js是运行在前台的,容易退出,我们可利用systemd来把此命令运行为service:
nano /etc/systemd/system/socksv5-by-mscdex.service
内容为:
[Unit]
After=network.target

[Service]
WorkingDirectory=/root/
ExecStart=/usr/bin/node /root/server-with-no-auth-by-mscdex.js
Restart=always

[Install]
WantedBy=multi-user.target

然后运行,
systemctl start socksv5-by-mscdex
systemctl enable socksv5-by-mscdex
服务器端搭建完成。

在本地机器mac上。
在chrome+switchyomega里设置一个代理服务器情景模式。代理协议为socks5,代理服务器的值为vps的ip,代理端口为10200,保存选项,chrome即可翻墙,只是看youtube有点慢。

项目地址:https://github.com/mscdex/socksv5

No comments:

Post a Comment