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

This commit is contained in:
刘祥超
2023-03-17 11:12:23 +08:00
parent e938bb34f1
commit 46dc42ffe3
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) {
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
}
// 转换为JSON
// AsJSON 转换为JSON
func (this *HTTPProtocolConfig) AsJSON() ([]byte, error) {
return json.Marshal(this)
}