2016-01-15 11:43:06 +00:00
|
|
|
// +build json
|
|
|
|
|
|
|
|
package freedom
|
|
|
|
|
|
|
|
import (
|
2016-05-22 20:30:21 +00:00
|
|
|
"encoding/json"
|
2016-05-24 20:41:51 +00:00
|
|
|
"strings"
|
2016-05-22 20:30:21 +00:00
|
|
|
|
2016-01-15 11:43:06 +00:00
|
|
|
"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-24 20:41:51 +00:00
|
|
|
domainStrategy := strings.ToLower(jsonConfig.DomainStrategy)
|
|
|
|
if domainStrategy == "useip" {
|
2016-05-22 20:30:21 +00:00
|
|
|
this.DomainStrategy = DomainStrategyUseIP
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-01-15 11:43:06 +00:00
|
|
|
func init() {
|
2016-01-25 16:19:09 +00:00
|
|
|
config.RegisterOutboundConfig("freedom",
|
2016-01-15 11:43:06 +00:00
|
|
|
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
|
2016-01-15 11:43:06 +00:00
|
|
|
})
|
|
|
|
}
|