Skip to content

Commit 0a46ca8

Browse files
committed
Merging in main
2 parents c7bc6e4 + e115305 commit 0a46ca8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

resources/maintainer_scripts/node_util.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ def _get_external_ip(self):
246246
if self._external_ip:
247247
return self._external_ip
248248
services = (("https://checkip.amazonaws.com", "amazonaws.com"),
249-
("https://ifconfig.me", "ifconfig.me"),
250-
("https://ident.me", "ident.me"))
249+
("https://4.icanhazip.com/", "icanhazip.com"),
250+
("https://4.ident.me", "ident.me"))
251251
ips = []
252252
# Using our own PoolManager for shorter timeouts
253253
print("Querying your external IP...")
@@ -271,7 +271,7 @@ def _get_external_ip(self):
271271
def _is_valid_ip(ip):
272272
""" Check validity of ip address """
273273
try:
274-
_ = ipaddress.ip_address(ip)
274+
_ = ipaddress.IPv4Network(ip)
275275
except ValueError:
276276
return False
277277
else:
@@ -864,6 +864,10 @@ def get_trusted_hash(self):
864864
exit(1)
865865
print(f"{block_hash}")
866866

867+
def get_ip(self):
868+
""" Get external IP of node. Can be used to test code used for automatically filling IP
869+
or to check if you need to update the IP in your config.toml file. """
870+
print(self._get_external_ip())
867871

868872
if __name__ == '__main__':
869873
NodeUtil()

0 commit comments

Comments
 (0)