github.com/v2fly/v2ray-core/v4@v4.45.2/infra/conf/dokodemo.go (about)

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