12345678910111213141516171819202122232425262728 |
- package ip
- import (
- "encoding/binary"
- "net"
- )
- func isUp(v net.Flags) bool {
- return v&net.FlagUp == net.FlagUp
- }
- func ToLong(ipAddress string) uint32 {
- ip := net.ParseIP(ipAddress)
- if ip == nil {
- return 0
- }
- return binary.BigEndian.Uint32(ip.To4())
- }
- func FromLong(properAddress uint32) string {
- ipByte := make([]byte, 4)
- binary.BigEndian.PutUint32(ipByte, properAddress)
- ip := net.IP(ipByte)
- return ip.String()
- }
|