mirror of
https://github.com/v2ray/v2ray-core.git
synced 2024-04-21 12:31:52 +00:00
revert back to multiconfig
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
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
|
||||
}
|
||||
@@ -119,6 +119,15 @@ func CreateStdoutLogWriter() WriterCreator {
|
||||
}
|
||||
}
|
||||
|
||||
// CreateStderrLogWriter returns a LogWriterCreator that creates LogWriter for stderr.
|
||||
func CreateStderrLogWriter() WriterCreator {
|
||||
return func() Writer {
|
||||
return &consoleLogWriter{
|
||||
logger: log.New(os.Stderr, "", log.Ldate|log.Ltime),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CreateFileLogWriter returns a LogWriterCreator that creates LogWriter for the given file.
|
||||
func CreateFileLogWriter(path string) (WriterCreator, error) {
|
||||
file, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/platform"
|
||||
@@ -35,10 +36,15 @@ func Run(args []string, input io.Reader) (buf.MultiBuffer, error) {
|
||||
if err := cmd.Wait(); err != nil {
|
||||
msg := "failed to execute v2ctl"
|
||||
if errBuffer.Len() > 0 {
|
||||
msg += ": " + errBuffer.MultiBuffer.String()
|
||||
msg += ": \n" + strings.TrimSpace(errBuffer.MultiBuffer.String())
|
||||
}
|
||||
return nil, newError(msg).Base(err)
|
||||
}
|
||||
|
||||
// log stderr, info message
|
||||
if !errBuffer.IsEmpty() {
|
||||
newError("<v2ctl message> \n", strings.TrimSpace(errBuffer.MultiBuffer.String())).AtInfo().WriteToLog()
|
||||
}
|
||||
|
||||
return outBuffer.MultiBuffer, nil
|
||||
}
|
||||
|
||||
@@ -83,3 +83,10 @@ func GetConfigurationPath() string {
|
||||
configPath := NewEnvFlag(name).GetValue(getExecutableDir)
|
||||
return filepath.Join(configPath, "config.json")
|
||||
}
|
||||
|
||||
// GetConfDirPath reads "v2ray.location.confdir"
|
||||
func GetConfDirPath() string {
|
||||
const name = "v2ray.location.confdir"
|
||||
configPath := NewEnvFlag(name).GetValue(func() string { return "" })
|
||||
return configPath
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user