refactor: Modular inbounds

This commit is contained in:
世界
2024-11-03 19:46:20 +08:00
parent 0b2c7ec35c
commit 47736b27ba
90 changed files with 2353 additions and 1919 deletions

View File

@@ -29,13 +29,13 @@ type (
type Registry struct {
access sync.Mutex
optiosnType map[string]optionsConstructorFunc
optionsType map[string]optionsConstructorFunc
constructors map[string]constructorFunc
}
func NewRegistry() *Registry {
return &Registry{
optiosnType: make(map[string]optionsConstructorFunc),
optionsType: make(map[string]optionsConstructorFunc),
constructors: make(map[string]constructorFunc),
}
}
@@ -43,7 +43,7 @@ func NewRegistry() *Registry {
func (r *Registry) CreateOptions(outboundType string) (any, bool) {
r.access.Lock()
defer r.access.Unlock()
optionsConstructor, loaded := r.optiosnType[outboundType]
optionsConstructor, loaded := r.optionsType[outboundType]
if !loaded {
return nil, false
}
@@ -63,6 +63,6 @@ func (r *Registry) CreateOutbound(ctx context.Context, router adapter.Router, lo
func (r *Registry) register(outboundType string, optionsConstructor optionsConstructorFunc, constructor constructorFunc) {
r.access.Lock()
defer r.access.Unlock()
r.optiosnType[outboundType] = optionsConstructor
r.optionsType[outboundType] = optionsConstructor
r.constructors[outboundType] = constructor
}