add reload and plugin support for hop

This commit is contained in:
ginuerzh
2023-09-28 21:04:15 +08:00
parent ddc3c9392e
commit ea585fc25d
88 changed files with 2208 additions and 1538 deletions

View File

@ -4,6 +4,7 @@ import (
"context"
"github.com/go-gost/core/chain"
"github.com/go-gost/core/hop"
"github.com/go-gost/core/logger"
"github.com/go-gost/core/metadata"
"github.com/go-gost/core/selector"
@ -38,7 +39,7 @@ type chainNamer interface {
type Chain struct {
name string
hops []chain.Hop
hops []hop.Hop
marker selector.Marker
metadata metadata.Metadata
logger logger.Logger
@ -60,7 +61,7 @@ func NewChain(name string, opts ...ChainOption) *Chain {
}
}
func (c *Chain) AddHop(hop chain.Hop) {
func (c *Chain) AddHop(hop hop.Hop) {
c.hops = append(c.hops, hop)
}
@ -84,8 +85,8 @@ func (c *Chain) Route(ctx context.Context, network, address string) chain.Route
}
rt := NewRoute(ChainRouteOption(c))
for _, hop := range c.hops {
node := hop.Select(ctx, chain.AddrSelectOption(address))
for _, h := range c.hops {
node := h.Select(ctx, hop.AddrSelectOption(address))
if node == nil {
return rt
}