From a36631357c47a0d5aa16a99f595cfbb9bc333a23 Mon Sep 17 00:00:00 2001 From: vcptr <51714622+vcptr@users.noreply.github.com> Date: Tue, 24 Dec 2019 01:06:01 +0800 Subject: [PATCH] add comments to new added code --- common/cmdarg/cmdarg.go | 2 ++ infra/conf/serial/loader.go | 2 ++ infra/control/config.go | 5 +++++ infra/control/fetch.go | 1 + 4 files changed, 10 insertions(+) diff --git a/common/cmdarg/cmdarg.go b/common/cmdarg/cmdarg.go index de5ed9498..f524eb37d 100644 --- a/common/cmdarg/cmdarg.go +++ b/common/cmdarg/cmdarg.go @@ -2,12 +2,14 @@ package cmdarg import "strings" +// Arg is used by flag to accept multiple argument. type Arg []string func (c *Arg) String() string { return strings.Join([]string(*c), " ") } +// Set is the method flag package calls func (c *Arg) Set(value string) error { *c = append(*c, value) return nil diff --git a/infra/conf/serial/loader.go b/infra/conf/serial/loader.go index cdff522a4..f7ecf2db1 100644 --- a/infra/conf/serial/loader.go +++ b/infra/conf/serial/loader.go @@ -38,6 +38,8 @@ func findOffset(b []byte, o int) *offset { 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) { jsonConfig := &conf.Config{} diff --git a/infra/control/config.go b/infra/control/config.go index a0f456dd5..02d7cd5dd 100644 --- a/infra/control/config.go +++ b/infra/control/config.go @@ -13,12 +13,15 @@ import ( "v2ray.com/core/infra/conf/serial" ) +// ConfigCommand is the json to pb convert struct type ConfigCommand struct{} +// Name for cmd usage func (c *ConfigCommand) Name() string { return "config" } +// Description for help usage func (c *ConfigCommand) Description() Description { return Description{ 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 { if len(args) < 1 { return newError("empty config list") @@ -58,6 +62,7 @@ func (c *ConfigCommand) Execute(args []string) error { 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) { var data []byte diff --git a/infra/control/fetch.go b/infra/control/fetch.go index 81e600954..a9deef25f 100644 --- a/infra/control/fetch.go +++ b/infra/control/fetch.go @@ -37,6 +37,7 @@ func (c *FetchCommand) Execute(args []string) error { return nil } +// FetchHTTPContent dials https for remote content func FetchHTTPContent(target string) ([]byte, error) { parsedTarget, err := url.Parse(target)