From 2320bc33044d76be4fddd7e338ea91260f7b08ac Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Tue, 18 Oct 2016 15:31:48 +0200 Subject: [PATCH] remove unused code --- common/loader/loader.go | 36 ----------------------------- transport/internet/authenticator.go | 2 -- transport/internet/config.go | 6 +++-- 3 files changed, 4 insertions(+), 40 deletions(-) delete mode 100644 common/loader/loader.go diff --git a/common/loader/loader.go b/common/loader/loader.go deleted file mode 100644 index 756f033fb..000000000 --- a/common/loader/loader.go +++ /dev/null @@ -1,36 +0,0 @@ -package loader - -import ( - "errors" - "v2ray.com/core/common" -) - -var ( - ErrUnknownConfigID = errors.New("Unknown config ID.") -) - -type ConfigCreator func() interface{} - -type ConfigCreatorCache map[string]ConfigCreator - -func (this ConfigCreatorCache) RegisterCreator(id string, creator ConfigCreator) error { - if _, found := this[id]; found { - return common.ErrDuplicatedName - } - - this[id] = creator - return nil -} - -func (this ConfigCreatorCache) CreateConfig(id string) (interface{}, error) { - creator, found := this[id] - if !found { - return nil, ErrUnknownConfigID - } - return creator(), nil -} - -type ConfigLoader interface { - Load([]byte) (interface{}, string, error) - LoadWithID([]byte, string) (interface{}, error) -} diff --git a/transport/internet/authenticator.go b/transport/internet/authenticator.go index 32d3e6bcf..8bef925c6 100644 --- a/transport/internet/authenticator.go +++ b/transport/internet/authenticator.go @@ -3,7 +3,6 @@ package internet import ( "v2ray.com/core/common" "v2ray.com/core/common/alloc" - "v2ray.com/core/common/loader" ) type Authenticator interface { @@ -18,7 +17,6 @@ type AuthenticatorFactory interface { var ( authenticatorCache = make(map[string]AuthenticatorFactory) - configCache = loader.ConfigCreatorCache{} ) func RegisterAuthenticator(name string, factory AuthenticatorFactory) error { diff --git a/transport/internet/config.go b/transport/internet/config.go index bc96d6e22..b17ea8037 100644 --- a/transport/internet/config.go +++ b/transport/internet/config.go @@ -8,15 +8,17 @@ import ( v2net "v2ray.com/core/common/net" ) +type ConfigCreator func() interface{} + var ( - globalNetworkConfigCreatorCache = make(map[v2net.Network]loader.ConfigCreator) + globalNetworkConfigCreatorCache = make(map[v2net.Network]ConfigCreator) globalNetworkSettings []*NetworkSettings ErrUnconfiguredNetwork = errors.New("Network config creator not set.") ) -func RegisterNetworkConfigCreator(network v2net.Network, creator loader.ConfigCreator) error { +func RegisterNetworkConfigCreator(network v2net.Network, creator ConfigCreator) error { // TODO: check duplicate globalNetworkConfigCreatorCache[network] = creator return nil