Add Surge MITM and scripts

This commit is contained in:
世界 2025-03-20 09:12:48 +08:00
parent 58fdae33bb
commit 5cca8893c9
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
85 changed files with 7422 additions and 355 deletions

22
script/script.go Normal file
View file

@ -0,0 +1,22 @@
//go:build with_script
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)
}
}