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.
This commit is contained in:
SpudGunMan
2024-07-26 10:32:05 -07:00
parent 92e62cc9c4
commit 2ae908941b
+8 -3
View File
@@ -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
return alerts