// System contains policy settings at system level.
typeSystemstruct{
StatsSystemStats
BufferBuffer
}
// Session is session based settings for controlling Xray requests. It contains various settings (or limits) that may differ for different users in the context.
typeSessionstruct{
TimeoutsTimeout// Timeout settings
StatsStats
BufferBuffer
}
// Manager is a feature that provides Policy for the given user by its id or level.
//
// xray:api:stable
typeManagerinterface{
features.Feature
// ForLevel returns the Session policy for the given user level.
ForLevel(leveluint32)Session
// ForSystem returns the System policy for Xray system.
ForSystem()System
}
// ManagerType returns the type of Manager interface. Can be used to implement common.HasType.
//
// xray:api:stable
funcManagerType()interface{}{
return(*Manager)(nil)
}
vardefaultBufferSizeint32
funcinit(){
constkey="xray.ray.buffer.size"
constdefaultValue=-17
size:=platform.EnvFlag{
Name:key,
AltName:platform.NormalizeEnvName(key),
}.GetValueAsInt(defaultValue)
switchsize{
case0:
defaultBufferSize=-1// For pipe to use unlimited size
casedefaultValue:// Env flag not defined. Use default values per CPU-arch.
switchruntime.GOARCH{
case"arm","mips","mipsle":
defaultBufferSize=0
case"arm64","mips64","mips64le":
defaultBufferSize=4*1024// 4k cache for low-end devices
default:
defaultBufferSize=512*1024
}
default:
defaultBufferSize=int32(size)*1024*1024
}
}
funcdefaultBufferPolicy()Buffer{
returnBuffer{
PerConnection:defaultBufferSize,
}
}
// SessionDefault returns the Policy when user is not specified.
funcSessionDefault()Session{
returnSession{
Timeouts:Timeout{
// Align Handshake timeout with nginx client_header_timeout
// So that this value will not indicate server identity