Fixed the default Public IP range in AWS deployment.

This commit is contained in:
Khushboo Vashi 2022-03-11 14:33:30 +05:30 committed by Akshay Joshi
parent 0f5d4cd7b7
commit 99c6b171e4
2 changed files with 20 additions and 0 deletions

View File

@ -10,6 +10,7 @@
import random
import string
import urllib3
import ipaddress
def get_my_ip():
@ -23,6 +24,15 @@ def get_my_ip():
except Exception:
external_ip = '127.0.0.1'
if type(external_ip) == bytes:
external_ip = external_ip.decode('utf-8')
ip = ipaddress.ip_address(external_ip)
if isinstance(ip, ipaddress.IPv4Address):
return '{}/{}'.format(external_ip, 32)
elif isinstance(ip, ipaddress.IPv6Address):
return '{}/{}'.format(external_ip, 128)
return '{}/{}'.format(external_ip, 32)

View File

@ -8,6 +8,7 @@
# ##########################################################################
import urllib3
import ipaddress
def get_my_ip():
@ -21,4 +22,13 @@ def get_my_ip():
except Exception:
external_ip = '127.0.0.1'
if type(external_ip) == bytes:
external_ip = external_ip.decode('utf-8')
ip = ipaddress.ip_address(external_ip)
if isinstance(ip, ipaddress.IPv4Address):
return '{}/{}'.format(external_ip, 32)
elif isinstance(ip, ipaddress.IPv6Address):
return '{}/{}'.format(external_ip, 128)
return '{}/{}'.format(external_ip, 32)