You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.0 KiB

package routing
import (
"v2ray.com/core/common"
"v2ray.com/core/features"
)
// Router is a feature to choose an outbound tag for the given request.
6 years ago
//
// v2ray:api:beta
type Router interface {
features.Feature
// PickRoute returns a tag of an OutboundHandler based on the given context.
PickRoute(ctx Context) (string, error)
}
// RouterType return the type of Router interface. Can be used to implement common.HasType.
6 years ago
//
// v2ray:api:stable
func RouterType() interface{} {
return (*Router)(nil)
}
6 years ago
// DefaultRouter is an implementation of Router, which always returns ErrNoClue for routing decisions.
type DefaultRouter struct{}
6 years ago
// Type implements common.HasType.
func (DefaultRouter) Type() interface{} {
return RouterType()
}
6 years ago
// PickRoute implements Router.
func (DefaultRouter) PickRoute(ctx Context) (string, error) {
return "", common.ErrNoClue
}
6 years ago
// Start implements common.Runnable.
func (DefaultRouter) Start() error {
return nil
}
6 years ago
// Close implements common.Closable.
func (DefaultRouter) Close() error {
return nil
}