|
|
|
@ -959,7 +959,15 @@ def total_seconds(td):
|
|
|
|
|
""" |
|
|
|
|
return td.days * 60 * 60 * 24 + td.seconds |
|
|
|
|
|
|
|
|
|
def is_IP(string): |
|
|
|
|
def is_IP(string, var_name): |
|
|
|
|
"""Returns the if the string received is an IP or not. |
|
|
|
|
|
|
|
|
|
:param string: the string to check if it an IP or not |
|
|
|
|
:param var_name: the name of the variable that is being checked |
|
|
|
|
|
|
|
|
|
:returns: True if string is an IP, False if not |
|
|
|
|
:rtype: boolean |
|
|
|
|
""" |
|
|
|
|
ipv4 = string.split('.') |
|
|
|
|
ipv6 = string.split(':') |
|
|
|
|
try: |
|
|
|
@ -967,7 +975,7 @@ def is_IP(string):
|
|
|
|
|
if not t: |
|
|
|
|
ipv6[i] = "0" |
|
|
|
|
if(all(int(t,16) >= 0 and int(t,16) <= 65535 for t in ipv6)): |
|
|
|
|
print("IPv6 address introduced in SESSION_COOKIE_DOMAIN!") |
|
|
|
|
print("IPv6 address introduced in " + var_name) |
|
|
|
|
return True |
|
|
|
|
except ValueError: |
|
|
|
|
pass |
|
|
|
@ -975,7 +983,7 @@ def is_IP(string):
|
|
|
|
|
if len(ipv4) == 4: |
|
|
|
|
try: |
|
|
|
|
if(all(int(t) >= 0 and int(t) <= 255 for t in ipv4)): |
|
|
|
|
print("IPv4 address introduced in SESSION_COOKIE_DOMAIN!") |
|
|
|
|
print("IPv4 address introduced in " + var_name) |
|
|
|
|
except ValueError: |
|
|
|
|
return False |
|
|
|
|
else: |
|
|
|
|