mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 15:36:41 -05:00
remove unused pkg
This commit is contained in:
parent
1e76123a4c
commit
61e95e06c0
@ -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{}))
|
|
||||||
}
|
|
@ -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{})
|
|
||||||
}
|
|
@ -13,26 +13,27 @@ import (
|
|||||||
"v2ray.com/core/infra/conf/serial"
|
"v2ray.com/core/infra/conf/serial"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MconfigCommand struct{}
|
type ConfigCommand struct{}
|
||||||
|
|
||||||
func (c *MconfigCommand) Name() string {
|
func (c *ConfigCommand) Name() string {
|
||||||
return "config"
|
return "config"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *MconfigCommand) Description() Description {
|
func (c *ConfigCommand) Description() Description {
|
||||||
return Description{
|
return Description{
|
||||||
Short: "merge multiple json config",
|
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 {
|
if len(args) < 1 {
|
||||||
return newError("empty config list")
|
return newError("empty config list")
|
||||||
}
|
}
|
||||||
|
|
||||||
conf := &conf.Config{}
|
conf := &conf.Config{}
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
|
newError("Reading config: ", arg).AtInfo().WriteToLog()
|
||||||
r, err := c.LoadArg(arg)
|
r, err := c.LoadArg(arg)
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
c, err := serial.DecodeJSONConfig(r)
|
c, err := serial.DecodeJSONConfig(r)
|
||||||
@ -57,7 +58,7 @@ func (c *MconfigCommand) Execute(args []string) error {
|
|||||||
return nil
|
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
|
var data []byte
|
||||||
if strings.HasPrefix(arg, "http://") || strings.HasPrefix(arg, "https://") {
|
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() {
|
func init() {
|
||||||
common.Must(RegisterCommand(&MconfigCommand{}))
|
common.Must(RegisterCommand(&ConfigCommand{}))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user