mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
Merge branch 'dev'
This commit is contained in:
commit
2c39719cc0
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,6 +25,7 @@ _testmain.go
|
|||||||
|
|
||||||
# Self
|
# Self
|
||||||
bin/
|
bin/
|
||||||
|
packages/
|
||||||
|
|
||||||
# Cache
|
# Cache
|
||||||
*.swp
|
*.swp
|
||||||
|
13
Makefile
13
Makefile
@ -1,21 +1,22 @@
|
|||||||
export PATH := $(GOPATH)/bin:$(PATH)
|
export PATH := $(GOPATH)/bin:$(PATH)
|
||||||
export NEW_GOPATH := $(shell pwd)
|
export OLDGOPATH := $(GOPATH)
|
||||||
|
export GOPATH := $(shell pwd):$(GOPATH)
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
build: godep fmt frps frpc
|
build: godep fmt frps frpc
|
||||||
|
|
||||||
godep:
|
godep:
|
||||||
@go get github.com/tools/godep
|
GOPATH=$(OLDGOPATH) go get github.com/tools/godep
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
GOPATH=$(NEW_GOPATH) godep go fmt ./...
|
godep go fmt ./...
|
||||||
|
|
||||||
frps:
|
frps:
|
||||||
GOPATH=$(NEW_GOPATH) godep go build -o bin/frps ./src/frp/cmd/frps
|
godep go build -o bin/frps ./src/frp/cmd/frps
|
||||||
|
|
||||||
frpc:
|
frpc:
|
||||||
GOPATH=$(NEW_GOPATH) godep go build -o bin/frpc ./src/frp/cmd/frpc
|
godep go build -o bin/frpc ./src/frp/cmd/frpc
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@GOPATH=$(NEW_GOPATH) godep go test -v ./...
|
godep go test -v ./...
|
||||||
|
15
Makefile.cross-compiles
Normal file
15
Makefile.cross-compiles
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
export PATH := $(GOPATH)/bin:$(PATH)
|
||||||
|
export OLDGOPATH := $(GOPATH)
|
||||||
|
export GOPATH := $(shell pwd)/Godeps/_workspace:$(shell pwd):$(GOPATH)
|
||||||
|
export OS_TARGETS=linux windows
|
||||||
|
export ARCH_TARGETS=386 amd64
|
||||||
|
|
||||||
|
all: build
|
||||||
|
|
||||||
|
build: godep app
|
||||||
|
|
||||||
|
godep:
|
||||||
|
GOPATH=$(OLDGOPATH) go get github.com/mitchellh/gox
|
||||||
|
|
||||||
|
app:
|
||||||
|
gox -os "$(OS_TARGETS)" -arch="$(ARCH_TARGETS)" ./...
|
@ -3,9 +3,9 @@
|
|||||||
server_addr = 0.0.0.0
|
server_addr = 0.0.0.0
|
||||||
server_port = 7000
|
server_port = 7000
|
||||||
# console or real logFile path like ./frpc.log
|
# console or real logFile path like ./frpc.log
|
||||||
log_file = console
|
log_file = ./frpc.log
|
||||||
# debug, info, warn, error
|
# debug, info, warn, error
|
||||||
log_level = debug
|
log_level = info
|
||||||
# for authentication
|
# for authentication
|
||||||
auth_token = 123
|
auth_token = 123
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
bind_addr = 0.0.0.0
|
bind_addr = 0.0.0.0
|
||||||
bind_port = 7000
|
bind_port = 7000
|
||||||
# console or real logFile path like ./frps.log
|
# console or real logFile path like ./frps.log
|
||||||
log_file = console
|
log_file = ./frps.log
|
||||||
# debug, info, warn, error
|
# debug, info, warn, error
|
||||||
log_level = debug
|
log_level = info
|
||||||
|
|
||||||
# test1 is the proxy name, client will use this name and auth_token to connect to server
|
# test1 is the proxy name, client will use this name and auth_token to connect to server
|
||||||
[test1]
|
[test1]
|
||||||
|
45
cross_compiles_package.sh
Executable file
45
cross_compiles_package.sh
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
# compile for version
|
||||||
|
make
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "make error"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
frp_version=`./bin/frps --version`
|
||||||
|
echo "build version: $frp_version"
|
||||||
|
|
||||||
|
# cross_compiles
|
||||||
|
make -f ./Makefile.cross-compiles
|
||||||
|
|
||||||
|
rm -rf ./packages
|
||||||
|
mkdir ./packages
|
||||||
|
|
||||||
|
os_all='linux windows'
|
||||||
|
arch_all='386 amd64'
|
||||||
|
|
||||||
|
for os in $os_all; do
|
||||||
|
for arch in $arch_all; do
|
||||||
|
frp_dir_name="frp_${frp_version}_${os}_${arch}"
|
||||||
|
frp_path="./packages/frp_${frp_version}_${os}_${arch}"
|
||||||
|
mkdir ${frp_path}
|
||||||
|
if [ "x${os}" = x"windows" ]; then
|
||||||
|
mv ./frpc_${os}_${arch}.exe ${frp_path}/frpc.exe
|
||||||
|
mv ./frps_${os}_${arch}.exe ${frp_path}/frps.exe
|
||||||
|
else
|
||||||
|
mv ./frpc_${os}_${arch} ${frp_path}/frpc
|
||||||
|
mv ./frps_${os}_${arch} ${frp_path}/frps
|
||||||
|
fi
|
||||||
|
cp ./LICENSE ${frp_path}
|
||||||
|
cp ./conf/* ${frp_path}
|
||||||
|
|
||||||
|
# packages
|
||||||
|
cd ./packages
|
||||||
|
if [ "x${os}" = x"windows" ]; then
|
||||||
|
zip -rq ${frp_dir_name}.zip ${frp_dir_name}
|
||||||
|
else
|
||||||
|
tar -zcf ${frp_dir_name}.tar.gz ${frp_dir_name}
|
||||||
|
fi
|
||||||
|
cd ..
|
||||||
|
rm -rf ${frp_path}
|
||||||
|
done
|
||||||
|
done
|
@ -72,7 +72,10 @@ func msgReader(cli *client.ProxyClient, c *conn.Conn, msgSendChan chan interface
|
|||||||
log.Info("ProxyName [%s], try to reconnect to frps [%s:%d]...", cli.Name, client.ServerAddr, client.ServerPort)
|
log.Info("ProxyName [%s], try to reconnect to frps [%s:%d]...", cli.Name, client.ServerAddr, client.ServerPort)
|
||||||
c, err = loginToServer(cli)
|
c, err = loginToServer(cli)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
close(msgSendChan)
|
||||||
|
msgSendChan = make(chan interface{}, 1024)
|
||||||
go heartbeatSender(c, msgSendChan)
|
go heartbeatSender(c, msgSendChan)
|
||||||
|
go msgSender(cli, c, msgSendChan)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +84,7 @@ func msgReader(cli *client.ProxyClient, c *conn.Conn, msgSendChan chan interface
|
|||||||
}
|
}
|
||||||
time.Sleep(delayTime * time.Second)
|
time.Sleep(delayTime * time.Second)
|
||||||
}
|
}
|
||||||
|
continue
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
log.Warn("ProxyName [%s], read from frps error: %v", cli.Name, err)
|
log.Warn("ProxyName [%s], read from frps error: %v", cli.Name, err)
|
||||||
continue
|
continue
|
||||||
@ -117,7 +121,7 @@ func msgSender(cli *client.ProxyClient, c *conn.Conn, msgSendChan chan interface
|
|||||||
buf, _ := json.Marshal(msg)
|
buf, _ := json.Marshal(msg)
|
||||||
err := c.Write(string(buf) + "\n")
|
err := c.Write(string(buf) + "\n")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("ProxyName [%s], write to client error, proxy exit", cli.Name)
|
log.Warn("ProxyName [%s], write to server error, proxy exit", cli.Name)
|
||||||
c.Close()
|
c.Close()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ func msgReader(s *server.ProxyServer, c *conn.Conn, msgSendChan chan interface{}
|
|||||||
case consts.HeartbeatReq:
|
case consts.HeartbeatReq:
|
||||||
log.Debug("ProxyName [%s], get heartbeat", s.Name)
|
log.Debug("ProxyName [%s], get heartbeat", s.Name)
|
||||||
timer.Reset(time.Duration(server.HeartBeatTimeout) * time.Second)
|
timer.Reset(time.Duration(server.HeartBeatTimeout) * time.Second)
|
||||||
heartbeatRes := msg.ControlRes{
|
heartbeatRes := &msg.ControlRes{
|
||||||
Type: consts.HeartbeatRes,
|
Type: consts.HeartbeatRes,
|
||||||
}
|
}
|
||||||
msgSendChan <- heartbeatRes
|
msgSendChan <- heartbeatRes
|
||||||
|
Loading…
Reference in New Issue
Block a user