Browse Source

remove unused pkg

vcptr 6 years ago
parent
commit
61e95e06c0
3 changed files with 8 additions and 64 deletions
  1. 0 48
      infra/conf/command/command.go
  2. 0 9
      infra/conf/command/errors.generated.go
  3. 8 7
      infra/control/config.go

+ 0 - 48
infra/conf/command/command.go

@@ -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{}))
-}

+ 0 - 9
infra/conf/command/errors.generated.go

@@ -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{})
-}

+ 8 - 7
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 <url>.json"},
+		Usage: []string{"v2ctl config config.json c1.json c2.json <url>.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{}))
 }