Version: v4.19.1+incompatible Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2019 License: MIT Imports: 5 Imported by: 1,828




This section is empty.


This section is empty.


func ContextWithBufferPolicy

func ContextWithBufferPolicy(ctx context.Context, p Buffer) context.Context

func ManagerType

func ManagerType() interface{}

ManagerType returns the type of Manager interface. Can be used to implement common.HasType.



type Buffer

type Buffer struct {
	// Size of buffer per connection, in bytes. -1 for unlimited buffer.
	PerConnection int32

Buffer contains settings for internal buffer.

func BufferPolicyFromContext

func BufferPolicyFromContext(ctx context.Context) Buffer

type DefaultManager

type DefaultManager struct{}

DefaultManager is the implementation of the Manager.

func (DefaultManager) Close

func (DefaultManager) Close() error

Close implements common.Closable.

func (DefaultManager) ForLevel

func (DefaultManager) ForLevel(level uint32) Session

ForLevel implements Manager.

func (DefaultManager) ForSystem

func (DefaultManager) ForSystem() System

ForSystem implements Manager.

func (DefaultManager) Start

func (DefaultManager) Start() error

Start implements common.Runnable.

func (DefaultManager) Type

func (DefaultManager) Type() interface{}

Type implements common.HasType.

type Manager

type Manager interface {

	// ForLevel returns the Session policy for the given user level.
	ForLevel(level uint32) Session

	// ForSystem returns the System policy for V2Ray system.
	ForSystem() System

Manager is a feature that provides Policy for the given user by its id or level.


type Session

type Session struct {
	Timeouts Timeout // Timeout settings
	Stats    Stats
	Buffer   Buffer

Session is session based settings for controlling V2Ray requests. It contains various settings (or limits) that may differ for different users in the context.

func SessionDefault

func SessionDefault() Session

SessionDefault returns the Policy when user is not specified.

type Stats

type Stats struct {
	// Whether or not to enable stat counter for user uplink traffic.
	UserUplink bool
	// Whether or not to enable stat counter for user downlink traffic.
	UserDownlink bool

Stats contains settings for stats counters.

type System

type System struct {
	Stats  SystemStats
	Buffer Buffer

System contains policy settings at system level.

type SystemStats

type SystemStats struct {
	// Whether or not to enable stat counter for uplink traffic in inbound handlers.
	InboundUplink bool
	// Whether or not to enable stat counter for downlink traffic in inbound handlers.
	InboundDownlink bool

SystemStats contains stat policy settings on system level.

type Timeout

type Timeout struct {
	// Timeout for handshake phase in a connection.
	Handshake time.Duration
	// Timeout for connection being idle, i.e., there is no egress or ingress traffic in this connection.
	ConnectionIdle time.Duration
	// Timeout for an uplink only connection, i.e., the downlink of the connection has been closed.
	UplinkOnly time.Duration
	// Timeout for an downlink only connection, i.e., the uplink of the connection has been closed.
	DownlinkOnly time.Duration

Timeout contains limits for connection timeout.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL