Files
sing-box-extended-mirror/cmd/sing-box/cmd_check.go
T

38 lines
606 B
Go
Raw Normal View History

2022-07-04 16:59:27 +08:00
package main
import (
"context"
"github.com/sagernet/sing-box"
2022-07-12 15:17:29 +08:00
"github.com/sagernet/sing-box/log"
2022-07-06 15:01:09 +08:00
2022-07-04 16:59:27 +08:00
"github.com/spf13/cobra"
)
var commandCheck = &cobra.Command{
Use: "check",
2022-07-04 17:08:28 +08:00
Short: "Check configuration",
2022-08-13 18:36:49 +08:00
Run: func(cmd *cobra.Command, args []string) {
err := check()
if err != nil {
log.Fatal(err)
}
},
Args: cobra.NoArgs,
2022-07-04 16:59:27 +08:00
}
2022-08-13 18:36:49 +08:00
func init() {
mainCommand.AddCommand(commandCheck)
}
func check() error {
2022-08-19 15:42:29 +08:00
options, err := readConfig()
2022-07-04 16:59:27 +08:00
if err != nil {
2022-08-19 15:42:29 +08:00
return err
2022-07-04 16:59:27 +08:00
}
ctx, cancel := context.WithCancel(context.Background())
2023-02-28 19:02:27 +08:00
_, err = box.New(ctx, options, nil)
2022-07-04 16:59:27 +08:00
cancel()
2022-08-13 18:36:49 +08:00
return err
2022-07-04 16:59:27 +08:00
}