@@ -975,12 +975,24 @@ def is_private(self):
975975 """Test if this address is allocated for private networks.
976976
977977 Returns:
978- A boolean, True if the address is reserved per RFC 4193.
978+ A boolean, True if the address is reserved per
979+ iana-ipv4-special-registry or iana-ipv6-special-registry.
979980
980981 """
981982 return (self .network_address .is_private and
982983 self .broadcast_address .is_private )
983984
985+ @property
986+ def is_global (self ):
987+ """Test if this address is allocated for private networks.
988+
989+ Returns:
990+ A boolean, True if the address is not reserved per
991+ iana-ipv4-special-registry or iana-ipv6-special-registry.
992+
993+ """
994+ return not self .is_private
995+
984996 @property
985997 def is_unspecified (self ):
986998 """Test if the address is unspecified.
@@ -1225,15 +1237,37 @@ def is_private(self):
12251237 """Test if this address is allocated for private networks.
12261238
12271239 Returns:
1228- A boolean, True if the address is reserved per RFC 1918.
1240+ A boolean, True if the address is reserved per
1241+ iana-ipv4-special-registry.
12291242
12301243 """
1231- private_10 = IPv4Network ('10.0.0.0/8' )
1232- private_172 = IPv4Network ('172.16.0.0/12' )
1233- private_192 = IPv4Network ('192.168.0.0/16' )
1234- return (self in private_10 or
1235- self in private_172 or
1236- self in private_192 )
1244+ return (self in IPv4Network ('0.0.0.0/8' ) or
1245+ self in IPv4Network ('10.0.0.0/8' ) or
1246+ self in IPv4Network ('100.64.0.0/10' ) or
1247+ self in IPv4Network ('127.0.0.0/8' ) or
1248+ self in IPv4Network ('169.254.0.0/16' ) or
1249+ self in IPv4Network ('172.16.0.0/12' ) or
1250+ self in IPv4Network ('192.0.0.0/29' ) or
1251+ self in IPv4Network ('192.0.0.170/31' ) or
1252+ self in IPv4Network ('192.0.2.0/24' ) or
1253+ self in IPv4Network ('192.168.0.0/16' ) or
1254+ self in IPv4Network ('198.18.0.0/15' ) or
1255+ self in IPv4Network ('198.51.100.0/24' ) or
1256+ self in IPv4Network ('203.0.113.0/24' ) or
1257+ self in IPv4Network ('240.0.0.0/4' ) or
1258+ self in IPv4Network ('255.255.255.255/32' ))
1259+
1260+ @property
1261+ def is_global (self ):
1262+ """Test if this address is allocated for private networks.
1263+
1264+ Returns:
1265+ A boolean, True if the address is not reserved per
1266+ iana-ipv4-special-registry.
1267+
1268+ """
1269+ return not self .is_private
1270+
12371271
12381272 @property
12391273 def is_multicast (self ):
@@ -1826,11 +1860,31 @@ def is_private(self):
18261860 """Test if this address is allocated for private networks.
18271861
18281862 Returns:
1829- A boolean, True if the address is reserved per RFC 4193.
1863+ A boolean, True if the address is reserved per
1864+ iana-ipv6-special-registry.
1865+
1866+ """
1867+ return (self in IPv6Network ('::1/128' ) or
1868+ self in IPv6Network ('::/128' ) or
1869+ self in IPv6Network ('::ffff:0:0/96' ) or
1870+ self in IPv6Network ('100::/64' ) or
1871+ self in IPv6Network ('2001::/23' ) or
1872+ self in IPv6Network ('2001:2::/48' ) or
1873+ self in IPv6Network ('2001:db8::/32' ) or
1874+ self in IPv6Network ('2001:10::/28' ) or
1875+ self in IPv6Network ('fc00::/7' ) or
1876+ self in IPv6Network ('fe80::/10' ))
1877+
1878+ @property
1879+ def is_global (self ):
1880+ """Test if this address is allocated for public networks.
1881+
1882+ Returns:
1883+ A boolean, true if the address is not reserved per
1884+ iana-ipv6-special-registry.
18301885
18311886 """
1832- private_network = IPv6Network ('fc00::/7' )
1833- return self in private_network
1887+ return not self .is_private
18341888
18351889 @property
18361890 def is_unspecified (self ):
0 commit comments