move hop out of chain
This commit is contained in:
41
hop/hop.go
Normal file
41
hop/hop.go
Normal file
@ -0,0 +1,41 @@
|
||||
package hop
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-gost/core/chain"
|
||||
)
|
||||
|
||||
type SelectOptions struct {
|
||||
Addr string
|
||||
Host string
|
||||
Protocol string
|
||||
}
|
||||
|
||||
type SelectOption func(*SelectOptions)
|
||||
|
||||
func AddrSelectOption(addr string) SelectOption {
|
||||
return func(o *SelectOptions) {
|
||||
o.Addr = addr
|
||||
}
|
||||
}
|
||||
|
||||
func HostSelectOption(host string) SelectOption {
|
||||
return func(o *SelectOptions) {
|
||||
o.Host = host
|
||||
}
|
||||
}
|
||||
|
||||
func ProtocolSelectOption(protocol string) SelectOption {
|
||||
return func(o *SelectOptions) {
|
||||
o.Protocol = protocol
|
||||
}
|
||||
}
|
||||
|
||||
type Hop interface {
|
||||
Select(ctx context.Context, opts ...SelectOption) *chain.Node
|
||||
}
|
||||
|
||||
type NodeList interface {
|
||||
Nodes() []*chain.Node
|
||||
}
|
Reference in New Issue
Block a user