Package DebTorrent :: Module subnetparse :: Class IP_List
[hide private]
[frames] | no frames]

Class IP_List

source code

Stores multiple IP address subnets.

Instance Methods [hide private]
 
__init__(self, entrylist=None)
Initialize the instance.
source code
boolean
__nonzero__(self)
Check whether there are any IP address subnets stored.
source code
 
_append(self, ip, depth=256)
Add a new IP address subnet to the end.
source code
 
append(self, ip, depth=256)
Add a new IP address subnet in the correct order.
source code
boolean
includes(self, ip)
Determine whether the IP address is included in any of the subnets.
source code
 
read_fieldlist(self, file)
Parse a file for lists of IP address subnets to add.
source code
 
set_intranet_addresses(self)
Add the (RFC 1918) private subnets and local subnets.
source code
 
set_ipv4_addresses(self)
Add the IPv6 address subnet used to store IPv4 addresses.
source code
Instance Variables [hide private]
list of string ipv4list
the binary strings representing the start of the IPv4 address that is in the subnet
list of string ipv6list
the binary strings representing the start of the IPv6 address that is in the subnet
Method Details [hide private]

__init__(self, entrylist=None)
(Constructor)

source code 
Initialize the instance.
Parameters:
  • entrylist (list of (string, int)) - the IP address and subnet length of the IP address subnets to start with (optional, defaults to None)

__nonzero__(self)
(Boolean test operator)

source code 
Check whether there are any IP address subnets stored.
Returns: boolean
whether there are IP address subnets stored

_append(self, ip, depth=256)

source code 
Add a new IP address subnet to the end.
Parameters:
  • ip (string) - an IP address in the subnet
  • depth (int) - the length of the address subnet header (optional, defaults to the entire IP address)

append(self, ip, depth=256)

source code 
Add a new IP address subnet in the correct order.
Parameters:
  • ip (string) - an IP address in the subnet
  • depth (int) - the length of the address subnet header (optional, defaults to the entire IP address)

includes(self, ip)

source code 
Determine whether the IP address is included in any of the subnets.
Parameters:
  • ip (string) - the IP address to check
Returns: boolean
whether the IP address is in one of the ranges

read_fieldlist(self, file)

source code 

Parse a file for lists of IP address subnets to add.

The file to parse must have lines in the format 'ip/len <whatever>'. The 'whatever' will be ignored. If the subnet is only a single IP address, omit the '/' and the 'len'. Empty lines will be ignored, as will lines beginning with '#' which can be used for comments.
Parameters:
  • file (string) - the name of the file to parse