From 2ae908941bdf5b40472a87928ec0cb621d5e9fb4 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Fri, 26 Jul 2024 10:32:05 -0700 Subject: [PATCH] fixGPS and whereami security issue if you used an exact lat long for the node settings it would return the address of the "bot" might not be ideal. --- modules/locationdata.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/locationdata.py b/modules/locationdata.py index ebcea58..bb7cd82 100644 --- a/modules/locationdata.py +++ b/modules/locationdata.py @@ -13,16 +13,21 @@ trap_list_location = ("whereami", "tide", "moon", "wx", "wxc", "wxa", "wxalert") def where_am_i(lat=0, lon=0): whereIam = "" + grid = mh.to_maiden(float(lat), float(lon)) + if float(lat) == 0 and float(lon) == 0: return NO_DATA_NOGPS + + if float(lat) == latitudeValue and float(lon) == longitudeValue: + return "Grid: " + grid + # initialize Nominatim API geolocator = Nominatim(user_agent="mesh-bot") - + # Nomatim API call to get address location = geolocator.reverse(lat + ", " + lon) address = location.raw['address'] address_components = ['house_number', 'road', 'city', 'state', 'postcode', 'county', 'country'] whereIam += ' '.join([address.get(component, '') for component in address_components if component in address]) - grid = mh.to_maiden(float(lat), float(lon)) whereIam += " Grid: " + grid return whereIam @@ -263,4 +268,4 @@ def getActiveWeatherAlertsDetail(lat=0, lon=0): alerts = "\n".join(alerts) - return alerts \ No newline at end of file + return alerts