github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/infra/conf/v4/browser_forwarder.go (about)

     1  package v4
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/golang/protobuf/proto"
     7  
     8  	"github.com/v2fly/v2ray-core/v5/app/browserforwarder"
     9  )
    10  
    11  type BrowserForwarderConfig struct {
    12  	ListenAddr string `json:"listenAddr"`
    13  	ListenPort int32  `json:"listenPort"`
    14  }
    15  
    16  func (b *BrowserForwarderConfig) Build() (proto.Message, error) {
    17  	b.ListenAddr = strings.TrimSpace(b.ListenAddr)
    18  	if b.ListenAddr != "" && b.ListenPort == 0 {
    19  		b.ListenPort = 54321
    20  	}
    21  	return &browserforwarder.Config{
    22  		ListenAddr: b.ListenAddr,
    23  		ListenPort: b.ListenPort,
    24  	}, nil
    25  }