1package conf 2 3import ( 4 "github.com/golang/protobuf/proto" 5 6 "github.com/xtls/xray-core/proxy/dokodemo" 7) 8 9type DokodemoConfig struct { 10 Host *Address `json:"address"` 11 PortValue uint16 `json:"port"` 12 NetworkList *NetworkList `json:"network"` 13 TimeoutValue uint32 `json:"timeout"` 14 Redirect bool `json:"followRedirect"` 15 UserLevel uint32 `json:"userLevel"` 16} 17 18func (v *DokodemoConfig) Build() (proto.Message, error) { 19 config := new(dokodemo.Config) 20 if v.Host != nil { 21 config.Address = v.Host.Build() 22 } 23 config.Port = uint32(v.PortValue) 24 config.Networks = v.NetworkList.Build() 25 config.Timeout = v.TimeoutValue 26 config.FollowRedirect = v.Redirect 27 config.UserLevel = v.UserLevel 28 return config, nil 29} 30