v2fly/features/outbound/outbound.go

46 lines
1.2 KiB
Go
Raw Normal View History

package outbound
import (
"context"
"v2ray.com/core/common"
"v2ray.com/core/features"
2018-11-03 11:36:29 +00:00
"v2ray.com/core/transport"
)
// Handler is the interface for handlers that process outbound connections.
2018-12-03 21:44:42 +00:00
//
// v2ray:api:stable
type Handler interface {
common.Runnable
Tag() string
2018-11-03 11:36:29 +00:00
Dispatch(ctx context.Context, link *transport.Link)
}
2018-11-07 20:08:20 +00:00
type HandlerSelector interface {
Select([]string) []string
}
2018-10-12 21:57:56 +00:00
// Manager is a feature that manages outbound.Handlers.
2018-12-03 21:44:42 +00:00
//
// v2ray:api:stable
2018-10-12 21:57:56 +00:00
type Manager interface {
features.Feature
// GetHandler returns an outbound.Handler for the given tag.
GetHandler(tag string) Handler
// GetDefaultHandler returns the default outbound.Handler. It is usually the first outbound.Handler specified in the configuration.
GetDefaultHandler() Handler
2018-10-12 21:57:56 +00:00
// AddHandler adds a handler into this outbound.Manager.
AddHandler(ctx context.Context, handler Handler) error
2018-10-12 21:57:56 +00:00
// RemoveHandler removes a handler from outbound.Manager.
RemoveHandler(ctx context.Context, tag string) error
}
2018-10-12 21:57:56 +00:00
2018-10-13 13:15:49 +00:00
// ManagerType returns the type of Manager interface. Can be used to implement common.HasType.
2018-12-03 21:44:42 +00:00
//
// v2ray:api:stable
2018-10-12 21:57:56 +00:00
func ManagerType() interface{} {
return (*Manager)(nil)
}