1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-19 10:56:06 -05:00
v2fly/infra/conf/browser_forwarder.go
秋のかえで b68411f460
Fix: browserforwarder panics with empty config (#954)
Co-authored-by: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
2021-05-01 20:50:30 +08:00

26 lines
534 B
Go

package conf
import (
"strings"
"github.com/golang/protobuf/proto"
"github.com/v2fly/v2ray-core/v4/app/browserforwarder"
)
type BrowserForwarderConfig struct {
ListenAddr string `json:"listenAddr"`
ListenPort int32 `json:"listenPort"`
}
func (b *BrowserForwarderConfig) Build() (proto.Message, error) {
b.ListenAddr = strings.TrimSpace(b.ListenAddr)
if b.ListenAddr != "" && b.ListenPort == 0 {
b.ListenPort = 54321
}
return &browserforwarder.Config{
ListenAddr: b.ListenAddr,
ListenPort: b.ListenPort,
}, nil
}