mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-30 23:37:44 +00:00
allow stdin as input source
This commit is contained in:
4 files changed
+34
-17
No files matched your search
@@ -5,8 +5,7 @@ package point
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"v2ray.com/core/app/dns"
|
||||
@@ -260,16 +259,10 @@ func (this *OutboundDetourConfig) UnmarshalJSON(data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func JsonLoadConfig(file string) (*Config, error) {
|
||||
fixedFile := os.ExpandEnv(file)
|
||||
rawConfig, err := ioutil.ReadFile(fixedFile)
|
||||
if err != nil {
|
||||
log.Error("Point: Failed to read server config file (", file, "): ", file, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func JsonLoadConfig(input io.Reader) (*Config, error) {
|
||||
jsonConfig := &Config{}
|
||||
err = json.Unmarshal(rawConfig, jsonConfig)
|
||||
decoder := json.NewDecoder(input)
|
||||
err := decoder.Decode(jsonConfig)
|
||||
if err != nil {
|
||||
log.Error("Point: Failed to load server config: ", err)
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user