1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00
v2fly/features/outbound/outbound.go

46 lines
1.2 KiB
Go
Raw Normal View History

package outbound
import (
"context"
2021-02-16 15:31:50 -05:00
"github.com/v2fly/v2ray-core/v4/common"
"github.com/v2fly/v2ray-core/v4/features"
"github.com/v2fly/v2ray-core/v4/transport"
)
// Handler is the interface for handlers that process outbound connections.
2018-12-03 16:44:42 -05:00
//
// v2ray:api:stable
type Handler interface {
common.Runnable
Tag() string
2018-11-03 07:36:29 -04:00
Dispatch(ctx context.Context, link *transport.Link)
}
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 {
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.
AddHandler(ctx context.Context, handler Handler) error
2018-10-12 17:57:56 -04:00
// RemoveHandler removes a handler from outbound.Manager.
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)
}