remove unused code

pull/314/head
Darien Raymond 2016-10-18 15:31:48 +02:00
parent 751a105324
commit 2320bc3304
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 4 additions and 40 deletions

View File

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

View File

@ -3,7 +3,6 @@ package internet
import ( import (
"v2ray.com/core/common" "v2ray.com/core/common"
"v2ray.com/core/common/alloc" "v2ray.com/core/common/alloc"
"v2ray.com/core/common/loader"
) )
type Authenticator interface { type Authenticator interface {
@ -18,7 +17,6 @@ type AuthenticatorFactory interface {
var ( var (
authenticatorCache = make(map[string]AuthenticatorFactory) authenticatorCache = make(map[string]AuthenticatorFactory)
configCache = loader.ConfigCreatorCache{}
) )
func RegisterAuthenticator(name string, factory AuthenticatorFactory) error { func RegisterAuthenticator(name string, factory AuthenticatorFactory) error {

View File

@ -8,15 +8,17 @@ import (
v2net "v2ray.com/core/common/net" v2net "v2ray.com/core/common/net"
) )
type ConfigCreator func() interface{}
var ( var (
globalNetworkConfigCreatorCache = make(map[v2net.Network]loader.ConfigCreator) globalNetworkConfigCreatorCache = make(map[v2net.Network]ConfigCreator)
globalNetworkSettings []*NetworkSettings globalNetworkSettings []*NetworkSettings
ErrUnconfiguredNetwork = errors.New("Network config creator not set.") 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 // TODO: check duplicate
globalNetworkConfigCreatorCache[network] = creator globalNetworkConfigCreatorCache[network] = creator
return nil return nil