You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
// +build json
|
|
|
|
|
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/v2ray/v2ray-core/proxy/internal"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
internal.RegisterInboundConfig("http", func() interface{} { return new(Config) })
|
|
|
|
}
|