1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-18 09:57:04 -04:00
v2fly/proxy/freedom/config_json.go
2016-05-24 22:41:51 +02:00

38 lines
781 B
Go

// +build json
package freedom
import (
"encoding/json"
"strings"
"github.com/v2ray/v2ray-core/proxy/internal/config"
)
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
domainStrategy := strings.ToLower(jsonConfig.DomainStrategy)
if domainStrategy == "useip" {
this.DomainStrategy = DomainStrategyUseIP
}
return nil
}
func init() {
config.RegisterOutboundConfig("freedom",
func(data []byte) (interface{}, error) {
c := new(Config)
if err := json.Unmarshal(data, c); err != nil {
return nil, err
}
return c, nil
})
}