github.com/xraypb/Xray-core@v1.8.1/infra/conf/dokodemo.go (about)

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