add reload and plugin support for hop
This commit is contained in:
@ -4,24 +4,25 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/go-gost/core/chain"
|
||||
"github.com/go-gost/core/hop"
|
||||
)
|
||||
|
||||
type hopRegistry struct {
|
||||
registry[chain.Hop]
|
||||
registry[hop.Hop]
|
||||
}
|
||||
|
||||
func (r *hopRegistry) Register(name string, v chain.Hop) error {
|
||||
func (r *hopRegistry) Register(name string, v hop.Hop) error {
|
||||
return r.registry.Register(name, v)
|
||||
}
|
||||
|
||||
func (r *hopRegistry) Get(name string) chain.Hop {
|
||||
func (r *hopRegistry) Get(name string) hop.Hop {
|
||||
if name != "" {
|
||||
return &hopWrapper{name: name, r: r}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *hopRegistry) get(name string) chain.Hop {
|
||||
func (r *hopRegistry) get(name string) hop.Hop {
|
||||
return r.registry.Get(name)
|
||||
}
|
||||
|
||||
@ -35,10 +36,13 @@ func (w *hopWrapper) Nodes() []*chain.Node {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Nodes()
|
||||
if nl, ok := v.(hop.NodeList); ok {
|
||||
return nl.Nodes()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *hopWrapper) Select(ctx context.Context, opts ...chain.SelectOption) *chain.Node {
|
||||
func (w *hopWrapper) Select(ctx context.Context, opts ...hop.SelectOption) *chain.Node {
|
||||
v := w.r.get(w.name)
|
||||
if v == nil {
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user