remove plugin support as it is not practical

This commit is contained in:
Darien Raymond 2018-12-07 09:50:11 +01:00
parent 146b4eef0e
commit 769eeb0efd
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
4 changed files with 0 additions and 79 deletions

View File

@ -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())

View File

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

View File

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

View File

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