script.go 534 B

1234567891011121314151617181920
  1. package script
  2. import (
  3. "context"
  4. "github.com/sagernet/sing-box/adapter"
  5. C "github.com/sagernet/sing-box/constant"
  6. "github.com/sagernet/sing-box/option"
  7. E "github.com/sagernet/sing/common/exceptions"
  8. "github.com/sagernet/sing/common/logger"
  9. )
  10. func NewScript(ctx context.Context, logger logger.ContextLogger, options option.Script) (adapter.Script, error) {
  11. switch options.Type {
  12. case C.ScriptTypeSurge:
  13. return NewSurgeScript(ctx, logger, options)
  14. default:
  15. return nil, E.New("unknown script type: ", options.Type)
  16. }
  17. }