From 61e95e06c0cfd89eda1756f34e3b90fc327b65e7 Mon Sep 17 00:00:00 2001 From: vcptr <51714622+vcptr@users.noreply.github.com> Date: Sat, 14 Dec 2019 22:25:52 +0800 Subject: [PATCH] remove unused pkg --- infra/conf/command/command.go | 48 -------------------------- infra/conf/command/errors.generated.go | 9 ----- infra/control/config.go | 15 ++++---- 3 files changed, 8 insertions(+), 64 deletions(-) delete mode 100644 infra/conf/command/command.go delete mode 100644 infra/conf/command/errors.generated.go diff --git a/infra/conf/command/command.go b/infra/conf/command/command.go deleted file mode 100644 index 9f8c12d56..000000000 --- a/infra/conf/command/command.go +++ /dev/null @@ -1,48 +0,0 @@ -package command - -//go:generate errorgen - -import ( - "os" - - "github.com/golang/protobuf/proto" - "v2ray.com/core/common" - "v2ray.com/core/infra/conf/serial" - "v2ray.com/core/infra/control" -) - -type ConfigCommand struct{} - -func (c *ConfigCommand) Name() string { - return "config" -} - -func (c *ConfigCommand) Description() control.Description { - return control.Description{ - Short: "Convert config among different formats.", - Usage: []string{ - "v2ctl config", - }, - } -} - -func (c *ConfigCommand) Execute(args []string) error { - pbConfig, err := serial.LoadJSONConfig(os.Stdin) - if err != nil { - return newError("failed to parse json config").Base(err) - } - - bytesConfig, err := proto.Marshal(pbConfig) - if err != nil { - return newError("failed to marshal proto config").Base(err) - } - - if _, err := os.Stdout.Write(bytesConfig); err != nil { - return newError("failed to write proto config").Base(err) - } - return nil -} - -func init() { - common.Must(control.RegisterCommand(&ConfigCommand{})) -} diff --git a/infra/conf/command/errors.generated.go b/infra/conf/command/errors.generated.go deleted file mode 100644 index 66f780510..000000000 --- a/infra/conf/command/errors.generated.go +++ /dev/null @@ -1,9 +0,0 @@ -package command - -import "v2ray.com/core/common/errors" - -type errPathObjHolder struct{} - -func newError(values ...interface{}) *errors.Error { - return errors.New(values...).WithPathObj(errPathObjHolder{}) -} diff --git a/infra/control/config.go b/infra/control/config.go index aa6d142ab..cc2c98601 100644 --- a/infra/control/config.go +++ b/infra/control/config.go @@ -13,26 +13,27 @@ import ( "v2ray.com/core/infra/conf/serial" ) -type MconfigCommand struct{} +type ConfigCommand struct{} -func (c *MconfigCommand) Name() string { +func (c *ConfigCommand) Name() string { return "config" } -func (c *MconfigCommand) Description() Description { +func (c *ConfigCommand) Description() Description { return Description{ Short: "merge multiple json config", - Usage: []string{"v2ctl mconfig 1.json 2.json .json"}, + Usage: []string{"v2ctl config config.json c1.json c2.json .json"}, } } -func (c *MconfigCommand) Execute(args []string) error { +func (c *ConfigCommand) Execute(args []string) error { if len(args) < 1 { return newError("empty config list") } conf := &conf.Config{} for _, arg := range args { + newError("Reading config: ", arg).AtInfo().WriteToLog() r, err := c.LoadArg(arg) common.Must(err) c, err := serial.DecodeJSONConfig(r) @@ -57,7 +58,7 @@ func (c *MconfigCommand) Execute(args []string) error { return nil } -func (c *MconfigCommand) LoadArg(arg string) (out io.Reader, err error) { +func (c *ConfigCommand) LoadArg(arg string) (out io.Reader, err error) { var data []byte if strings.HasPrefix(arg, "http://") || strings.HasPrefix(arg, "https://") { @@ -74,5 +75,5 @@ func (c *MconfigCommand) LoadArg(arg string) (out io.Reader, err error) { } func init() { - common.Must(RegisterCommand(&MconfigCommand{})) + common.Must(RegisterCommand(&ConfigCommand{})) }