diff --git a/experimental/libbox/config.go b/experimental/libbox/config.go index 08aa8ff0..a3f47f5e 100644 --- a/experimental/libbox/config.go +++ b/experimental/libbox/config.go @@ -6,6 +6,7 @@ import ( "net/netip" "os" "reflect" + "slices" box "github.com/sagernet/sing-box" "github.com/sagernet/sing-box/adapter" @@ -269,3 +270,13 @@ func FormatConfig(configContent string) (*StringBox, error) { } return wrapString(buffer.String()), nil } + +func HasTunInbound(configContent string) (bool, error) { + options, err := parseConfig(baseContext(nil), configContent) + if err != nil { + return false, err + } + return slices.ContainsFunc(options.Inbounds, func(inbound option.Inbound) bool { + return inbound.Type == C.TypeTun + }), nil +}