修复待升级节点版本号对比错误

This commit is contained in:
刘祥超
2021-01-18 12:35:39 +08:00
parent 3ba2d9da63
commit ee2438aefa
3 changed files with 39 additions and 0 deletions

19
internal/utils/ip.go Normal file
View File

@@ -0,0 +1,19 @@
package utils
import (
"encoding/binary"
"net"
)
// 将IP转换为整型
func IP2Long(ip string) uint32 {
s := net.ParseIP(ip)
if s == nil {
return 0
}
if len(s) == 16 {
return binary.BigEndian.Uint32(s[12:16])
}
return binary.BigEndian.Uint32(s)
}