v2ray-core: github.com/v2ray/v2ray-core/features/policy Index | Files

package policy

import "github.com/v2ray/v2ray-core/features/policy"


Package Files

default.go policy.go

func ContextWithBufferPolicy Uses

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

func ManagerType Uses

func ManagerType() interface{}

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


type Buffer Uses

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

Buffer contains settings for internal buffer.

func BufferPolicyFromContext Uses

func BufferPolicyFromContext(ctx context.Context) Buffer

type DefaultManager Uses

type DefaultManager struct{}

DefaultManager is the implementation of the Manager.

func (DefaultManager) Close Uses

func (DefaultManager) Close() error

Close implements common.Closable.

func (DefaultManager) ForLevel Uses

func (DefaultManager) ForLevel(level uint32) Session

ForLevel implements Manager.

func (DefaultManager) ForSystem Uses

func (DefaultManager) ForSystem() System

ForSystem implements Manager.

func (DefaultManager) Start Uses

func (DefaultManager) Start() error

Start implements common.Runnable.

func (DefaultManager) Type Uses

func (DefaultManager) Type() interface{}

Type implements common.HasType.

type Manager Uses

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 Uses

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 Uses

func SessionDefault() Session

SessionDefault returns the Policy when user is not specified.

type Stats Uses

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 Uses

type System struct {
    Stats  SystemStats
    Buffer Buffer

System contains policy settings at system level.

type SystemStats Uses

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
    // Whether or not to enable stat counter for uplink traffic in outbound handlers.
    OutboundUplink bool
    // Whether or not to enable stat counter for downlink traffic in outbound handlers.
    OutboundDownlink bool

SystemStats contains stat policy settings on system level.

type Timeout Uses

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.

Package policy imports 5 packages (graph). Updated 2020-09-04. Refresh now. Tools for package owners.