From 769eeb0efd525459df3d8ce441d852145bd6875b Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 7 Dec 2018 09:50:11 +0100 Subject: [PATCH] remove plugin support as it is not practical --- main/main.go | 8 -------- plugin.go | 18 ------------------ plugin_linux.go | 46 ---------------------------------------------- plugin_other.go | 7 ------- 4 files changed, 79 deletions(-) delete mode 100644 plugin.go delete mode 100644 plugin_linux.go delete mode 100644 plugin_other.go diff --git a/main/main.go b/main/main.go index 2981993ba..a5d3a447d 100644 --- a/main/main.go +++ b/main/main.go @@ -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()) diff --git a/plugin.go b/plugin.go deleted file mode 100644 index 8d4388e42..000000000 --- a/plugin.go +++ /dev/null @@ -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() -} diff --git a/plugin_linux.go b/plugin_linux.go deleted file mode 100644 index a3d548c4f..000000000 --- a/plugin_linux.go +++ /dev/null @@ -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 -} diff --git a/plugin_other.go b/plugin_other.go deleted file mode 100644 index 183869a67..000000000 --- a/plugin_other.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build !linux - -package core - -func loadPluginsInternal() error { - return nil -}