diff --git a/cmd/dfdaemon/app/root.go b/cmd/dfdaemon/app/root.go index eeb123d45..534526b4a 100644 --- a/cmd/dfdaemon/app/root.go +++ b/cmd/dfdaemon/app/root.go @@ -95,7 +95,7 @@ func init() { rf.String("localrepo", filepath.Join(os.Getenv("HOME"), ".small-dragonfly/dfdaemon/data/"), "temp output dir of dfdaemon") rf.String("dfpath", defaultDfgetPath, "dfget path") rf.Var(netutils.NetLimit(), "ratelimit", "net speed limit") - rf.StringSlice("node", []string{"127.0.0.1:8002"}, "specify the addresses(host:port) of supernodes that will be passed to dfget.") + rf.StringSlice("node", nil, "specify the addresses(host:port) of supernodes that will be passed to dfget.") exitOnError(bindRootFlags(viper.GetViper()), "bind root command flags") } diff --git a/cmd/dfdaemon/app/root_test.go b/cmd/dfdaemon/app/root_test.go index df7a5e719..e3b2e33f6 100644 --- a/cmd/dfdaemon/app/root_test.go +++ b/cmd/dfdaemon/app/root_test.go @@ -76,7 +76,7 @@ func (ts *rootTestSuite) TestNodeFlag() { r.Equal([]string{"127.0.0.1:6666"}, cfg.SuperNodes) } - // flag not set, config file doesn't exist, should use default + // flag not set, config file doesn't exist, should be nil { v := viper.New() v.SetFs(fs) @@ -86,7 +86,7 @@ func (ts *rootTestSuite) TestNodeFlag() { r.NotNil(readConfigFile(v, rootCmd)) cfg, err := getConfigFromViper(rootCmd, v) r.Nil(err) - r.Equal([]string{"127.0.0.1:8002"}, cfg.SuperNodes) + r.EqualValues([]string(nil), cfg.SuperNodes) } // when --node flag is set, should always use the flag diff --git a/dfdaemon/downloader/dfget/dfget.go b/dfdaemon/downloader/dfget/dfget.go index a4a42a0c3..221d5eede 100644 --- a/dfdaemon/downloader/dfget/dfget.go +++ b/dfdaemon/downloader/dfget/dfget.go @@ -77,7 +77,9 @@ func (dfGetter *DFGetter) getCommand( } add("-s", dfGetter.config.RateLimit) add("--totallimit", dfGetter.config.RateLimit) - add("--node", strings.Join(dfGetter.config.SuperNodes, ",")) + if len(dfGetter.config.SuperNodes) > 0 { + add("--node", strings.Join(dfGetter.config.SuperNodes, ",")) + } for key, value := range header { // discard HTTP host header for backing to source successfully