sing-box/script/script.go
2025-02-04 15:00:59 +08:00

20 lines
534 B
Go

package script
import (
"context"
"github.com/sagernet/sing-box/adapter"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/option"
E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/logger"
)
func NewScript(ctx context.Context, logger logger.ContextLogger, options option.Script) (adapter.Script, error) {
switch options.Type {
case C.ScriptTypeSurge:
return NewSurgeScript(ctx, logger, options)
default:
return nil, E.New("unknown script type: ", options.Type)
}
}