1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-24 08:25:23 +00:00
v2fly/tools/conf/freedom.go

25 lines
600 B
Go
Raw Normal View History

2016-10-17 12:35:13 +00:00
package conf
import (
"strings"
2016-12-15 10:51:09 +00:00
"v2ray.com/core/common/serial"
2016-10-17 12:35:13 +00:00
"v2ray.com/core/proxy/freedom"
)
type FreedomConfig struct {
DomainStrategy string `json:"domainStrategy"`
Timeout uint32 `json:"timeout"`
}
2016-12-15 10:51:09 +00:00
func (v *FreedomConfig) Build() (*serial.TypedMessage, error) {
2016-10-17 12:35:13 +00:00
config := new(freedom.Config)
config.DomainStrategy = freedom.Config_AS_IS
2016-11-27 20:39:09 +00:00
domainStrategy := strings.ToLower(v.DomainStrategy)
2016-10-17 12:35:13 +00:00
if domainStrategy == "useip" || domainStrategy == "use_ip" {
config.DomainStrategy = freedom.Config_USE_IP
}
2016-11-27 20:39:09 +00:00
config.Timeout = v.Timeout
2016-12-15 10:51:09 +00:00
return serial.ToTypedMessage(config), nil
2016-10-17 12:35:13 +00:00
}