如果你的linux vps里安装的go的版本为1.4.x,则需另外安装go 1.5.x:
wget https://storage.googleapis.com/golang/go1.5.4.linux-386.tar.gz
(wget https://storage.googleapis.com/golang/go1.5.4.linux-amd64.tar.gz ,如果你的系统是64位)
tar zxvf go1.5.4.linux-386.tar.gz -C /usr/local/
mv /usr/local/go /usr/local/go1.5.4
git clone https://github.com/cosiner/tunnel tunnel-by-cosiner
cd tunnel-by-cosiner
mkdir gospace
cd gospace
export GOPATH=~/tunnel-by-cosiner/gospace/ 或export GOPATH=`pwd`
export GOROOT=/usr/local/go1.5.4/ (这一步不可少!)
cd tunnel-by-cosiner
mkdir gospace
cd gospace
export GOPATH=~/tunnel-by-cosiner/gospace/ 或export GOPATH=`pwd`
export GOROOT=/usr/local/go1.5.4/ (这一步不可少!)
root@AR:~/tunnel-by-cosiner/gospace# /usr/local/go1.5.4/bin/go get github.com/cosiner/tunnel
root@AR:~/tunnel-by-cosiner/gospace# ls
pkg src
root@AR:~/tunnel-by-cosiner/gospace# /usr/local/go1.5.4/bin/go install github.com/cosiner/tunnel
root@AR:~/tunnel-by-cosiner/gospace#
root@AR:~/tunnel-by-cosiner/gospace# which tunnel
root@AR:~/tunnel-by-cosiner/gospace# find / -name tunnel
/usr/local/go1.5.4/bin/tunnel
^C
root@AR:~/tunnel-by-cosiner/gospace# ls /usr/local/go1.5.4/bin/
go godoc gofmt tunnel
root@AR:~/tunnel-by-cosiner/gospace#
root@AR:~/tunnel-by-cosiner/gospace# ls
pkg src
root@AR:~/tunnel-by-cosiner/gospace# /usr/local/go1.5.4/bin/go install github.com/cosiner/tunnel
root@AR:~/tunnel-by-cosiner/gospace#
root@AR:~/tunnel-by-cosiner/gospace# which tunnel
root@AR:~/tunnel-by-cosiner/gospace# find / -name tunnel
/usr/local/go1.5.4/bin/tunnel
^C
root@AR:~/tunnel-by-cosiner/gospace# ls /usr/local/go1.5.4/bin/
go godoc gofmt tunnel
root@AR:~/tunnel-by-cosiner/gospace#
直接运行/usr/local/go1.5.4/bin/go install github.com/cosiner/tunnel 会遇到错误:
can't load package: package github.com/cosiner/tunnel: cannot find package "github.com/cosiner/tunnel" in any of:
/usr/local/go1.5.4/src/github.com/cosiner/tunnel (from $GOROOT)
/root/tunnel-by-cosiner/gospace/src/github.com/cosiner/tunnel (from $GOPATH) 。
必须先运行 /usr/local/go1.5.4/bin/go get github.com/cosiner/tunnel ,再运行
/usr/local/go1.5.4/bin/go install github.com/cosiner/tunnel才不会遇到错误。
can't load package: package github.com/cosiner/tunnel: cannot find package "github.com/cosiner/tunnel" in any of:
/usr/local/go1.5.4/src/github.com/cosiner/tunnel (from $GOROOT)
/root/tunnel-by-cosiner/gospace/src/github.com/cosiner/tunnel (from $GOPATH) 。
必须先运行 /usr/local/go1.5.4/bin/go get github.com/cosiner/tunnel ,再运行
/usr/local/go1.5.4/bin/go install github.com/cosiner/tunnel才不会遇到错误。
root@AR:~/tunnel-by-cosiner/gospace# /usr/local/go1.5.4/bin/tunnel --help
Usage of /usr/local/go1.5.4/bin/tunnel:
-conf string
config file in json (default "tunnel.json")
-local
run as local server
-remote
run as remote server
root@AR:~/tunnel-by-cosiner/gospace# cp ../tunnel.json.sample tunnel.json
Usage of /usr/local/go1.5.4/bin/tunnel:
-conf string
config file in json (default "tunnel.json")
-local
run as local server
-remote
run as remote server
root@AR:~/tunnel-by-cosiner/gospace# cp ../tunnel.json.sample tunnel.json
root@AR:~/tunnel-by-cosiner/gospace# ls
pkg src tunnel.json
root@AR:~/tunnel-by-cosiner/gospace# nano tunnel.json
(把tunnel.json的第16行里的127.0.0.1改为0.0.0.0)
root@AR:~/tunnel-by-cosiner/gospace# nohup /usr/local/go1.5.4/bin/tunnel -conf tunnel.json -remote > /dev/null &
(这样,服务器端就搭建好了)
在客户机器上。
linux桌面系统下,客户端的搭建跟linux vps大同小异。只是最后编辑tunnel.json时,把tunnel.json的第16行里的127.0.0.1改为你的vps的ip.然后,
~/tunnel-by-cosiner/gospace$ nohup /usr/local/go1.5.4/bin/tunnel -conf tunnel.json -local > /dev/null &
(这样,客户端就搭建好了)
设置本地机器的浏览器的socks5代理为127.0.0.1:7778,即可翻墙。
在mac下。参考http://briteming.blogspot.com/2015/10/macgo.html,搭建go的1.5.x 版。然后,
yudeMacBook-Air:~ brite$ git clone https://github.com/cosiner/tunnel tunnel-by-cosiner
yudeMacBook-Air:~ brite$ cd tunnel-by-cosiner
yudeMacBook-Air:tunnel-by-cosiner brite$ ls
LICENSE main.go server
README.md proxy tunnel.json.sample
yudeMacBook-Air:tunnel-by-cosiner brite$ mkdir gospace
yudeMacBook-Air:tunnel-by-cosiner brite$ cd gospace
yudeMacBook-Air:gospace brite$ export GOPATH=`pwd`
yudeMacBook-Air:gospace brite$ echo $GOROOT
/usr/local/go/
yudeMacBook-Air:gospace brite$ which go
/usr/local/go/bin/go
yudeMacBook-Air:gospace brite$ go version
go version go1.5.1 darwin/amd64
yudeMacBook-Air:gospace brite$ go get github.com/cosiner/tunnel
yudeMacBook-Air:gospace brite$ ls
bin pkg src
yudeMacBook-Air:gospace brite$ ls bin
tunnel
yudeMacBook-Air:gospace brite$ cd bin
yudeMacBook-Air:bin brite$ ls
tunnel
yudeMacBook-Air:bin brite$ pwd
/Users/brite/tunnel-by-cosiner/gospace/bin
yudeMacBook-Air:bin brite$ cp /Users/brite/tunnel-by-cosiner/tunnel.json.sample tunnel.json
yudeMacBook-Air:bin brite$ ls
tunnel tunnel.json
yudeMacBook-Air:bin brite$ nano tunnel.json
(把tunnel.json的第16行里的127.0.0.1改为你的vps的ip)
yudeMacBook-Air:bin brite$ nohup ./tunnel -conf tunnel.json -local > /dev/null &
这样,客户端就搭建好了。
设置本地机器的浏览器的socks5代理为127.0.0.1:7778,即可翻墙。
在window桌面系统下。作者提供了客户端程序:
https://github.com/cosiner/tunnel/releases/download/v0.1.1/tunnel.exe
在window桌面系统下。作者提供了客户端程序:
https://github.com/cosiner/tunnel/releases/download/v0.1.1/tunnel.exe
项目地址:https://github.com/cosiner/tunnel
参考http://stackoverflow.com/questions/27772831/golang-c-source-files-not-allowed-when-not-using-cgo里面的一句话“if you install Go 1.4 and then install Go 1.5. But don't change GOROOT environment variables. Change GOROOT point to GO 1.5 path.“
因为我没删除之前安装的go1.4版,所以必须运行一下export GOROOT=/usr/local/go1.5.4/ (这一步不可少!)