mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			453 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			453 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package utils
 | 
						|
 | 
						|
import (
 | 
						|
	"encoding/binary"
 | 
						|
	"net"
 | 
						|
	"strings"
 | 
						|
)
 | 
						|
 | 
						|
// VersionToLong 计算版本代号
 | 
						|
func VersionToLong(version string) uint32 {
 | 
						|
	var countDots = strings.Count(version, ".")
 | 
						|
	if countDots == 2 {
 | 
						|
		version += ".0"
 | 
						|
	} else if countDots == 1 {
 | 
						|
		version += ".0.0"
 | 
						|
	} else if countDots == 0 {
 | 
						|
		version += ".0.0.0"
 | 
						|
	}
 | 
						|
	var ip = net.ParseIP(version)
 | 
						|
	if ip == nil || ip.To4() == nil {
 | 
						|
		return 0
 | 
						|
	}
 | 
						|
	return binary.BigEndian.Uint32(ip.To4())
 | 
						|
}
 |