mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-07-04 00:41:35 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user