allow stdin as input source

This commit is contained in:
Darien Raymond committed 2016-10-03 11:18:24 +02:00
1 parent 1ee76d31fa
commit fd50e8e12b
4 files changed
+34 -17

No files matched your search

+4 -11
View File
@@ -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