dokodemo.go 754 B

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