diff --git a/cmd/sing-box/cmd_check.go b/cmd/sing-box/cmd_check.go index 29a3908168..765302e1b7 100644 --- a/cmd/sing-box/cmd_check.go +++ b/cmd/sing-box/cmd_check.go @@ -5,6 +5,7 @@ import ( "github.com/sagernet/sing-box" "github.com/sagernet/sing-box/log" + "github.com/sagernet/sing-box/option" "github.com/spf13/cobra" ) @@ -30,6 +31,7 @@ func check() error { if err != nil { return err } + prepareOptionsForCheck(&options) ctx, cancel := context.WithCancel(globalCtx) instance, err := box.New(box.Options{ Context: ctx, @@ -41,3 +43,9 @@ func check() error { cancel() return err } + +func prepareOptionsForCheck(options *option.Options) { + options.Log = &option.LogOptions{ + Disabled: true, + } +} diff --git a/cmd/sing-box/cmd_check_test.go b/cmd/sing-box/cmd_check_test.go new file mode 100644 index 0000000000..3449b69059 --- /dev/null +++ b/cmd/sing-box/cmd_check_test.go @@ -0,0 +1,43 @@ +package main + +import ( + "testing" + + "github.com/sagernet/sing-box/option" + + "github.com/stretchr/testify/require" +) + +func TestPrepareOptionsForCheck(t *testing.T) { + t.Parallel() + + t.Run("override existing log options", func(t *testing.T) { + t.Parallel() + + logOptions := &option.LogOptions{ + Level: "trace", + Timestamp: true, + Output: "stderr", + } + options := option.Options{ + Log: logOptions, + } + + prepareOptionsForCheck(&options) + + require.NotNil(t, options.Log) + require.True(t, options.Log.Disabled) + require.NotSame(t, logOptions, options.Log) + }) + + t.Run("set log options when absent", func(t *testing.T) { + t.Parallel() + + options := option.Options{} + + prepareOptionsForCheck(&options) + + require.NotNil(t, options.Log) + require.True(t, options.Log.Disabled) + }) +} diff --git a/docs/changelog.md b/docs/changelog.md index e51e6ed94b..71362bf5e8 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,10 @@ icon: material/alert-decagram --- +#### 1.14.0-alpha.20 + +** Fixes and improvements + #### 1.14.0-alpha.19 * Preserve comments between formatting