You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
287 B
17 lines
287 B
# -*- coding: utf8 -*-
|
|
import socket
|
|
import struct
|
|
|
|
|
|
def ip2int(addr):
|
|
try:
|
|
return struct.unpack("!I", socket.inet_aton(addr))[0]
|
|
except:
|
|
return 0
|
|
|
|
|
|
def int2ip(addr):
|
|
try:
|
|
return socket.inet_ntoa(struct.pack("!I", addr))
|
|
except:
|
|
return ''
|