public inbox for [email protected]
help / color / mirror / Atom feedFrom: Khushboo Vashi <[email protected]>
To: pgadmin-hackers <[email protected]>
Cc: Yogesh Mahajan <[email protected]>
Subject: [pgAdmin4][Patch]: Fixed default public IP range issue in AWS deployment
Date: Fri, 11 Mar 2022 08:49:39 +0530
Message-ID: <CAFOhELeN2ewo5zA79e9dRAoCQEgbUfQ+2+SuT8z65Vn7XMtcpQ@mail.gmail.com> (raw)
Hi,
Please find the attached patch to fix the default Public IP range issue in
AWS deployment.
@Yogesh Mahajan <[email protected]>, please test.
Thanks,
Khushboo
Attachments:
[application/octet-stream] cloud_public_ip_fix.patch (1.6K, 3-cloud_public_ip_fix.patch)
download | inline diff:
diff --git a/web/pgacloud/utils/misc.py b/web/pgacloud/utils/misc.py
index ddbbf04cb..586bf09c1 100644
--- a/web/pgacloud/utils/misc.py
+++ b/web/pgacloud/utils/misc.py
@@ -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)
diff --git a/web/pgadmin/misc/cloud/utils/__init__.py b/web/pgadmin/misc/cloud/utils/__init__.py
index ba4b73331..4cded810f 100644
--- a/web/pgadmin/misc/cloud/utils/__init__.py
+++ b/web/pgadmin/misc/cloud/utils/__init__.py
@@ -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)
view thread (7+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [pgAdmin4][Patch]: Fixed default public IP range issue in AWS deployment
In-Reply-To: <CAFOhELeN2ewo5zA79e9dRAoCQEgbUfQ+2+SuT8z65Vn7XMtcpQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox