登陆linux vps.
首先安装go环境:
wget https://dl.google.com/go/go1.10.linux-amd64.tar.gz
tar zxvf go1.10.linux-amd64.tar.gz
echo 'export PATH=$PATH:/root/go/bin' >> /etc/profile
cd go
mkdir gopath
echo 'export GOROOT=/root/go' >> /etc/profile
echo 'export GOPATH=/root/go/gopath' >> /etc/profile
. /etc/profile
这样,go环境就搭建好了。检验一下:
root@umh:~/go# echo $GOROOT
/root/go
root@umh:~/go# echo $GOPATH
/root/go/gopath
root@umh:~/go# cd ~
root@umh:~#
可见我的操作系统的 $GOPATH是 /root/go/gopath。
root@umh:~# cd /root/go/gopath/src
首先安装go环境:
wget https://dl.google.com/go/go1.10.linux-amd64.tar.gz
tar zxvf go1.10.linux-amd64.tar.gz
echo 'export PATH=$PATH:/root/go/bin' >> /etc/profile
cd go
mkdir gopath
echo 'export GOROOT=/root/go' >> /etc/profile
echo 'export GOPATH=/root/go/gopath' >> /etc/profile
. /etc/profile
这样,go环境就搭建好了。检验一下:
root@umh:~/go# echo $GOROOT
/root/go
root@umh:~/go# echo $GOPATH
/root/go/gopath
root@umh:~/go# cd ~
root@umh:~#
可见我的操作系统的 $GOPATH是 /root/go/gopath。
root@umh:~# cd /root/go/gopath/src
root@umh:~/go/gopath/src# git clone https://github.com/Kyoloro/go-socks5
root@umh:~/go/gopath/src# cd go-socks5
root@umh:~/go/gopath/src/go-socks5# ls
LICENSE README.md main.go media socks5 util
root@umh:~/go/gopath/src/go-socks5# grep -ri 1080 .
./socks5/config.go: Port: 1080,
root@umh:~/go/gopath/src/go-socks5# nano socks5/config.go
(把Port: 1080,改为Port: 20800, )
root@umh:~/go/gopath/src/go-socks5# grep -ri 127.0.0.1 .
./main.go: svr, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d",
socks5.ServerConfig.Port))
root@umh:~/go/gopath/src/go-socks5# go build main.go
(此命令会在当前目录下,生成可执行文件main)
root@umh:~/go/gopath/src/go-socks5# ls
LICENSE README.md main main.go media socks5 util
root@umh:~/go/gopath/src/go-socks5# ./main > /dev/null &
不过命令:nohup ./main > /dev/null &还是容易退出,我们可以利用systemd来把./main运行为service:
nano /etc/systemd/system/go-socks5.service
内容为:
[Unit]
After=network.target
[Service]
WorkingDirectory=/root/go/gopath/src/go-socks5/
ExecStart=/root/go/gopath/src/go-socks5/main
Restart=always
[Install]
WantedBy=multi-user.target
然后运行,
systemctl start go-socks5
systemctl enable go-socks5
socks proxy服务器搭建完成。
项目地址:
https://github.com/Kyoloro/go-socks5
https://github.com/Kyoloro/go-socks5/issues/1
-------
类似项目:https://github.com/nicdex/go-socks5
相关帖子:https://briteming.blogspot.com/2018/07/node-socks5.html
No comments:
Post a Comment