mirror of https://github.com/v2ray/v2ray-core
allow customized timeout in socks protocol
parent
96c6012013
commit
566adec285
|
@ -14,6 +14,7 @@ type Config struct {
|
||||||
Accounts map[string]string
|
Accounts map[string]string
|
||||||
Address v2net.Address
|
Address v2net.Address
|
||||||
UDPEnabled bool
|
UDPEnabled bool
|
||||||
|
Timeout int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Config) HasAccount(username, password string) bool {
|
func (this *Config) HasAccount(username, password string) bool {
|
||||||
|
|
|
@ -27,6 +27,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||||
Accounts []*SocksAccount `json:"accounts"`
|
Accounts []*SocksAccount `json:"accounts"`
|
||||||
UDP bool `json:"udp"`
|
UDP bool `json:"udp"`
|
||||||
Host *v2net.AddressJson `json:"ip"`
|
Host *v2net.AddressJson `json:"ip"`
|
||||||
|
Timeout int `json:"timeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
rawConfig := new(SocksConfig)
|
rawConfig := new(SocksConfig)
|
||||||
|
@ -55,6 +56,10 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||||
} else {
|
} else {
|
||||||
this.Address = v2net.LocalHostIP
|
this.Address = v2net.LocalHostIP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rawConfig.Timeout >= 0 {
|
||||||
|
this.Timeout = rawConfig.Timeout
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ func (this *Server) Start() error {
|
||||||
func (this *Server) handleConnection(connection internet.Connection) {
|
func (this *Server) handleConnection(connection internet.Connection) {
|
||||||
defer connection.Close()
|
defer connection.Close()
|
||||||
|
|
||||||
timedReader := v2net.NewTimeOutReader(120, connection)
|
timedReader := v2net.NewTimeOutReader(this.config.Timeout, connection)
|
||||||
reader := v2io.NewBufferedReader(timedReader)
|
reader := v2io.NewBufferedReader(timedReader)
|
||||||
defer reader.Release()
|
defer reader.Release()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue