mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-02-20 23:47:21 -05:00
configurable read and write buffer size
This commit is contained in:
parent
b6a6c154a3
commit
f6d4e599bd
@ -49,8 +49,8 @@ func DefaultConfig() Config {
|
|||||||
UplinkCapacity: 5,
|
UplinkCapacity: 5,
|
||||||
DownlinkCapacity: 20,
|
DownlinkCapacity: 20,
|
||||||
Congestion: false,
|
Congestion: false,
|
||||||
WriteBuffer: 4 * 1024 * 1024,
|
WriteBuffer: 1 * 1024 * 1024,
|
||||||
ReadBuffer: 4 * 1024 * 1024,
|
ReadBuffer: 1 * 1024 * 1024,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
|||||||
UpCap *uint32 `json:"uplinkCapacity"`
|
UpCap *uint32 `json:"uplinkCapacity"`
|
||||||
DownCap *uint32 `json:"downlinkCapacity"`
|
DownCap *uint32 `json:"downlinkCapacity"`
|
||||||
Congestion *bool `json:"congestion"`
|
Congestion *bool `json:"congestion"`
|
||||||
|
ReadBufferSize *uint32 `json:"readBufferSize"`
|
||||||
|
WriteBufferSize *uint32 `json:"writeBufferSize"`
|
||||||
}
|
}
|
||||||
jsonConfig := new(JSONConfig)
|
jsonConfig := new(JSONConfig)
|
||||||
if err := json.Unmarshal(data, &jsonConfig); err != nil {
|
if err := json.Unmarshal(data, &jsonConfig); err != nil {
|
||||||
@ -46,6 +48,22 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
|||||||
if jsonConfig.Congestion != nil {
|
if jsonConfig.Congestion != nil {
|
||||||
this.Congestion = *jsonConfig.Congestion
|
this.Congestion = *jsonConfig.Congestion
|
||||||
}
|
}
|
||||||
|
if jsonConfig.ReadBufferSize != nil {
|
||||||
|
size := *jsonConfig.ReadBufferSize
|
||||||
|
if size > 0 {
|
||||||
|
this.ReadBuffer = size * 1024 * 1024
|
||||||
|
} else {
|
||||||
|
this.ReadBuffer = 512 * 1024
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if jsonConfig.WriteBufferSize != nil {
|
||||||
|
size := *jsonConfig.WriteBufferSize
|
||||||
|
if size > 0 {
|
||||||
|
this.WriteBuffer = size * 1024 * 1024
|
||||||
|
} else {
|
||||||
|
this.WriteBuffer = 512 * 1024
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user