From: Russ Handorf Date: Thu, 2 Feb 2023 15:34:14 +0000 (-0500) Subject: working on heatmaps X-Git-Url: https://handorf.org/code/?a=commitdiff_plain;h=64478d6a7b5096115a5fe055f50bda5d114678b3;p=kismet-logviewer.git working on heatmaps --- diff --git a/logviewer/dbview/__pycache__/views.cpython-38.pyc b/logviewer/dbview/__pycache__/views.cpython-38.pyc index 8d3e613..7e183cb 100644 Binary files a/logviewer/dbview/__pycache__/views.cpython-38.pyc and b/logviewer/dbview/__pycache__/views.cpython-38.pyc differ diff --git a/logviewer/dbview/views.py b/logviewer/dbview/views.py index 6a899ee..d91b507 100644 --- a/logviewer/dbview/views.py +++ b/logviewer/dbview/views.py @@ -309,6 +309,65 @@ def index(request): return HttpResponse(dev_string, content_type='text/json') elif request.path == "/eventbus/events.ws": return HttpResponse("[]", content_type='text/json') + elif request.path == "/phy/RUSS/map_data.json": + min_long = 361.0 + max_long = 0.0 + min_lat = 181.0 + max_lat = 0.0 + multikey = "{}" + russlist = "{ \"kismet.wireless.map.devices\": [ " + dev_list = list(load_db("select cast(device as text) from devices where (phyname = 'Bluetooth' or phyname = 'IEEE802.11') and cast(device as text) like '%kismet.common.location.geopoint%'")) + for device in dev_list: + (dev,) = device + dev_json = json.loads(dev) + newdev = {} + newdev['kismet.device.base.first_time'] = dev_json['kismet.device.base.first_time'] + try: + (tmp_min_long,tmp_min_lat) = dev_json['kismet.device.base.location']['kismet.common.location.min_loc']['kismet.common.location.geopoint'] + tmp_min_lat = round(tmp_min_lat + 91, 6) + tmp_min_long = round(tmp_min_long + 181, 6) + if (tmp_min_lat != 91 and tmp_min_long !=181): + if (tmp_min_lat < min_lat): + min_lat = tmp_min_lat + if (tmp_min_long < min_long): + min_long = tmp_min_long + (tmp_max_long,tmp_max_lat) = dev_json['kismet.device.base.location']['kismet.common.location.max_loc']['kismet.common.location.geopoint'] + tmp_max_lat = round(tmp_max_lat + 91,6) + tmp_max_long = round(tmp_max_long +181,6) + if (tmp_max_lat != 91 and tmp_max_long !=181): + if (tmp_max_lat > max_lat): + max_lat = tmp_max_lat + if (tmp_max_long > max_long): + max_long = tmp_max_long + russlist = russlist + str(dev_json['kismet.device.base.location']['kismet.common.location.avg_loc']['kismet.common.location.geopoint']) + "," + except: + try: + (tmp_min_long,tmp_min_lat) = dev_json['dot11.device']['dot11.device.client_map']['dot11.client.location']['kismet.common.location.min_loc']['kismet.common.location.geopoint'] + tmp_min_lat = round(tmp_min_lat + 91, 6) + tmp_min_long = round(tmp_min_long + 181, 6) + if (tmp_min_lat != 91 and tmp_min_long !=181): + if (tmp_min_lat < min_lat): + min_lat = tmp_min_lat + if (tmp_min_long < min_long): + min_long = tmp_min_long + (tmp_max_long,tmp_max_lat) = dev_json['dot11.device']['dot11.device.client_map']['dot11.client.location']['kismet.common.location.max_loc']['kismet.common.location.geopoint'] + tmp_max_lat = round(tmp_max_lat + 91,6) + tmp_max_long = round(tmp_max_long +181,6) + if (tmp_max_lat != 91 and tmp_max_long !=181): + if (tmp_max_lat > max_lat): + max_lat = tmp_max_lat + if (tmp_max_long > max_long): + max_long = tmp_max_long + russlist = russlist + str(dev_json['dot11.device']['dot11.device.client_map']['dot11.client.location']['kismet.common.location.avg_loc']['kismet.common.location.geopoint']) + "," + except: + print("poop") + russlist = russlist[:-1] + min_lat = round(min_lat - 91, 6) + min_long = round(min_long - 181, 6) + max_lat = round(max_lat - 91, 6) + max_long = round(max_long - 181, 6) + russlist = russlist + " ], \"kismet.wireless.map.min_lon\": "+str(min_long) + ", \"kismet.wireless.map.max_lat\": "+str(max_lat)+", \"kismet.wireless.map.min_lat\": "+str(min_lat)+", \"kismet.wireless.map.max_lon\": "+str(max_long)+" }" + return HttpResponse(russlist, content_type='text/json') elif request.path == "/devices/multikey/as-object/devices.json": #ClientMap incomplete.... figure out where the rest of the JSON comes from search_json = "" diff --git a/logviewer/logviewer/__pycache__/settings.cpython-38.pyc b/logviewer/logviewer/__pycache__/settings.cpython-38.pyc index 10c7562..2abba2b 100644 Binary files a/logviewer/logviewer/__pycache__/settings.cpython-38.pyc and b/logviewer/logviewer/__pycache__/settings.cpython-38.pyc differ diff --git a/logviewer/logviewer/__pycache__/urls.cpython-38.pyc b/logviewer/logviewer/__pycache__/urls.cpython-38.pyc index 31bf70d..693196d 100644 Binary files a/logviewer/logviewer/__pycache__/urls.cpython-38.pyc and b/logviewer/logviewer/__pycache__/urls.cpython-38.pyc differ diff --git a/logviewer/logviewer/settings.py b/logviewer/logviewer/settings.py index 2df18a0..ec05c9c 100644 --- a/logviewer/logviewer/settings.py +++ b/logviewer/logviewer/settings.py @@ -27,7 +27,7 @@ SECRET_KEY = 'django-insecure-%9bti-7!h)!k2gi)4dq93^t=08()d8^aevt!1$nqlqg_x4k3qr # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +#ALLOWED_HOSTS = [] # Application definition @@ -145,7 +145,7 @@ TEMPLATES = [ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -ALLOWED_HOSTS = ['sdr-cabinet', 'sdr-cabinet.dyn.spangdorfia.com'] +ALLOWED_HOSTS = ['*'] ASGI_APPLICATION = 'logviewer.asgi.application' diff --git a/logviewer/logviewer/urls.py b/logviewer/logviewer/urls.py index ae573ea..aee7816 100644 --- a/logviewer/logviewer/urls.py +++ b/logviewer/logviewer/urls.py @@ -36,6 +36,7 @@ urlpatterns = [ path('phy/phy80211/ssids/views/ssids.json', include('dbview.urls')), path('css/images/', include('kiscontent.urls')), path('adsb_map_panel.html', include('adsbmap.urls')), + path('russ_map_panel.html', include('russmap.urls')), path('system/status.json', include('dbview.urls')), path('alerts/wrapped/last-time/0/alerts.json', include('dbview.urls')), path('messagebus/last-time/0/messages.json', include('dbview.urls')), @@ -54,6 +55,7 @@ urlpatterns = [ path('devices/views/phy-RTL433/devices.json', include('dbview.urls')), path('devices/views/phy-IEEE802.11/devices.json', include('dbview.urls')), path('phy/ADSB/map_data.json', include('dbview.urls')), + path('phy/RUSS/map_data.json', include('dbview.urls')), path('devices/by-key//device.json', include('devices.urls')), path('devices/multikey/as-object/devices.json', include('dbview.urls')), path('datasource/by-uuid//source.json', include('devices.urls')), diff --git a/logviewer/russmap/__init__.py b/logviewer/russmap/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/logviewer/russmap/__pycache__/__init__.cpython-38.pyc b/logviewer/russmap/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..605e22a Binary files /dev/null and b/logviewer/russmap/__pycache__/__init__.cpython-38.pyc differ diff --git a/logviewer/russmap/__pycache__/urls.cpython-38.pyc b/logviewer/russmap/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000..fbce56c Binary files /dev/null and b/logviewer/russmap/__pycache__/urls.cpython-38.pyc differ diff --git a/logviewer/russmap/__pycache__/views.cpython-38.pyc b/logviewer/russmap/__pycache__/views.cpython-38.pyc new file mode 100644 index 0000000..1a92a6a Binary files /dev/null and b/logviewer/russmap/__pycache__/views.cpython-38.pyc differ diff --git a/logviewer/russmap/admin.py b/logviewer/russmap/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/logviewer/russmap/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/logviewer/russmap/apps.py b/logviewer/russmap/apps.py new file mode 100644 index 0000000..f7384d8 --- /dev/null +++ b/logviewer/russmap/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class RussmapConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'russmap' diff --git a/logviewer/russmap/migrations/__init__.py b/logviewer/russmap/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/logviewer/russmap/models.py b/logviewer/russmap/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/logviewer/russmap/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/logviewer/russmap/tests.py b/logviewer/russmap/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/logviewer/russmap/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/logviewer/russmap/urls.py b/logviewer/russmap/urls.py new file mode 100644 index 0000000..4c9189f --- /dev/null +++ b/logviewer/russmap/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='index'), +] + diff --git a/logviewer/russmap/views.py b/logviewer/russmap/views.py new file mode 100644 index 0000000..06ddbf9 --- /dev/null +++ b/logviewer/russmap/views.py @@ -0,0 +1,15 @@ +from django.shortcuts import render +from django.http import HttpResponse, HttpRequest +import os + +def index(request): + #print("===") + #print(request) + #print("====") + if request.method == 'POST': + for key, value in request.POST.items(): + print(key,value) + + load_file = open('static/'+request.path, mode='rb') + if request.path == "/russ_map_panel.html": + return HttpResponse(load_file, content_type='text/html') diff --git a/logviewer/static/dynamic.js b/logviewer/static/dynamic.js index 0bc785a..8c386ea 100644 --- a/logviewer/static/dynamic.js +++ b/logviewer/static/dynamic.js @@ -10,6 +10,7 @@ var kismet_ui_meter; var kismet_ui_rtl433; var kismet_ui_uav; var kismet_ui_zwave; +var kismet_ui_russmap; async function load_dynamics() { kismet_ui_adsb = await import(`${local_uri_prefix}js/kismet.ui.adsb.js`); kismet_ui_bluetooth = await import(`${local_uri_prefix}js/kismet.ui.bluetooth.js`); @@ -20,4 +21,5 @@ kismet_ui_meter = await import(`${local_uri_prefix}js/kismet.ui.meter.js`); kismet_ui_rtl433 = await import(`${local_uri_prefix}js/kismet.ui.rtl433.js`); kismet_ui_uav = await import(`${local_uri_prefix}js/kismet.ui.uav.js`); kismet_ui_zwave = await import(`${local_uri_prefix}js/kismet.ui.zwave.js`); +kismet_ui_russmap = await import(`${local_uri_prefix}js/kismet.ui.russmap.js`); } diff --git a/logviewer/static/js/kismet.ui.russmap.js b/logviewer/static/js/kismet.ui.russmap.js new file mode 100644 index 0000000..bd60ff5 --- /dev/null +++ b/logviewer/static/js/kismet.ui.russmap.js @@ -0,0 +1,30 @@ + +"use strict"; + +var local_uri_prefix = ""; +if (typeof(KISMET_URI_PREFIX) !== 'undefined') + local_uri_prefix = KISMET_URI_PREFIX; + +kismet_ui_tabpane.AddTab({ + id: 'heatmap', + tabTitle: 'Heat Map', + expandable: false, + createCallback: function(div) { + var url = new URL(parent.document.URL); + url.searchParams.append('parent_url', url.origin) + url.searchParams.append('local_uri_prefix', local_uri_prefix); + url.searchParams.append('KISMET_PROXY_PREFIX', KISMET_PROXY_PREFIX); + url.pathname = `${local_uri_prefix}${KISMET_PROXY_PREFIX}russ_map_panel.html`; + + div.append( + $('