Skip to content

Commit

Permalink
Replace Ipify API call with HANA (#57)
Browse files Browse the repository at this point in the history
* Update public IP Address method to use HANA
Closes #56

* Update default HANA url to neonaibeta to include util endpoints

---------

Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Jul 9, 2024
1 parent 2708d0a commit e79cffd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ def handle_query_ip(self, message):
{'interface': iface, 'ip': ip_spoken},
private=True, wait=True)

@staticmethod
def _get_public_ip_address(message: Message = None) -> str:
def _get_public_ip_address(self, message: Message = None) -> str:
"""
Get the public IP address associated with the request
:returns: str public IP address
Expand All @@ -156,4 +155,9 @@ def _get_public_ip_address(message: Message = None) -> str:
public_addr = message.context['node_data'].get('networking',
{}).get('public_ip')
LOG.info(f"Got public IP from context: {public_addr}")
return public_addr or get('https://api.ipify.org').text
if not public_addr:
hana_url = self.config_core.get('hana', {}).get('url') or \
"https://hana.neonaibeta.com" # TODO: Update to neonaiservices after HANA 0.2 release
public_addr = get(f"{hana_url}/util/client_ip").text
LOG.info(f"Got public IP from HANA: {public_addr}")
return public_addr

0 comments on commit e79cffd

Please sign in to comment.