mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-13 21:56:59 -05:00
timeout settings in http proxy
This commit is contained in:
parent
5e7d413404
commit
30041041d3
@ -2,6 +2,7 @@ package http
|
||||
|
||||
// Config for HTTP proxy server.
|
||||
type Config struct {
|
||||
Timeout int
|
||||
}
|
||||
|
||||
// ClientConfig for HTTP proxy client.
|
||||
|
@ -12,11 +12,13 @@ import (
|
||||
// UnmarshalJSON implements json.Unmarshaler
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
type JsonConfig struct {
|
||||
Timeout int `json:"timeout"`
|
||||
}
|
||||
jsonConfig := new(JsonConfig)
|
||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||
return errors.New("HTTP: Failed to parse config: " + err.Error())
|
||||
}
|
||||
this.Timeout = jsonConfig.Timeout
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -95,7 +95,8 @@ func parseHost(rawHost string, defaultPort v2net.Port) (v2net.Destination, error
|
||||
|
||||
func (this *Server) handleConnection(conn internet.Connection) {
|
||||
defer conn.Close()
|
||||
reader := bufio.NewReader(conn)
|
||||
timedReader := v2net.NewTimeOutReader(this.config.Timeout, conn)
|
||||
reader := bufio.NewReader(timedReader)
|
||||
|
||||
request, err := http.ReadRequest(reader)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user