合并最新代码

This commit is contained in:
haidy 2019-03-05 22:31:51 +08:00
parent b66cd62c0d
commit 512e601cc9
8 changed files with 28 additions and 9 deletions

View File

@ -20,6 +20,8 @@ package assets
//go:generate go fmt ./frpc/statik/statik.go
import (
statik2 "github.com/fatedier/frp/assets/frpc/statik"
"github.com/fatedier/frp/assets/frps/statik"
"io/ioutil"
"net/http"
"os"
@ -34,16 +36,24 @@ var (
// if prefix is not empty, we get file content from disk
prefixPath string
Frpc = 1
Frps = 2
)
// if path is empty, load assets in memory
// or set FileSystem using disk files
func Load(path string) (err error) {
func Load(path string, t int) (err error) {
prefixPath = path
if prefixPath != "" {
FileSystem = http.Dir(prefixPath)
return nil
} else {
if t == Frpc {
statik.RegisterFrps()
} else {
statik2.RegisterFrpc()
}
FileSystem, err = fs.New()
}
return err

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -54,7 +54,7 @@ type Service struct {
func NewService(pxyCfgs map[string]config.ProxyConf, visitorCfgs map[string]config.VisitorConf) (svr *Service, err error) {
// Init assets
err = assets.Load("")
err = assets.Load("", assets.Frpc)
if err != nil {
err = fmt.Errorf("Load assets error: %v", err)
return

View File

@ -19,8 +19,13 @@ import (
"github.com/fatedier/frp/cmd/frps/frps"
"github.com/fatedier/frp/utils/version"
"github.com/fatedier/golib/crypto"
"runtime/debug"
)
func init() {
debug.SetGCPercent(5)
}
func RunFrpc(cfgFilePath string) (err error) {
crypto.DefaultSalt = "frp"
@ -28,6 +33,7 @@ func RunFrpc(cfgFilePath string) (err error) {
}
func StopFrpc() (err error) {
defer debug.FreeOSMemory()
return sub.StopFrp()
}
@ -43,6 +49,7 @@ func RunFrps(cfgFilePath string) (err error) {
// StopFrps 停止frps服务
func StopFrps() error {
defer debug.FreeOSMemory()
return frps.StopFrps()
}

View File

@ -124,6 +124,7 @@ func StopFrp() (err error) {
service.Close()
log.Info("frpc is stoped")
service = nil
return
}

View File

@ -1,3 +1,2 @@
[common]
bind_port = 7000
allow_ports = 7000, 6000
bind_port = 7000

View File

@ -107,7 +107,7 @@ func NewService() (svr *Service, err error) {
svr.rc.TcpGroupCtl = group.NewTcpGroupCtl(svr.rc.TcpPortManager)
// Init assets
err = assets.Load(cfg.AssetsDir)
err = assets.Load(cfg.AssetsDir, assets.Frps)
if err != nil {
err = fmt.Errorf("Load assets error: %v", err)
return