当HTTP和HTTPS端口冲突时提示用户

This commit is contained in:
GoEdgeLab
2023-03-17 11:12:23 +08:00
parent 75e13d8d71
commit 172882774d
2 changed files with 20 additions and 1 deletions

View File

@@ -30,3 +30,22 @@ func (this *BaseProtocol) FullAddresses() []string {
func (this *BaseProtocol) AddListen(addr ...*NetworkAddressConfig) { func (this *BaseProtocol) AddListen(addr ...*NetworkAddressConfig) {
this.Listen = append(this.Listen, addr...) this.Listen = append(this.Listen, addr...)
} }
// AllPorts 获取所有端口号
func (this *BaseProtocol) AllPorts() []int {
var ports = []int{}
var portMap = map[int]bool{}
for _, listen := range this.Listen {
if listen.MinPort > 0 && listen.MaxPort > 0 {
for port := listen.MinPort; port <= listen.MaxPort; port++ {
_, ok := portMap[port]
if ok {
continue
}
ports = append(ports, port)
portMap[port] = true
}
}
}
return ports
}

View File

@@ -26,7 +26,7 @@ func (this *HTTPProtocolConfig) Init() error {
return nil return nil
} }
// 转换为JSON // AsJSON 转换为JSON
func (this *HTTPProtocolConfig) AsJSON() ([]byte, error) { func (this *HTTPProtocolConfig) AsJSON() ([]byte, error) {
return json.Marshal(this) return json.Marshal(this)
} }