Added IPv6 support for Rocket, refactored some code, and fixed some bugs.

This commit is contained in:
Charles Winebrinner
2012-11-18 01:03:04 -06:00
parent c6c54ad98d
commit bd13035a17
3 changed files with 122 additions and 71 deletions
+13
View File
@@ -287,3 +287,16 @@ def is_valid_ip_address(address):
return False
else: # do not know what to do? assume it is a valid address
return True
def is_loopback_ip_address(ip):
"""Determines whether the IP address appears to be a loopback address.
This assumes that the IP is valid. The IPv6 check is limited to '::1'.
"""
if not ip:
return False
if ip.count('.') == 3: # IPv4
return ip.startswith('127') or ip.startswith('::ffff:127')
return ip == '::1' # IPv6