Browse Source

remove plugin support as it is not practical

Darien Raymond 7 years ago
parent
commit
769eeb0efd
4 changed files with 0 additions and 79 deletions
  1. 0 8
      main/main.go
  2. 0 18
      plugin.go
  3. 0 46
      plugin_linux.go
  4. 0 7
      plugin_other.go

+ 0 - 8
main/main.go

@@ -23,7 +23,6 @@ var (
 	version    = flag.Bool("version", false, "Show current version of V2Ray.")
 	version    = flag.Bool("version", false, "Show current version of V2Ray.")
 	test       = flag.Bool("test", false, "Test config file only, without launching V2Ray server.")
 	test       = flag.Bool("test", false, "Test config file only, without launching V2Ray server.")
 	format     = flag.String("format", "json", "Format of input file.")
 	format     = flag.String("format", "json", "Format of input file.")
-	plugin     = flag.Bool("plugin", false, "True to load plugins.")
 )
 )
 
 
 func fileExists(file string) bool {
 func fileExists(file string) bool {
@@ -96,13 +95,6 @@ func main() {
 		return
 		return
 	}
 	}
 
 
-	if *plugin {
-		if err := core.LoadPlugins(); err != nil {
-			fmt.Println("Failed to load plugins:", err.Error())
-			os.Exit(-1)
-		}
-	}
-
 	server, err := startV2Ray()
 	server, err := startV2Ray()
 	if err != nil {
 	if err != nil {
 		fmt.Println(err.Error())
 		fmt.Println(err.Error())

+ 0 - 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()
-}

+ 0 - 46
plugin_linux.go

@@ -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
-}

+ 0 - 7
plugin_other.go

@@ -1,7 +0,0 @@
-// +build !linux
-
-package core
-
-func loadPluginsInternal() error {
-	return nil
-}