-
Notifications
You must be signed in to change notification settings - Fork 0
iptoolbox 0.0.3
python3 -m pip install iptoolbox==0.0.3
-
RandomIp4
class is for creating random IP -
validation.ip4
Checks the correctness of the IP version 4 structural template -
validation.ip6
Checks the correctness of the IP version 6 structural template
-
iptoolbox.RandomIp4(country_code: set = "ALL", random_seed=None)
RandomIp4 class is for creating random IP
- Parameters:
-
country_code
(set
, optional): - Enter the country code or you can enterALL
instead of the country code. In this case, the generated IP can be for any country . Defaults toALL
. -
random_seed
(str
orint
, optional): - used to initialize the random ip generator . Defaults to None.
-
- Returns
- type: None
-
-
Use
generate_ip
to generate an IP. It will return the created IP to you and add it to theip_list
list- Returns:
-
str
: ip v4
-
- Returns:
-
-
simple :
>>> import iptoolbox >>> iptoolbox.RandomIp4().generate_ip() '213.248.92.166' >>>
import iptoolbox r = iptoolbox.RandomIp4() print(r.generate_ip()) print(r.ip_list)
139.81.25.43
['139.81.25.43']
-
using with :
import iptoolbox with iptoolbox.RandomIp4(country_code="IR") as r: print(r.generate_ip())
185.8.173.203
-
using a for loop :
import iptoolbox with iptoolbox.RandomIp4(country_code="US") as r: for _ in range(10): r.generate_ip() print(r.ip_list)
['205.252.16.87', '50.0.53.6', '154.26.1.61', '149.14.14.36', '130.244.138.15', '151.139.41.225', '200.186.105.44', '220.158.255.80', '199.180.221.10', '69.172.213.166']
-
using seed :
import iptoolbox with iptoolbox.RandomIp4(country_code="US", random_seed=24) as r: for _ in range(10): r.generate_ip() print(r.ip_list)
['204.246.205.39', '216.250.193.77', '63.218.150.66', '63.110.213.250', '63.146.54.87', '199.189.209.223', '204.98.216.96', '213.151.35.145', '206.71.103.208', '130.244.2.49']
-
-
- Parameters:
-
iptoolbox.validation.<?>
A set of tools for validation
-
-
iptoolbox.validation.ip4(ip:str)
Checks the correctness of the IP version 4 structural template
-
Parameters:
- ip (
str
): enter ip version 4
- ip (
-
Returns
-
bool
: If the entered IP has a correct pattern, it will returnTrue
for you, otherwise it will returnFalse
-
-
-
- simple :
>>> from iptoolbox import validation >>> validation.ip4("127.0.0.1") True >>> validation.ip4("127.0.0.256") False >>> validation.ip4("127.0.0.01") False >>>
- simple :
-
iptoolbox.validation.ip6(ip:str)
Checks the correctness of the IP version 6 structural template
-
Parameters:
- ip (
str
): enter ip version 6
- ip (
-
Returns
-
bool
: If the entered IP has a correct pattern, it will returnTrue
for you, otherwise it will returnFalse
-
-
-
- simple :
>>> from iptoolbox import validation >>> validation.ip6("2001:db8:3333:4444:5555:6666:7777:8888") True >>> validation.ip6("2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF") True >>> validation.ip6("2001:db8:3333:4444:CCCC:DDDD:EEEE:ZZZZ") False >>> validation.ip6("192:168:100:100") False >>>
- simple :
-
-