recently , i find the python library "iptools" can help me to solve some problem , but i meet a problem in iptools.IpRangeList , i only can declare the initial data in first , like
internalIP = iptools.IpRangeList(
'127.0.0.1/8',
'192.168/16',
'10.0.0.1/8'
)
if i want to add a new ip into IpRangeList , compiler always show error
internalIP.append('1.1.1.1')
AttributeError: 'IpRangeList' object has no attribute 'append'
or openfrom file
intranetlist = IpRangeList()
if os.path.isfile("/tmp/intranal.list"):
fp = open("/tmp/intranal.list", 'r')
intranetlist = ([line.strip() for line in fp])
print intranetlist , len(intranetlist)
fp.close()
return
Result : ['127.0.0.1/8', '192.168/16', '10.0.0.0/8'] 3
it is incorrect , the correct result is as below
>>> from iptools import *
>>> a=IpRangeList('127.0.0.1/8' , '192.168/16', '10.0.0.0/8')
>>> print a
(('127.0.0.0', '127.255.255.255'), ('192.168.0.0', '192.168.255.255'), ('10.0.0.0', '10.255.255.255'))
>>> len(a)
33619968
>>>
can anyone help me to solve this problem ? or have other library i can use for ?
Thanks.