Total Pageviews

Thursday, 23 June 2016

利用shadowsocks-ruby的clowwindy版翻墙

以前曾写过此帖子http://briteming.blogspot.com/2015/11/shadowsocks-ruby_5.html (利用shadowsocks-ruby翻墙
项目:https://github.com/Sen/shadowsocks-ruby其实是fork自
https://github.com/clowwindy/shadowsocks-ruby,所以现在来说说如何用shadowsocks-ruby的clowwindy版翻墙。

登陆linux ups,首先编译ruby:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make
echo 'export PATH=$PATH:~/.rbenv/bin/' >> /etc/profile
. /etc/profile
git clone https://github.com/rbenv/ruby-build ~/.rbenv/plugins/ruby-build/
cd ~/.rbenv/plugins/ruby-build/
./install.sh
apt-get install -y libreadline-dev
rbenv install 2.2.0 (此步骤耗时约10分钟)
会显示:
...
Installed ruby-2.2.0 to /root/.rbenv/versions/2.2.0
root@AR:~/.rbenv/plugins/ruby-build# ruby -v
-bash: ruby: 未找到命令
root@AR:~/.rbenv/plugins/ruby-build# cd /root/.rbenv/versions/2.2.0
root@AR:~/.rbenv/versions/2.2.0# ls
bin  include  lib  share
root@AR:~/.rbenv/versions/2.2.0# ls bin
erb  gem  irb  rake  rdoc  ri  ruby
root@AR:~/.rbenv/versions/2.2.0# ~/.rbenv/versions/2.2.0/bin/ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [i686-linux]
root@AR:~/.rbenv/versions/2.2.0#
root@AR:~/.rbenv/versions/2.2.0/bin# echo 'export PATH=$PATH:~/.rbenv/versions/2.2.0/bin/' >> /etc/profile
root@AR:~/.rbenv/versions/2.2.0/bin# . /etc/profile
root@AR:~/.rbenv/versions/2.2.0/bin# cd ~
root@AR:~# ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [i686-linux]
root@AR:~#
这样ruby的2.2.0版就搭建好了。(参见http://briteming.blogspot.com/2016/05/rvmrbenvruby.html)
rbenv rehash
关于为什么要做rehash,解释如下:
新装的gem(以前重没装过)一定要rehash在.rbenv/shims下生成可执行程序,像zsh要自动补全还需要 hash -r .不过因为 rbenv init - 里会调用rbenv rehash,所有新开个窗口是不需要的.我的用法是bundler管理gemset,在~/.bundle/config里设置BUNDLE_PATH为vendor/bundle , 配合shell的一个小函数为常用命令添加alias,在发现Gemset的时候自动加上bundle exec ( rbenv.zsh ).通过bundler安装bundle exec执行是不需要rehash的。

git clone https://github.com/clowwindy/shadowsocks-ruby shadowsocks-ruby-by-clowwindy
cd shadowsocks-ruby-by-clowwindy

root@AR:~/shadowsocks-ruby-by-clowwindy# ls
config.json  encrypt.rb  local.rb  merge_sort.rb  server.rb  test.rb

root@AR:~/shadowsocks-ruby-by-clowwindy# nano config.json
root@AR:~/shadowsocks-ruby-by-clowwindy# cat config.json 
{
    "server":"0.0.0.0",
    "server_port":8688,
    "local_port":1080,
    "password":"your_password",
    "timeout":600
}
root@AR:~/shadowsocks-ruby-by-clowwindy# nohup ruby server.rb -c config.json > /dev/null &
这样服务器端就搭建好了。

在客户机器上。
在linux桌面系统上,如同linux vps上一样,搭建ruby的2.2.0版。(Mac上,运行brew install ruby来安装ruby)
然后,
git clone https://github.com/clowwindy/shadowsocks-ruby shadowsocks-ruby-by-clowwindy
cd shadowsocks-ruby-by-clowwindy
nano config.json
cat config.json
显示:
{
    "server":"your_vps_ip",
    "server_port":8688,
    "local_port":1080,
    "password":"your_password",
    "timeout":600

}
然后,
nohup ruby local.rb -c config.json > /dev/null &
这样客户端就搭建好了。

设置浏览器的socks5代理为127.0.0.1:1080,即可翻墙。

项目地址:https://github.com/clowwindy/shadowsocks-ruby
用此项目翻墙,速度不太快。速度不如此法http://briteming.blogspot.com/2015/11/shadowsocks-ruby_5.html快。

相关帖子:http://briteming.blogspot.com/2015/11/shadowsocks-ruby_5.html