mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-03 00:22:05 +00:00
json config parser
This commit is contained in:
85 files changed
+9357
-9052
No files matched your search
@@ -1,27 +0,0 @@
|
||||
// +build json
|
||||
|
||||
package freedom
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
type JsonConfig struct {
|
||||
DomainStrategy string `json:"domainStrategy"`
|
||||
Timeout uint32 `json:"timeout"`
|
||||
}
|
||||
jsonConfig := new(JsonConfig)
|
||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||
return errors.New("Freedom: Failed to parse config: " + err.Error())
|
||||
}
|
||||
this.DomainStrategy = Config_AS_IS
|
||||
domainStrategy := strings.ToLower(jsonConfig.DomainStrategy)
|
||||
if domainStrategy == "useip" || domainStrategy == "use_ip" {
|
||||
this.DomainStrategy = Config_USE_IP
|
||||
}
|
||||
this.Timeout = jsonConfig.Timeout
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user