Generating a list of IP addresses of IPv4 and IPv6 versions.
Project description
ipaddr_range
This code provides a simple implementation of generating a list of IP addresses of IPv4 and IPv6 versions.
Usage
The code defines three classes:
IPAddressRange
: This is a data class that holds the start and end IP addresses.IPv4AddressRange
andIPv6AddressRange
: These classes inherit fromIPAddressRange
and represent IP ranges for IPv4 and IPv6 addresses respectively.IPAddressGenerator
: This is an abstract class that provides an interface for generating IP addresses.IPv4AddressGenerator
andIPv6AddressGenerator
: These classes inherit fromIPAddressGenerator
and provide the implementation for generating IPv4 and IPv6 addresses respectively.
To generate a list of IP addresses, you need to create an instance of IPv4AddressGenerator
or IPv6AddressGenerator
and then call the generate method with the start and end IP addresses.
The generate method returns an object of type IPAddressRange
, which can be used to traverse through the generated IP addresses.
Example
if __name__ == '__main__':
start_ip, end_ip = '192.168.2.1', '192.168.2.10'
generator = IPv4AddressGenerator()
ip_range = generator.generate(start_ip, end_ip)
for ip in ip_range:
logging.info(ip)
This code generates a list of IP addresses of the IPv4 version and logs the generated IP addresses.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ipaddr_range-0.0.1.tar.gz
(2.1 kB
view hashes)
Built Distribution
Close
Hashes for ipaddr_range-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b9ad5eeda7e282393be14673adc2360a66f0b90cf12a1df57a5e0c597e1536a |
|
MD5 | b35ed4c3f1f36a99af451f1d1557af96 |
|
BLAKE2b-256 | 7932319217c231c3f1217e6e06bfd93078f9bdf764856899f5f0d491e35a7007 |