Total Pageviews

Wednesday, 16 October 2019

安装socks代理服务器程序spleen

 首先在本地机器的浏览器上,访问https://github.com/Leviathan1995/spleen,然后把该项目fork一份,我fork为https://github.com/luckypoem/spleen,
在此处https://github.com/luckypoem/spleen/blob/master/server/main.go,把第9行改为"github.com/luckypoem/spleen/server/util",
在此处https://github.com/luckypoem/spleen/blob/master/server/util/server.go,把第8行改为
"github.com/luckypoem/spleen/service" 。注意:把luckypoem替换为你的用户名。

然后登陆Linux vps.先安装go环境。然后,
cd $GOPATH
go get -u -v github.com/luckypoem/spleen/server/

在$GOPATH/bin/内,会生成可执行文件server.
mv  $GOPATH/bin/server $GOPATH/bin/server-by-spleen
cd ~


[root@hs ~]# which server-by-spleen
/root/go/gopath/bin/server-by-spleen
[root@hs ~]#
[root@hs ~]# server-by-spleen -h
Usage of server-by-spleen:
  -c string
        server config (default ".server.json")
[root@hs ~]# wget https://github.com/luckypoem/spleen/raw/master/.server.json
[root@hs ~]# nano .server.json
[root@hs ~]# cat .server.json
{
  "local_ip"   : "127.0.0.1",
  "local_port" : 20000
}
[root@hs ~]#
server-by-spleen -c .server.json
会显示:
2019/10/16 16:26:45 Server local address: 127.0.0.1:20000
2019/10/16 16:26:45 Server listen at 127.0.0.1:20000 successed.

不过server-by-spleen -c .server.json是运行在前台的,我们可以用systemd把它运行为service:
nano /etc/systemd/system/socks-server-by-spleen.service
其内容为:
[Unit]
After=network.target

[Service]
ExecStart=/root/go/gopath/bin/server-by-spleen -c /root/.server.json
Restart=always

[Install]
WantedBy=multi-user.target


然后,运行: 
systemctl start socks-server-by-spleen
systemctl enable socks-server-by-spleen
安装socks代理服务器程序spleen完成。

这个socks代理服务器程序可用作tunnel程序的后端程序。

项目地址:
https://github.com/Leviathan1995/spleen
https://github.com/luckypoem/spleen