mirror of https://github.com/v2ray/v2ray-core
add comments to new added code
parent
f54bbb903d
commit
a36631357c
|
@ -2,12 +2,14 @@ package cmdarg
|
||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
|
// Arg is used by flag to accept multiple argument.
|
||||||
type Arg []string
|
type Arg []string
|
||||||
|
|
||||||
func (c *Arg) String() string {
|
func (c *Arg) String() string {
|
||||||
return strings.Join([]string(*c), " ")
|
return strings.Join([]string(*c), " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set is the method flag package calls
|
||||||
func (c *Arg) Set(value string) error {
|
func (c *Arg) Set(value string) error {
|
||||||
*c = append(*c, value)
|
*c = append(*c, value)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -38,6 +38,8 @@ func findOffset(b []byte, o int) *offset {
|
||||||
return &offset{line: line, char: char}
|
return &offset{line: line, char: char}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DecodeJSONConfig reads from reader and decode the config into *conf.Config
|
||||||
|
// syntax error could be detected.
|
||||||
func DecodeJSONConfig(reader io.Reader) (*conf.Config, error) {
|
func DecodeJSONConfig(reader io.Reader) (*conf.Config, error) {
|
||||||
jsonConfig := &conf.Config{}
|
jsonConfig := &conf.Config{}
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,15 @@ import (
|
||||||
"v2ray.com/core/infra/conf/serial"
|
"v2ray.com/core/infra/conf/serial"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ConfigCommand is the json to pb convert struct
|
||||||
type ConfigCommand struct{}
|
type ConfigCommand struct{}
|
||||||
|
|
||||||
|
// Name for cmd usage
|
||||||
func (c *ConfigCommand) Name() string {
|
func (c *ConfigCommand) Name() string {
|
||||||
return "config"
|
return "config"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Description for help usage
|
||||||
func (c *ConfigCommand) Description() Description {
|
func (c *ConfigCommand) Description() Description {
|
||||||
return Description{
|
return Description{
|
||||||
Short: "merge multiple json config",
|
Short: "merge multiple json config",
|
||||||
|
@ -26,6 +29,7 @@ func (c *ConfigCommand) Description() Description {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Execute real work here.
|
||||||
func (c *ConfigCommand) 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")
|
||||||
|
@ -58,6 +62,7 @@ func (c *ConfigCommand) Execute(args []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadArg loads one arg, maybe an remote url, or local file path
|
||||||
func (c *ConfigCommand) 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
|
||||||
|
|
|
@ -37,6 +37,7 @@ func (c *FetchCommand) Execute(args []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FetchHTTPContent dials https for remote content
|
||||||
func FetchHTTPContent(target string) ([]byte, error) {
|
func FetchHTTPContent(target string) ([]byte, error) {
|
||||||
|
|
||||||
parsedTarget, err := url.Parse(target)
|
parsedTarget, err := url.Parse(target)
|
||||||
|
|
Loading…
Reference in New Issue