github.com/imannamdari/v2ray-core/v5@v5.0.5/features/outbound/outbound.go (about)

     1  package outbound
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/imannamdari/v2ray-core/v5/common"
     7  	"github.com/imannamdari/v2ray-core/v5/features"
     8  	"github.com/imannamdari/v2ray-core/v5/transport"
     9  )
    10  
    11  // Handler is the interface for handlers that process outbound connections.
    12  //
    13  // v2ray:api:stable
    14  type Handler interface {
    15  	common.Runnable
    16  	Tag() string
    17  	Dispatch(ctx context.Context, link *transport.Link)
    18  }
    19  
    20  type HandlerSelector interface {
    21  	Select([]string) []string
    22  }
    23  
    24  // Manager is a feature that manages outbound.Handlers.
    25  //
    26  // v2ray:api:stable
    27  type Manager interface {
    28  	features.Feature
    29  	// GetHandler returns an outbound.Handler for the given tag.
    30  	GetHandler(tag string) Handler
    31  	// GetDefaultHandler returns the default outbound.Handler. It is usually the first outbound.Handler specified in the configuration.
    32  	GetDefaultHandler() Handler
    33  	// AddHandler adds a handler into this outbound.Manager.
    34  	AddHandler(ctx context.Context, handler Handler) error
    35  
    36  	// RemoveHandler removes a handler from outbound.Manager.
    37  	RemoveHandler(ctx context.Context, tag string) error
    38  }
    39  
    40  // ManagerType returns the type of Manager interface. Can be used to implement common.HasType.
    41  //
    42  // v2ray:api:stable
    43  func ManagerType() interface{} {
    44  	return (*Manager)(nil)
    45  }