mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-11-23 12:02:58 -05:00
Add subscription manager
This commit is contained in:
committed by
Xiaokang Wang (Shelikhoo)
parent
b91354901c
commit
cc77e90254
54
main/commands/all/engineering/nonnativelinkexec.go
Normal file
54
main/commands/all/engineering/nonnativelinkexec.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package engineering
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/v2fly/v2ray-core/v5/app/subscription/entries/nonnative"
|
||||
"github.com/v2fly/v2ray-core/v5/main/commands/base"
|
||||
)
|
||||
|
||||
var cmdNonNativeLinkExecInputName *string
|
||||
|
||||
var cmdNonNativeLinkExecTemplatePath *string
|
||||
|
||||
var cmdNonNativeLinkExec = &base.Command{
|
||||
UsageLine: "{{.Exec}} engineering nonnativelinkexec",
|
||||
Flag: func() flag.FlagSet {
|
||||
fs := flag.NewFlagSet("", flag.ExitOnError)
|
||||
cmdNonNativeLinkExecInputName = fs.String("name", "", "")
|
||||
cmdNonNativeLinkExecTemplatePath = fs.String("templatePath", "", "path for template directory (WARNING: This will not stop templates from reading file outside this directory)")
|
||||
return *fs
|
||||
}(),
|
||||
Run: func(cmd *base.Command, args []string) {
|
||||
cmd.Flag.Parse(args)
|
||||
|
||||
content, err := io.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
base.Fatalf("%s", err)
|
||||
}
|
||||
flattenedLink := nonnative.ExtractAllValuesFromBytes(content)
|
||||
|
||||
matcher := nonnative.NewDefMatcher()
|
||||
if *cmdNonNativeLinkExecTemplatePath != "" {
|
||||
osFs := os.DirFS(*cmdNonNativeLinkExecTemplatePath)
|
||||
err = matcher.LoadDefinitions(osFs)
|
||||
if err != nil {
|
||||
base.Fatalf("%s", err)
|
||||
}
|
||||
} else {
|
||||
err = matcher.LoadEmbeddedDefinitions()
|
||||
if err != nil {
|
||||
base.Fatalf("%s", err)
|
||||
}
|
||||
}
|
||||
|
||||
spec, err := matcher.ExecuteNamed(flattenedLink, *cmdNonNativeLinkExecInputName)
|
||||
if err != nil {
|
||||
base.Fatalf("%s", err)
|
||||
}
|
||||
io.Copy(os.Stdout, bytes.NewReader(spec))
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user