github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/features/inbound/inbound.go (about)

     1  package inbound
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/v2fly/v2ray-core/v5/common"
     7  	"github.com/v2fly/v2ray-core/v5/common/net"
     8  	"github.com/v2fly/v2ray-core/v5/features"
     9  )
    10  
    11  // Handler is the interface for handlers that process inbound connections.
    12  //
    13  // v2ray:api:stable
    14  type Handler interface {
    15  	common.Runnable
    16  	// The tag of this handler.
    17  	Tag() string
    18  
    19  	// Deprecated: Do not use in new code.
    20  	GetRandomInboundProxy() (interface{}, net.Port, int)
    21  }
    22  
    23  // Manager is a feature that manages InboundHandlers.
    24  //
    25  // v2ray:api:stable
    26  type Manager interface {
    27  	features.Feature
    28  	// GetHandlers returns an InboundHandler for the given tag.
    29  	GetHandler(ctx context.Context, tag string) (Handler, error)
    30  	// AddHandler adds the given handler into this Manager.
    31  	AddHandler(ctx context.Context, handler Handler) error
    32  
    33  	// RemoveHandler removes a handler from Manager.
    34  	RemoveHandler(ctx context.Context, tag string) error
    35  }
    36  
    37  // ManagerType returns the type of Manager interface. Can be used for implementing common.HasType.
    38  //
    39  // v2ray:api:stable
    40  func ManagerType() interface{} {
    41  	return (*Manager)(nil)
    42  }