From 35ff8da689db2194b3de66969f90a07e2150e71e Mon Sep 17 00:00:00 2001 From: Jim Ma Date: Thu, 1 Jul 2021 14:31:53 +0800 Subject: [PATCH] fix: update mapsturcture decode and remove unused config (#396) Signed-off-by: Jim Ma --- build/package/nfpm/config/dfget.yaml | 7 ------- client/config/peerhost.go | 16 ++++++++-------- client/config/peerhost_test.go | 1 - client/config/testdata/config/daemon.yaml | 2 -- cmd/dependency/dependency.go | 2 +- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/build/package/nfpm/config/dfget.yaml b/build/package/nfpm/config/dfget.yaml index b2d16108f..ad2f1759f 100644 --- a/build/package/nfpm/config/dfget.yaml +++ b/build/package/nfpm/config/dfget.yaml @@ -4,13 +4,6 @@ aliveTime: 0s # daemon gc task running interval gcInterval: 1m0s -# daemon pid location -pid_file: /var/run/dfdaemon.pid - -# daemon lock file location -# some lock file will only allow to run one daemon service -lock_file: /var/run/dfdaemon.lock - # daemon data directory dataDir: /home/t4/dragonfly/ diff --git a/client/config/peerhost.go b/client/config/peerhost.go index 206e7f027..31166e552 100644 --- a/client/config/peerhost.go +++ b/client/config/peerhost.go @@ -231,14 +231,14 @@ func (p *ProxyOption) UnmarshalYAML(node *yaml.Node) error { func (p *ProxyOption) unmarshal(unmarshal func(in []byte, out interface{}) (err error), b []byte) error { pt := struct { - ListenOption `yaml:",inline"` - DefaultFilter string `json:"defaultFilter" yaml:"defaultFilter"` - MaxConcurrency int64 `json:"maxConcurrency" yaml:"maxConcurrency"` - RegistryMirror *RegistryMirror `json:"registryMirror" yaml:"registryMirror"` - Proxies []*Proxy `json:"proxies" yaml:"proxies"` - HijackHTTPS *HijackConfig `json:"hijackHTTPS" yaml:"hijackHTTPS"` - WhiteList []*WhiteList `json:"whiteList" yaml:"whiteList"` - BasicAuth *BasicAuth `json:"basicAuth" yaml:"basicAuth"` + ListenOption `mapstructure:",squash" yaml:",inline"` + BasicAuth *BasicAuth `mapstructure:"basicAuth" yaml:"basicAuth"` + DefaultFilter string `mapstructure:"defaultFilter" yaml:"defaultFilter"` + MaxConcurrency int64 `mapstructure:"maxConcurrency" yaml:"maxConcurrency"` + RegistryMirror *RegistryMirror `mapstructure:"registryMirror" yaml:"registryMirror"` + WhiteList []*WhiteList `mapstructure:"whiteList" yaml:"whiteList"` + Proxies []*Proxy `mapstructure:"proxies" yaml:"proxies"` + HijackHTTPS *HijackConfig `mapstructure:"hijackHTTPS" yaml:"hijackHTTPS"` }{} if err := unmarshal(b, &pt); err != nil { diff --git a/client/config/peerhost_test.go b/client/config/peerhost_test.go index 1de5c87a4..b22a24f7f 100644 --- a/client/config/peerhost_test.go +++ b/client/config/peerhost_test.go @@ -361,5 +361,4 @@ func TestPeerHostOption_Load(t *testing.T) { } assert.EqualValues(peerHostOption, peerHostOptionYAML) - } diff --git a/client/config/testdata/config/daemon.yaml b/client/config/testdata/config/daemon.yaml index e724c2e0f..6194f7ffb 100644 --- a/client/config/testdata/config/daemon.yaml +++ b/client/config/testdata/config/daemon.yaml @@ -1,7 +1,5 @@ aliveTime: 0s gcInterval: 1m0s -pid_file: /tmp/dfdaemon.pid -lock_file: /tmp/dfdaemon.lock dataDir: /tmp/dragonfly/dfdaemon/ workHome: /tmp/dragonfly/dfdaemon/ keepStorage: false diff --git a/cmd/dependency/dependency.go b/cmd/dependency/dependency.go index 9c4858df9..6d3edfffc 100644 --- a/cmd/dependency/dependency.go +++ b/cmd/dependency/dependency.go @@ -195,7 +195,7 @@ func initDecoderConfig(dc *mapstructure.DecoderConfig) { reflect.TypeOf(dfnet.NetAddr{}), reflect.TypeOf(clientutil.RateLimit{}), reflect.TypeOf(clientutil.Duration{}), - reflect.TypeOf(config.ProxyOption{}), + reflect.TypeOf(&config.ProxyOption{}), reflect.TypeOf(config.TCPListenPortRange{}), reflect.TypeOf(config.FileString("")), reflect.TypeOf(config.URL{}),