Package DebTorrent :: Module iprangeparse
[hide private]
[frames] | no frames]

Module iprangeparse

source code

Deal with all types of IP addresses and IP address ranges.

Classes [hide private]
  IP_List
Stores mutltiple IP address ranges.
Functions [hide private]
long
to_long_ipv4(ip)
Convert an IP address from a string to a long.
source code
long
to_long_ipv6(ip)
Convert an IPv6 address from a string to a long.
source code
boolean
is_ipv4(ip)
Determine whether the IP address is in the IPv4 format.
source code
boolean
is_valid_ip(ip)
Determine whether the IP address is a valid IPv4 or IPv6 address.
source code
Variables [hide private]
logging.Logger logger = logging.getLogger('DebTorrent.iprangeparse')
the logger to send all log messages to for this module
long ipv4addrmask = 281470681743360
the address mask used to determine if the IP address in long format is v4 encapsulated in a v6 address

Imports: bisect.bisect, bisect.insort, logging


Function Details [hide private]

to_long_ipv4(ip)

source code 
Convert an IP address from a string to a long.
Parameters:
  • ip (string) - the IP address
Returns: long
the same IP address
Raises:
  • ValueError - if the input IP address is poorly formatted

to_long_ipv6(ip)

source code 
Convert an IPv6 address from a string to a long.
Parameters:
  • ip (string) - the IPv6 address
Returns: long
the same IPv6 address
Raises:
  • ValueError - if the input IPv6 address is poorly formatted

is_ipv4(ip)

source code 
Determine whether the IP address is in the IPv4 format.
Parameters:
  • ip (string) - the IP address to check
Returns: boolean
whether the IP address is for IPv4

is_valid_ip(ip)

source code 
Determine whether the IP address is a valid IPv4 or IPv6 address.
Parameters:
  • ip (string) - the IP address to check
Returns: boolean
whether the IP address is valid