mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-04 05:00:24 +08:00
当HTTP和HTTPS端口冲突时提示用户
This commit is contained in:
@@ -30,3 +30,22 @@ func (this *BaseProtocol) FullAddresses() []string {
|
||||
func (this *BaseProtocol) AddListen(addr ...*NetworkAddressConfig) {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func (this *HTTPProtocolConfig) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 转换为JSON
|
||||
// AsJSON 转换为JSON
|
||||
func (this *HTTPProtocolConfig) AsJSON() ([]byte, error) {
|
||||
return json.Marshal(this)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user