shadowsocks in haskell.
Shadowsocks in Haskell. Original python version: https://github.com/clowwindy/shadowsocks
Compatible with other versions of shadowsocks.
from https://github.com/rnons/shadowsocks-haskell
--extra-include-dirs=/usr/local/opt/openssl/include --extra-lib-dirs=/usr/local/opt/openssl/lib
------
一个类似的基于haskell的项目-moesocks (感觉moesocks用起来,比shadowsocks-haskell
好用多了。)
Shadowsocks in Haskell. Original python version: https://github.com/clowwindy/shadowsocks
Compatible with other versions of shadowsocks.
cabal update
cabal install shadowsocks
最后显示:
...
Linking dist/build/sslocal/sslocal ...
...
Linking dist/build/ssserver/ssserver ...
...
Installing executable sslocal in /root/.cabal/bin
Warning: The directory /root/.cabal/bin is not in the system search path.
Installing executable ssserver in /root/.cabal/bin
Warning: The directory /root/.cabal/bin is not in the system search path.
root@cc:~# ls /root/.cabal/bin/ sslocal ssserver root@cc:~# echo 'export PATH=$PATH:/root/.cabal/bin' >> /etc/profile && . /etc/profile root@cc:~# which ssserver /root/.cabal/bin/ssserver root@cc:~# nano
shadowsocks-haskell-config.json
root@cc:~# cat
shadowsocks-haskell-config.json
{ "server":"0.0.0.0", "server_port":4567, "local_port":1080, "password":"my-password", "timeout":600, "method":"aes-256-cfb" }
root@cc:~# ssserver -c shadowsocks-haskell-config.json &
root@cc:~#
from https://github.com/rnons/shadowsocks-haskell
至于客户端,是兼容‘纸飞机’程序的,把你服务器的ip,端口4567,你的密码,加密方式aes-256-cfb共4个参数值填入‘纸飞机’程序。
试用后,发现用shadowsocks-haskell翻墙的速度并不快,看youtube很慢,所以不建议使用此法翻墙。
试用后,发现用shadowsocks-haskell翻墙的速度并不快,看youtube很慢,所以不建议使用此法翻墙。
--extra-include-dirs=/usr/local/opt/openssl/include --extra-lib-dirs=/usr/local/opt/openssl/lib
------
一个类似的基于haskell的项目-moesocks (感觉moesocks用起来,比shadowsocks-haskell
好用多了。)
MoeSocks
A SOCKS5 proxy using the client / server architecture.
MoeSocks is mostly compatible with shadowsocks.
Installation
From binary
Install Nix
curl https://nixos.org/nix/install | sh
Install moesocks
nix-env -i -A nixpkgs.haskellPackages.moesocks
Run
moesocks
From source
firstly Install GHC and cabal.
Download moesocks:
git clone https://github.com/luckypoem/moesocks
cd moesocks
cabal sandbox init
Install:
cabal install
--extra-include-dirs=/usr/local/opt/openssl/include --extra-lib-dirs=/usr/local/opt/openssl/lib
Run
.cabal-sandbox/bin/moesocks (这个生成的可执行文件
moesocks就是我们所需要的文件)
Usage
- Start a remote node outside a firewall:
moesocks -r remote -k birthday!
- Start a local node inside a firewall:
moesocks -s $REMOTE_IP -k birthday!
- Now you have a SOCKS5 proxy running inside a firewall on port
1080
. - See more options:
moesocks --help
Features
- SOCKS5 proxy service, tested with GFW.
- TCP port forwarding.
- UDP port forwarding, for example to tunnel DNS request:
-U 5300:8.8.8.8:53
. - SOCKS5 service on local can be turned off.
- Understand
shadowsocks
' json configuration file.
Known issues
- UDP over SOCKS5 is not implemented.
- TCP bind over SOCKS5 is not implemented.
- A bit slower then the Python implementation.
- Only works on Unix.
Tips
TCP Fast Open (TFO)
Benefit of using TFO
TFO can bypass the TCP three-way handshake in successive connections, thus reducing latency.
Enable TFO in your OS runtime.
On Linux 3.7+, to check the availability of TFO:
cat /proc/sys/net/ipv4/tcp_fastopen
On Linux 3.7+, to enable TFO (as root):
echo 3 > /proc/sys/net/ipv4/tcp_fastopen
Enable TFO in MoeSocks
TFO can be turned on by adding a
"fastOpen":true
field in config.json
or adding a --fast-open
argument in the command line.Verify
Use
tcpdump
on the remotePort
, check for that SYN
should start to carry payload. An example command is:tcpdump port 8388 -i any -X -v
TCP BBR
Using tcp-bbr as the congestion control algorithm should dramatically increase your bandwith in most cases.
Credits
- shadowsocks greatly inspired MoeSocks.
- shadowsocks-haskell another implementation of shadowsocks in Haskell, also greatly inspired MoeSocks. Much of the understanding of the internal of shadowsocks was gained by reading shadowsocks-haskell.
from https://github.com/luckypoem/moesocks
https://github.com/cngeeks/moesocks
-------
我的补充说明
登陆linux vps,
git clone https://github.com/luckypoem/moesocks
cd moesocks
stack init
(因为moesocks目录里有cabal文件,所以可运行stack init,来生成stack.yaml)
stack install
显示:
...
cd moesocks
stack init
(因为moesocks目录里有cabal文件,所以可运行stack init,来生成stack.yaml)
stack install
https://github.com/cngeeks/moesocks
-------
我的补充说明
登陆linux vps,
git clone https://github.com/luckypoem/moesocks
cd moesocks
stack init
(因为moesocks目录里有cabal文件,所以可运行stack init,来生成stack.yaml)
stack install
显示:
...
Installing executable moesocks in /root/moesocks/.stack-work/install/x86_64-linux/lts-11.14/8.2.2/bin
Completed 19 action(s).
Copying from /root/moesocks/.stack-work/install/x86_64-linux/lts-11.14/8.2.2/bin/moesocks to /root/.local/bin/moesocks
Copied executables to /root/.local/bin:
- moesocks
然后运行moesocks -r remote -s 0.0.0.0 -p 2388 -k my-password -m aes-256-cfb
(不过这条命令是运行在前台的,容易退出,我们可以利用systemd来把该命令运行为service:
nano /etc/systemd/system/moesocks.service
其内容为:
[Unit]
After=network.target
[Service]
ExecStart=/root/.local/bin/moesocks -r remote -s 0.0.0.0 -p 2388 -k my-password -m aes-256-cfb
Restart=always
[Install]
WantedBy=multi-user.target
然后运行:
systemctl start moesocks
systemctl enable moesocks
服务器端就搭建好了。
至于客户端,是兼容‘纸飞机’程序的,把你服务器的ip,端口2388,你的密码,加密方式aes-256-cfb共4个参数值填入‘纸飞机’程序。
在linux桌面系统上,还可这样做:
先安装ghc.
git clone https://github.com/luckypoem/moesocks先安装ghc.
cd moesocks
stack init
(因为moesocks目录里有cabal文件,所以可运行stack init,来生成stack.yaml)
stack install
moesocks -r local -s vps-ip -p 2388 -k my-password -m aes-256-cfb -l 3344
然后设置浏览器的socks5代理服务器为127.0.0.1:3344 ,浏览器即可翻墙。
在mac桌面系统上,则这样做:
在mac桌面系统上,则这样做:
git clone https://github.com/luckypoem/moesocks
cd moesocks
cabal sandbox init
cabal install --extra-include-dirs=/usr/local/opt/openssl/include --extra-lib-dirs=/usr/local/opt/openssl/lib
然后运行:
.cabal-sandbox/bin/moesocks -r local -s vps-ip -p 2388 -k my-password -m aes-256-cfb -l 3344
(这个生成的可执行文件moesocks就是我们所需要的文件)
然后设置浏览器的socks5代理服务器为127.0.0.1:3344 ,浏览器即可翻墙。
No comments:
Post a Comment