nps/server/tool/utils.go

28 lines
427 B
Go
Raw Normal View History

2019-02-12 19:54:00 +00:00
package tool
import (
"github.com/cnlh/nps/lib/beego"
"github.com/cnlh/nps/lib/common"
)
var ports []int
func init() {
p := beego.AppConfig.String("allowPorts")
2019-02-15 14:59:28 +00:00
ports = common.GetPorts(p)
2019-02-12 19:54:00 +00:00
}
2019-02-15 14:59:28 +00:00
2019-02-12 19:54:00 +00:00
func TestServerPort(p int, m string) (b bool) {
if len(ports) != 0 {
if !common.InIntArr(ports, p) {
return false
}
}
if m == "udpServer" {
b = common.TestUdpPort(p)
} else {
b = common.TestTcpPort(p)
}
return
}