mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-09-18 01:46:06 -04:00
remove plugin support as it is not practical
This commit is contained in:
parent
146b4eef0e
commit
769eeb0efd
@ -23,7 +23,6 @@ var (
|
||||
version = flag.Bool("version", false, "Show current version of V2Ray.")
|
||||
test = flag.Bool("test", false, "Test config file only, without launching V2Ray server.")
|
||||
format = flag.String("format", "json", "Format of input file.")
|
||||
plugin = flag.Bool("plugin", false, "True to load plugins.")
|
||||
)
|
||||
|
||||
func fileExists(file string) bool {
|
||||
@ -96,13 +95,6 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
if *plugin {
|
||||
if err := core.LoadPlugins(); err != nil {
|
||||
fmt.Println("Failed to load plugins:", err.Error())
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
|
||||
server, err := startV2Ray()
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
|
18
plugin.go
18
plugin.go
@ -1,18 +0,0 @@
|
||||
package core
|
||||
|
||||
// PluginMetadata contains some brief information regarding a plugin.
|
||||
type PluginMetadata struct {
|
||||
// Name of the plugin
|
||||
Name string
|
||||
}
|
||||
|
||||
// GetMetadataFuncName is the name of the function in the plugin to return PluginMetadata.
|
||||
const GetMetadataFuncName = "GetPluginMetadata"
|
||||
|
||||
// GetMetadataFunc is the type of the function in the plugin to return PluginMetadata.
|
||||
type GetMetadataFunc func() PluginMetadata
|
||||
|
||||
// LoadPlugins loads all possible plugins in the 'plugin' directory.
|
||||
func LoadPlugins() error {
|
||||
return loadPluginsInternal()
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
// +build linux
|
||||
|
||||
package core
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"plugin"
|
||||
"strings"
|
||||
|
||||
"v2ray.com/core/common/platform"
|
||||
)
|
||||
|
||||
func loadPluginsInternal() error {
|
||||
pluginPath := platform.GetPluginDirectory()
|
||||
|
||||
dir, err := os.Open(pluginPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer dir.Close()
|
||||
|
||||
files, err := dir.Readdir(-1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
if !file.IsDir() && strings.HasSuffix(file.Name(), ".so") {
|
||||
p, err := plugin.Open(filepath.Join(pluginPath, file.Name()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
f, err := p.Lookup(GetMetadataFuncName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if gmf, ok := f.(GetMetadataFunc); ok {
|
||||
metadata := gmf()
|
||||
newError("plugin (", metadata.Name, ") loaded.").WriteToLog()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
// +build !linux
|
||||
|
||||
package core
|
||||
|
||||
func loadPluginsInternal() error {
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user