登陆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:~# cd /root/go/gopath/src
root@umh:~/go/gopath/src# git clone https://github.com/Kyoloro/whiteshadow
root@umh:~/go/gopath/src# cd whiteshadow
root@umh:~/go/gopath/src/whiteshadow# ls
README.md cmd sock5
root@umh:~/go/gopath/src/whiteshadow# grep -ri 1080 .
会显示:
./cmd/server/main.go: flag.IntVar(&Port, "port", 1080, "Server Listen Port")
./sock5/protocol.go: Sock5DefaultPort = 1080
./sock5/config.go: Port: 1080,
root@umh:~/go/gopath/src/whiteshadow#
分别修改 ./cmd/server/main.go,./sock5/protocol.go,./sock5/config.go里面的1080端口为其他端口,比如2070.然后,
root@umh:~/go/gopath/src/whiteshadow# cd cmd/server
root@umh:~/go/gopath/src/whiteshadow/cmd/server# ls
main.go
root@umh:~/go/gopath/src/whiteshadow/cmd/server# go build main.go
(此命令会在当前目录下,生成可执行文件main)
root@umh:~/go/gopath/src/whiteshadow/cmd/server# ls
main main.go
root@umh:~/go/gopath/src/whiteshadow/cmd/server# ./main
会显示:
2018/07/28 12:09:30 Listen sock5 server on 2070
不过此命令是在前台运行的,容易退出,我们可利用systemd来把此命令运行为service:
nano /etc/systemd/system/whiteshadow-by-kyoloro.service
内容为:
[Unit]
After=network.target
[Service]
WorkingDirectory=/root/go/gopath/src/whiteshadow/cmd/server/
ExecStart=/root/go/gopath/src/whiteshadow/cmd/server/main
Restart=always
[Install]
WantedBy=multi-user.target
然后运行:
systemctl start whiteshadow-by-kyoloro
systemctl enable whiteshadow-by-kyoloro
服务器端就搭建好了。
项目地址:https://github.com/Kyoloro/whiteshadow
(此项目fork自 https://github.com/alanyang/whiteshadow,但是这个原版其实改不了whiteshadow的端口号,所以不建议使用此原版)
类似的项目:
https://briteming.blogspot.com/2018/07/python-proxy.html
https://briteming.blogspot.com/2018/07/node-socks5.html
需先安装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:~# cd /root/go/gopath/src
root@umh:~/go/gopath/src# git clone https://github.com/Kyoloro/whiteshadow
root@umh:~/go/gopath/src# cd whiteshadow
root@umh:~/go/gopath/src/whiteshadow# ls
README.md cmd sock5
root@umh:~/go/gopath/src/whiteshadow# grep -ri 1080 .
会显示:
./cmd/server/main.go: flag.IntVar(&Port, "port", 1080, "Server Listen Port")
./sock5/protocol.go: Sock5DefaultPort = 1080
./sock5/config.go: Port: 1080,
root@umh:~/go/gopath/src/whiteshadow#
分别修改 ./cmd/server/main.go,./sock5/protocol.go,./sock5/config.go里面的1080端口为其他端口,比如2070.然后,
root@umh:~/go/gopath/src/whiteshadow# cd cmd/server
root@umh:~/go/gopath/src/whiteshadow/cmd/server# ls
main.go
root@umh:~/go/gopath/src/whiteshadow/cmd/server# go build main.go
(此命令会在当前目录下,生成可执行文件main)
root@umh:~/go/gopath/src/whiteshadow/cmd/server# ls
main main.go
root@umh:~/go/gopath/src/whiteshadow/cmd/server# ./main
会显示:
2018/07/28 12:09:30 Listen sock5 server on 2070
不过此命令是在前台运行的,容易退出,我们可利用systemd来把此命令运行为service:
nano /etc/systemd/system/whiteshadow-by-kyoloro.service
内容为:
[Unit]
After=network.target
[Service]
WorkingDirectory=/root/go/gopath/src/whiteshadow/cmd/server/
ExecStart=/root/go/gopath/src/whiteshadow/cmd/server/main
Restart=always
[Install]
WantedBy=multi-user.target
然后运行:
systemctl start whiteshadow-by-kyoloro
systemctl enable whiteshadow-by-kyoloro
服务器端就搭建好了。
项目地址:https://github.com/Kyoloro/whiteshadow
(此项目fork自 https://github.com/alanyang/whiteshadow,但是这个原版其实改不了whiteshadow的端口号,所以不建议使用此原版)
类似的项目:
https://briteming.blogspot.com/2018/07/python-proxy.html
https://briteming.blogspot.com/2018/07/node-socks5.html
因为pure socks proxy server仍然是明文传输,不安全。这类pure socks proxy server可以做各类tunnel程序的后端使用。
No comments:
Post a Comment