1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-25 00:45:24 +00:00
v2fly/proxy/freedom/config_json.go

38 lines
833 B
Go
Raw Normal View History

// +build json
package freedom
import (
2016-05-22 20:30:21 +00:00
"encoding/json"
"github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/proxy/internal/config"
)
2016-05-22 20:30:21 +00:00
func (this *Config) UnmarshalJSON(data []byte) error {
type JsonConfig struct {
DomainStrategy string `json:"domainStrategy"`
}
jsonConfig := new(JsonConfig)
if err := json.Unmarshal(data, jsonConfig); err != nil {
return err
}
this.DomainStrategy = DomainStrategyAsIs
2016-05-23 18:25:24 +00:00
domainStrategy := serial.StringT(jsonConfig.DomainStrategy).ToLower()
2016-05-22 20:30:21 +00:00
if domainStrategy.String() == "useip" {
this.DomainStrategy = DomainStrategyUseIP
}
return nil
}
func init() {
config.RegisterOutboundConfig("freedom",
func(data []byte) (interface{}, error) {
2016-05-22 20:30:21 +00:00
c := new(Config)
if err := json.Unmarshal(data, c); err != nil {
return nil, err
}
return c, nil
})
}