update for strict config (#3779)

This commit is contained in:
fatedier
2023-11-16 21:03:36 +08:00
committed by GitHub
parent e8deb65c4b
commit 526e809bd5
15 changed files with 99 additions and 70 deletions

View File

@@ -30,9 +30,9 @@ import (
)
var (
cfgFile string
showVersion bool
strictConfig bool
cfgFile string
showVersion bool
strictConfigMode bool
serverCfg v1.ServerConfig
)
@@ -40,7 +40,7 @@ var (
func init() {
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file of frps")
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "v", false, "version of frps")
rootCmd.PersistentFlags().BoolVarP(&strictConfig, "strict_config", "", false, "strict config parsing mode")
rootCmd.PersistentFlags().BoolVarP(&strictConfigMode, "strict_config", "", false, "strict config parsing mode, unknown fileds will cause error")
RegisterServerConfigFlags(rootCmd, &serverCfg)
}
@@ -60,7 +60,7 @@ var rootCmd = &cobra.Command{
err error
)
if cfgFile != "" {
svrCfg, isLegacyFormat, err = config.LoadServerConfig(cfgFile, strictConfig)
svrCfg, isLegacyFormat, err = config.LoadServerConfig(cfgFile, strictConfigMode)
if err != nil {
fmt.Println(err)
os.Exit(1)

View File

@@ -36,7 +36,7 @@ var verifyCmd = &cobra.Command{
fmt.Println("frps: the configuration file is not specified")
return nil
}
svrCfg, _, err := config.LoadServerConfig(cfgFile, strictConfig)
svrCfg, _, err := config.LoadServerConfig(cfgFile, strictConfigMode)
if err != nil {
fmt.Println(err)
os.Exit(1)