mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
commit
08b0885564
@ -106,7 +106,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pxyCfgs, err := config.LoadProxyConfFromFile(conf)
|
pxyCfgs, err := config.LoadProxyConfFromFile(config.ClientCommonCfg.User, conf, config.ClientCommonCfg.Start)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -32,6 +32,10 @@ user = your_name
|
|||||||
# default is true
|
# default is true
|
||||||
login_fail_exit = true
|
login_fail_exit = true
|
||||||
|
|
||||||
|
# proxy names you want to start divided by ','
|
||||||
|
# default is empty, means all proxies
|
||||||
|
# start = ssh,dns
|
||||||
|
|
||||||
# heartbeat configure, it's not recommended to modify the default value
|
# heartbeat configure, it's not recommended to modify the default value
|
||||||
# the default value of heartbeat_interval is 10 and heartbeat_timeout is 90
|
# the default value of heartbeat_interval is 10 and heartbeat_timeout is 90
|
||||||
# heartbeat_interval = 30
|
# heartbeat_interval = 30
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
ini "github.com/vaughan0/go-ini"
|
ini "github.com/vaughan0/go-ini"
|
||||||
)
|
)
|
||||||
@ -39,6 +40,7 @@ type ClientCommonConf struct {
|
|||||||
TcpMux bool
|
TcpMux bool
|
||||||
User string
|
User string
|
||||||
LoginFailExit bool
|
LoginFailExit bool
|
||||||
|
Start map[string]struct{}
|
||||||
HeartBeatInterval int64
|
HeartBeatInterval int64
|
||||||
HeartBeatTimeout int64
|
HeartBeatTimeout int64
|
||||||
}
|
}
|
||||||
@ -58,6 +60,7 @@ func GetDeaultClientCommonConf() *ClientCommonConf {
|
|||||||
TcpMux: true,
|
TcpMux: true,
|
||||||
User: "",
|
User: "",
|
||||||
LoginFailExit: true,
|
LoginFailExit: true,
|
||||||
|
Start: make(map[string]struct{}),
|
||||||
HeartBeatInterval: 30,
|
HeartBeatInterval: 30,
|
||||||
HeartBeatTimeout: 90,
|
HeartBeatTimeout: 90,
|
||||||
}
|
}
|
||||||
@ -136,6 +139,14 @@ func LoadClientCommonConf(conf ini.File) (cfg *ClientCommonConf, err error) {
|
|||||||
cfg.User = tmpStr
|
cfg.User = tmpStr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmpStr, ok = conf.Get("common", "start")
|
||||||
|
if ok {
|
||||||
|
proxyNames := strings.Split(tmpStr, ",")
|
||||||
|
for _, name := range proxyNames {
|
||||||
|
cfg.Start[name] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tmpStr, ok = conf.Get("common", "login_fail_exit")
|
tmpStr, ok = conf.Get("common", "login_fail_exit")
|
||||||
if ok && tmpStr == "false" {
|
if ok && tmpStr == "false" {
|
||||||
cfg.LoginFailExit = false
|
cfg.LoginFailExit = false
|
||||||
|
@ -466,14 +466,21 @@ func (cfg *HttpsProxyConf) Check() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadProxyConfFromFile(conf ini.File) (proxyConfs map[string]ProxyConf, err error) {
|
// if len(startProxy) is 0, start all
|
||||||
var prefix string
|
// otherwise just start proxies in startProxy map
|
||||||
if ClientCommonCfg.User != "" {
|
func LoadProxyConfFromFile(prefix string, conf ini.File, startProxy map[string]struct{}) (proxyConfs map[string]ProxyConf, err error) {
|
||||||
prefix = ClientCommonCfg.User + "."
|
if prefix != "" {
|
||||||
|
prefix += "."
|
||||||
|
}
|
||||||
|
|
||||||
|
startAll := true
|
||||||
|
if len(startProxy) > 0 {
|
||||||
|
startAll = false
|
||||||
}
|
}
|
||||||
proxyConfs = make(map[string]ProxyConf)
|
proxyConfs = make(map[string]ProxyConf)
|
||||||
for name, section := range conf {
|
for name, section := range conf {
|
||||||
if name != "common" {
|
_, shouldStart := startProxy[name]
|
||||||
|
if name != "common" && (startAll || shouldStart) {
|
||||||
cfg, err := NewProxyConfFromFile(name, section)
|
cfg, err := NewProxyConfFromFile(name, section)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return proxyConfs, err
|
return proxyConfs, err
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var version string = "0.10.0"
|
var version string = "0.11.0"
|
||||||
|
|
||||||
func Full() string {
|
func Full() string {
|
||||||
return version
|
return version
|
||||||
@ -54,8 +54,8 @@ func Minor(v string) int64 {
|
|||||||
|
|
||||||
// add every case there if server will not accept client's protocol and return false
|
// add every case there if server will not accept client's protocol and return false
|
||||||
func Compat(client string) (ok bool, msg string) {
|
func Compat(client string) (ok bool, msg string) {
|
||||||
if LessThan(client, version) {
|
if LessThan(client, "0.10.0") {
|
||||||
return false, "Please upgrade your frpc version to 0.10.0"
|
return false, "Please upgrade your frpc version to at least 0.10.0"
|
||||||
}
|
}
|
||||||
return true, ""
|
return true, ""
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user