Allow read config from stdin

This commit is contained in:
世界
2022-08-19 15:42:29 +08:00
parent d1c3dd0ee1
commit 12d7e19f32
2 changed files with 23 additions and 15 deletions

View File

@@ -2,13 +2,9 @@ package main
import (
"context"
"os"
"github.com/sagernet/sing-box"
"github.com/sagernet/sing-box/common/json"
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing-box/option"
E "github.com/sagernet/sing/common/exceptions"
"github.com/spf13/cobra"
)
@@ -30,14 +26,9 @@ func init() {
}
func check() error {
configContent, err := os.ReadFile(configPath)
options, err := readConfig()
if err != nil {
return E.Cause(err, "read config")
}
var options option.Options
err = json.Unmarshal(configContent, &options)
if err != nil {
return E.Cause(err, "decode config")
return err
}
ctx, cancel := context.WithCancel(context.Background())
_, err = box.New(ctx, options)