2021-06-19 08:45:43 -04:00
|
|
|
package v4
|
2021-03-20 11:10:17 -04:00
|
|
|
|
|
|
|
import (
|
2021-05-01 08:50:30 -04:00
|
|
|
"strings"
|
|
|
|
|
2021-03-20 11:10:17 -04:00
|
|
|
"github.com/golang/protobuf/proto"
|
2021-03-27 20:44:04 -04:00
|
|
|
|
2022-01-02 10:16:23 -05:00
|
|
|
"github.com/v2fly/v2ray-core/v5/app/browserforwarder"
|
2021-03-20 11:10:17 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type BrowserForwarderConfig struct {
|
|
|
|
ListenAddr string `json:"listenAddr"`
|
|
|
|
ListenPort int32 `json:"listenPort"`
|
|
|
|
}
|
|
|
|
|
2021-05-01 08:50:30 -04:00
|
|
|
func (b *BrowserForwarderConfig) Build() (proto.Message, error) {
|
|
|
|
b.ListenAddr = strings.TrimSpace(b.ListenAddr)
|
|
|
|
if b.ListenAddr != "" && b.ListenPort == 0 {
|
|
|
|
b.ListenPort = 54321
|
|
|
|
}
|
2021-03-20 11:10:17 -04:00
|
|
|
return &browserforwarder.Config{
|
|
|
|
ListenAddr: b.ListenAddr,
|
|
|
|
ListenPort: b.ListenPort,
|
|
|
|
}, nil
|
|
|
|
}
|