Total Pageviews

Thursday 12 April 2018

利用wstan翻墙(要求:本地机器跟北京时间的误差不能超过10秒。否则翻墙会失败。时间误差很难做到,所以不建议使用此法翻墙)

在linux vps上。
wstan是基于python3的程序,所以需先安装python3环境:
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
tar zxvf Python-3.6.4.tgz
cd Python-3.6.4


./configure --prefix=/usr/local/python-3.6.4
make 
make install
echo 'export PATH=$PATH:/usr/local/python-3.6.4/bin' >> /etc/profile
. /etc/profile
(至此python3.6.4就搭建好了)
 
pip3 install wstan
 
root@ar:~# which wstan
/usr/local/python-3.6.4/bin/wstan
root@ar:~#
这样, wstan 就安装好了。
 
wstan --gen-key
(此命令会输出一个key值:一串字符
wstan ws://0.0.0.0:2356 上面输出的那串字符 -s 

不过此命令wstan ws://0.0.0.0:2356 上面输出的那串字符 -s是运行在前台的,容易退出,
我们可用利用systemd来使其运行在后台:
nano /etc/systemd/system/wstan.service
其内容为:
[Unit]
After=network.target

[Service]
ExecStart=/usr/local/python-3.6.4/bin/wstan ws://0.0.0.0:2356 1FkhWM4lHztCvpCBbzUkGQ== -s
Restart=always

[Install]
WantedBy=multi-user.target
 
然后运行:
systemctl start wstan
systemctl enable wstan
服务器端搭建完毕。
 
在客户机器mac上。
brew install python3
pip3 install wstan
 
wstan ws://my-vps-ip:2356 1FkhWM4lHztCvpCBbzUkGQ== -c -p 1234
会显示:
wstan client -- SOCKS5/HTTP(S) server listening on localhost:1234


然后设置本地机器的浏览器的socks5代理服务器为127.0.0.1:1234, 
浏览器即可翻墙。
(看到提示:HTTP(S) server listening on localhost:1234了吗? 
wstan其实也是
个http proxy server,不过设置浏览器的http proxy server为
127.0.0.1:1234,浏览器虽可翻墙,但维持不了多长时间,服务器端就会
退出,而导致翻墙失败,
所以不建议设置浏览器的http proxy server模式
如果翻墙失败,请重新运行上面的客户端命令。
注意:本地机器跟北京时间的误差不能超过10秒
 
 
项目地址:
https://github.com/krrr/wstan
https://github.com/krrr/wstan/issues/4

No comments:

Post a Comment