refcn | refen |
---|---|
chapter_02/policy |
configuration/policy |
Local policy manages settings of current V2Ray instance, such as connection timeouts. The policys can be applied to each user level, or the whole system.
Configuration:
{
"levels": {
"0": {
"handshake": 4,
"connIdle": 300,
"uplinkOnly": 2,
"downlinkOnly": 5,
"statsUserUplink": false,
"statsUserDownlink": false
}
},
"system": {
"statsInboundUplink": false,
"statsInboundDownlink": false
}
}
Where:
level
: A list of key value pairs. Each key is a string of integer (restricted by JSON), such as"0"
,"1"
, etc. The numeric value is for a certain user level. Each value has the following attributes:handshake
: Timeout for establishing a connection, in seconds. Default value4
.connIdle
: Timeout for idle connections, in seconds. Default value300
.uplinkOnly
: Time for keeping connections open after the uplink of the connection is closed, in seconds. Default value2
.downlinkOnly
: Time for keeping connections open after the downlink of the connection is closed, in seconds. Default value5
.statsUserUplink
: When set totrue
, V2Ray enables stat counter to uplink traffic for all users in this level.statsUserDownlink
: When set totrue
, V2Ray enables stat counter to downlink traffic for all users in this level.bufferSize
(V2Ray 3.24+): Size of internal buffer per connection, in kilo-bytes. Default value is10240
. When it is set to0
, the internal buffer is disabled.
system
(V2Ray 3.18+): System policy for V2RaystatsInboundUplink
(V2Ray 3.18+): When set totrue
, V2Ray enables stat counter for all uplink traffic in all inbound proxies.statsInboundDownlink
(V2Ray 3.18+): When set totrue
, V2Ray enables stat counter for all downlink traffic in all inbound proxies.
Some details when V2Ray handles connections:
- At the handshake stage of an inbound proxy dealing with a new connection, say VMess reading request header, if it takes longer than
handshake
time, V2Ray aborts the connection. - If there is no data passed through the connection in
connIdle
time, V2Ray aborts the conneciton. - After client (browser) closes the uplink of the connection, V2Ray aborts the connection after
downlinkOnly
time. - After remote (server) closes the downlink of the connection, V2Ray aborts the connection after
uplinkOnly
times.
- Each inbound and outbound connection can apply a user level. V2Ray applies corresponding policy based on user level.
bufferSize
overridesv2ray.ray.buffer.size
settings in env variables.