2018-10-11 14:43:37 -04:00
|
|
|
package outbound
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-01-02 10:16:23 -05:00
|
|
|
"github.com/v2fly/v2ray-core/v5/common"
|
|
|
|
"github.com/v2fly/v2ray-core/v5/features"
|
|
|
|
"github.com/v2fly/v2ray-core/v5/transport"
|
2018-10-11 14:43:37 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// Handler is the interface for handlers that process outbound connections.
|
2018-12-03 16:44:42 -05:00
|
|
|
//
|
|
|
|
// v2ray:api:stable
|
2018-10-11 14:43:37 -04:00
|
|
|
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.
|
2018-12-03 16:44:42 -05:00
|
|
|
//
|
|
|
|
// v2ray:api:stable
|
2018-10-12 17:57:56 -04:00
|
|
|
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-12-03 16:44:42 -05:00
|
|
|
//
|
|
|
|
// v2ray:api:stable
|
2018-10-12 17:57:56 -04:00
|
|
|
func ManagerType() interface{} {
|
|
|
|
return (*Manager)(nil)
|
|
|
|
}
|