Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/sing-box/cmd_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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,
Expand All @@ -41,3 +43,9 @@ func check() error {
cancel()
return err
}

func prepareOptionsForCheck(options *option.Options) {
options.Log = &option.LogOptions{
Disabled: true,
}
}
43 changes: 43 additions & 0 deletions cmd/sing-box/cmd_check_test.go
Original file line number Diff line number Diff line change
@@ -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)
})
}
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down