2018-10-11 14:43:37 -04:00
|
|
|
package outbound
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"v2ray.com/core/common"
|
|
|
|
"v2ray.com/core/features"
|
2018-11-03 07:36:29 -04:00
|
|
|
"v2ray.com/core/transport"
|
2018-10-11 14:43:37 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// Handler is the interface for handlers that process outbound connections.
|
|
|
|
type Handler interface {
|
|
|
|
common.Runnable
|
|
|
|
Tag() string
|
2018-11-03 07:36:29 -04:00
|
|
|
Dispatch(ctx context.Context, link *transport.Link)
|
2018-10-11 14:43:37 -04:00
|
|
|
}
|
|
|
|
|
2018-11-07 15:08:20 -05:00
|
|
|
type HandlerSelector interface {
|
|
|
|
Select([]string) []string
|
|
|
|
}
|
|
|
|
|
2018-10-12 17:57:56 -04:00
|
|
|
// Manager is a feature that manages outbound.Handlers.
|
|
|
|
type Manager interface {
|
2018-10-11 14:43:37 -04:00
|
|
|
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 17:57:56 -04:00
|
|
|
// AddHandler adds a handler into this outbound.Manager.
|
2018-10-11 14:43:37 -04:00
|
|
|
AddHandler(ctx context.Context, handler Handler) error
|
|
|
|
|
2018-10-12 17:57:56 -04:00
|
|
|
// RemoveHandler removes a handler from outbound.Manager.
|
2018-10-11 14:43:37 -04:00
|
|
|
RemoveHandler(ctx context.Context, tag string) error
|
|
|
|
}
|
2018-10-12 17:57:56 -04:00
|
|
|
|
2018-10-13 09:15:49 -04:00
|
|
|
// ManagerType returns the type of Manager interface. Can be used to implement common.HasType.
|
2018-10-12 17:57:56 -04:00
|
|
|
func ManagerType() interface{} {
|
|
|
|
return (*Manager)(nil)
|
|
|
|
}
|