1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-09 11:46:42 -05:00

allow customized timeout in socks protocol

This commit is contained in:
v2ray 2016-07-11 15:46:18 +02:00
parent 96c6012013
commit 566adec285
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 7 additions and 1 deletions

View File

@ -14,6 +14,7 @@ type Config struct {
Accounts map[string]string
Address v2net.Address
UDPEnabled bool
Timeout int
}
func (this *Config) HasAccount(username, password string) bool {

View File

@ -27,6 +27,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
Accounts []*SocksAccount `json:"accounts"`
UDP bool `json:"udp"`
Host *v2net.AddressJson `json:"ip"`
Timeout int `json:"timeout"`
}
rawConfig := new(SocksConfig)
@ -55,6 +56,10 @@ func (this *Config) UnmarshalJSON(data []byte) error {
} else {
this.Address = v2net.LocalHostIP
}
if rawConfig.Timeout >= 0 {
this.Timeout = rawConfig.Timeout
}
return nil
}

View File

@ -96,7 +96,7 @@ func (this *Server) Start() error {
func (this *Server) handleConnection(connection internet.Connection) {
defer connection.Close()
timedReader := v2net.NewTimeOutReader(120, connection)
timedReader := v2net.NewTimeOutReader(this.config.Timeout, connection)
reader := v2io.NewBufferedReader(timedReader)
defer reader.Release()