From d6eb994bf114e1e75cef44e35ce5d162e23ca20b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:53:45 +0000 Subject: [PATCH 01/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 37700de434fc394bbd4cb03f57ee2d440c609ed8 Mon Sep 17 00:00:00 2001 From: gallegonovato Date: Thu, 18 Jul 2024 09:49:21 +0000 Subject: [PATCH 02/44] Translated using Weblate (Spanish) Currently translated at 100.0% (691 of 691 strings) Translation: NetAlertX/core Translate-URL: https://hosted.weblate.org/projects/pialert/core/es/ --- front/php/templates/language/es_es.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/front/php/templates/language/es_es.json b/front/php/templates/language/es_es.json index dad937c1..4ddf3a3c 100644 --- a/front/php/templates/language/es_es.json +++ b/front/php/templates/language/es_es.json @@ -394,11 +394,11 @@ "Maintenance_Tool_ExportCSV_text": "Genere un archivo CSV (valor separado por comas) que contenga la lista de Dispositivos incluyendo las relaciones de red entre los Nodos de red y los dispositivos conectados. También puedes activarlo accediendo a esta URL your NetAlertX url/php/server/devices.php?action=ExportCSV o activando el plugin Copia de seguridad CSV.", "Maintenance_Tool_ImportCSV": "Importación CSV", "Maintenance_Tool_ImportCSV_noti": "Importación CSV", - "Maintenance_Tool_ImportCSV_noti_text": "¿Está seguro de que quiere importar el archivo CSV? Esto sobrescribirá completamente los dispositivos de su base de datos.", + "Maintenance_Tool_ImportCSV_noti_text": "¿Estás seguro de que quieres importar el archivo CSV? Esto sobrescribirá completamente los dispositivos en su base de datos.", "Maintenance_Tool_ImportCSV_text": "Antes de usar esta función, haga una copia de seguridad. Importe un archivo CSV (valor separado por comas) que contiene la lista de dispositivos, incluidas las relaciones de red entre nodos de red y dispositivos conectados. Para hacer eso, coloque el archivo CSV llamado devices.csv en su carpeta /config .", - "Maintenance_Tool_ImportPastedCSV": "", - "Maintenance_Tool_ImportPastedCSV_noti_text": "", - "Maintenance_Tool_ImportPastedCSV_text": "", + "Maintenance_Tool_ImportPastedCSV": "Importar CSV (Pegar)", + "Maintenance_Tool_ImportPastedCSV_noti_text": "¿Seguro que desea importar el CSV pegado? Esto sobrescribirá completamente los dispositivos en su base de datos.", + "Maintenance_Tool_ImportPastedCSV_text": "Antes de usar esta función, por favor haga una copia de seguridad. Importar un archivo CSV (valor separado por comas) que contiene la lista de Dispositivos incluyendo las relaciones de red entre los Nodos de red y los dispositivos conectados.", "Maintenance_Tool_arpscansw": "Activar arp-scan (on/off)", "Maintenance_Tool_arpscansw_noti": "Activar arp-scan on or off", "Maintenance_Tool_arpscansw_noti_text": "Cuando el escaneo se ha apagado, permanece apagado hasta que se active nuevamente.", @@ -735,7 +735,7 @@ "Webhooks_icon": "", "Webhooks_settings_group": " Webhooks", "devices_old": "Volviendo a actualizar....", - "general_event_description": "El evento que has activado puede tardar un poco hasta que finalicen los procesos en segundo plano. La ejecución finalizó una vez que se vació la cola de ejecución de abajo (Compruebe el registro de errores si encuentra problemas).

Cola de ejecución:", + "general_event_description": "El evento que ha desencadenado puede tardar un tiempo hasta que finalicen los procesos en segundo plano. La ejecución finalizó una vez que se vació la siguiente cola de ejecución (compruebe el registro de errores si tiene problemas).

Cola de ejecución:", "general_event_title": "Ejecutar un evento ad-hoc", "report_guid": "Guía de las notificaciones:", "report_guid_missing": "No se ha encontrado la notificación vinculada. Hay un pequeño retraso entre las notificaciones enviadas recientemente y su disponibilidad. Actualiza tu página y la caché después de unos segundos. También es posible que la notificación seleccionada se haya eliminado durante el mantenimiento, tal y como se especifica en la configuración de DBCLNP_NOTIFI_HIST.

En su lugar, se muestra la notificación más reciente. La notificación que falta tiene el siguiente GUID:", From 9b0d956fdbed866fdcbfffa80c009709f0a3402d Mon Sep 17 00:00:00 2001 From: Massimo Pissarello Date: Thu, 18 Jul 2024 17:30:00 +0000 Subject: [PATCH 03/44] Translated using Weblate (Italian) Currently translated at 100.0% (691 of 691 strings) Translation: NetAlertX/core Translate-URL: https://hosted.weblate.org/projects/pialert/core/it/ --- front/php/templates/language/it_it.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/front/php/templates/language/it_it.json b/front/php/templates/language/it_it.json index dcda6d2f..5dec73e6 100644 --- a/front/php/templates/language/it_it.json +++ b/front/php/templates/language/it_it.json @@ -370,11 +370,11 @@ "Maintenance_Tool_ExportCSV_text": "Genera un file CSV (comma separated value) contenente la lista dei dispositivi incluse le relazioni di rete tra i nodi di rete e i dispositivi connessi. Puoi anche eseguire questa azione accedendo all'URL il_tuo_NetAlertX/php/server/devices.php?action=ExportCSV o abilitando il plugin Backup CSV.", "Maintenance_Tool_ImportCSV": "Importa CSV", "Maintenance_Tool_ImportCSV_noti": "Importa CSV", - "Maintenance_Tool_ImportCSV_noti_text": "Sei sicuro di voler importare il file CSV? Questa operazione sovrascriverà tutti i dispositivi presenti nel database.", + "Maintenance_Tool_ImportCSV_noti_text": "Sei sicuro di voler importare il file CSV? Questa operazione sovrascriverà tutti i dispositivi presenti nel database.", "Maintenance_Tool_ImportCSV_text": "Prima di utilizzare questa funzione, esegui un backup. Importa un file CSV (comma separated value) contenente la lista dei dispositivi incluse le relazioni di rete tra i nodi di rete e i dispositivi connessi. Per far ciò posiziona il file CSV denominato devices.csv nella cartella /config.", - "Maintenance_Tool_ImportPastedCSV": "", - "Maintenance_Tool_ImportPastedCSV_noti_text": "", - "Maintenance_Tool_ImportPastedCSV_text": "", + "Maintenance_Tool_ImportPastedCSV": "Importazione CSV (incolla)", + "Maintenance_Tool_ImportPastedCSV_noti_text": "Sei sicuro di voler importare il CSV incollato? Questo sovrascriverà completamente i dispositivi nel tuo database.", + "Maintenance_Tool_ImportPastedCSV_text": "Prima di utilizzare questa funzione, esegui un backup. Importa un file CSV (valori separati da virgole) contenente l'elenco dei dispositivi, comprese le relazioni di rete tra i nodi di rete e i dispositivi collegati.", "Maintenance_Tool_arpscansw": "Attiva/disattiva arp-Scan", "Maintenance_Tool_arpscansw_noti": "Attiva o disattiva arp-Scan", "Maintenance_Tool_arpscansw_noti_text": "Una volta disattivata la scansione rimane disattivata finché non viene nuovamente attivata.", @@ -655,7 +655,7 @@ "UI_REFRESH_description": "Inserisci il numero di secondi dopo il quale la UI si ricarica. Imposta a 0 per disabilitare.", "UI_REFRESH_name": "Aggiorna automaticamente la UI", "devices_old": "Aggiornamento...", - "general_event_description": "L'evento che hai attivato potrebbe richiedere del tempo prima che i processi in background vengano completati. L'esecuzione è terminata una volta che la coda di esecuzione sottostante si è svuotata (controlla il log degli errori se riscontri problemi).

Coda di esecuzione:", + "general_event_description": "L'evento che hai attivato potrebbe richiedere del tempo prima che i processi in background vengano completati. L'esecuzione è terminata una volta che la coda di esecuzione sottostante si è svuotata (controlla il log degli errori se riscontri problemi).

Coda di esecuzione:", "general_event_title": "Esecuzione di un evento ad-hoc", "report_guid": "GUID notifica:", "report_guid_missing": "Notifica collegata non trovata. C'è un piccolo ritardo tra la disponibilità delle notifiche inviate di recente e la loro disponibilità. Aggiorna la pagina e la cache dopo alcuni secondi. È anche possibile che la notifica selezionata sia stata eliminata durante la manutenzione come specificato nell'impostazione DBCLNP_NOTIFI_HIST.

Viene invece visualizzata l'ultima notifica. La notifica mancante ha il seguente GUID:", From 1fe56a80bdacd54a7348a6eefddffcd66ae2ddd9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 19 Jul 2024 11:53:47 +0000 Subject: [PATCH 04/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 7f83fe82b3d53c267504e31e790e1a3db179d61e Mon Sep 17 00:00:00 2001 From: ffsb Date: Fri, 19 Jul 2024 17:48:32 -0400 Subject: [PATCH 05/44] fixed timezone issue. --- front/plugins/omada_sdn_imp/omada_sdn.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/front/plugins/omada_sdn_imp/omada_sdn.py b/front/plugins/omada_sdn_imp/omada_sdn.py index fbbc3342..5395a6dc 100755 --- a/front/plugins/omada_sdn_imp/omada_sdn.py +++ b/front/plugins/omada_sdn_imp/omada_sdn.py @@ -4,6 +4,9 @@ __version__ = "0.1" #initial __version__ = "0.2" # added logic to retry omada api call once as it seems to sometimes fail for some reasons, and error handling logic... __version__ = "0.3" # split devices API calls to allow multithreading but had to stop due to concurency issues. __version__ = "0.6" # found issue with multithreading - my omada calls redirect stdout which gets clubbered by normal stdout... not sure how to fix for now... +__version__ = "0.7" # avoid updating omada sdn client name when it is the MAC, and naxname is also the same MAC... +__version__ = "1.0" # fixed the timzone mylog issue by resetting the tz value at the begining of the script... I suspect it doesn't inherit the tz from the main. + # query OMADA SDN to populate NetAlertX witch omada switches, access points, clients. # try to identify and populate their connections by switch/accesspoints and ports/SSID # try to differentiate root bridges from accessory @@ -38,6 +41,9 @@ from logger import mylog from const import pluginsPath, fullDbPath from helper import timeNowTZ, get_setting_value from notification import write_notification +from pytz import timezone +import conf +conf.tz = timezone(get_setting_value('TIMEZONE')) # Define the current path and log file paths CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) @@ -165,6 +171,7 @@ def add_uplink (uplink_mac, switch_mac, device_data_bymac, sadevices_linksbymac, # Main initialization def main(): start_time = time.time() + mylog('verbose', [f'[{pluginName}] starting execution']) from database import DB from device import Device_obj @@ -395,10 +402,14 @@ def get_device_data(omada_clients_output,switches_and_aps,device_handler): naxname = odevice_data[cNAME] if odevice_data[cNAME] != '' else odevice_data[cMAC] naxname = naxname.strip() mylog('debug', [f'[{pluginName}] TEST name from MAC: {naxname}']) - if odevice_data[cNAME] in (odevice_data[cMAC], 'null', ''): + if odevice_data[cNAME] in ('null', ''): mylog('verbose', [f'[{pluginName}] updating omada server because odevice_data is: {odevice_data[cNAME]} and naxname is: "{naxname}"']) callomada(['set-client-name', odevice_data[cMAC], naxname]) odevice_data_reordered[NAME] = naxname + elif odevice_data[cNAME] == odevice_data[cMAC] and ieee2ietf_mac_formater(naxname) != ieee2ietf_mac_formater(odevice_data[cNAME]) : + mylog('verbose', [f'[{pluginName}] updating omada server because odevice_data is: "{odevice_data[cNAME]} and naxname is: "{naxname}"']) + callomada(['set-client-name', odevice_data[cMAC], naxname]) + odevice_data_reordered[NAME] = naxname else: if omada_force_overwrite and naxname != odevice_data[cNAME] : mylog('verbose', [f'[{pluginName}] updating omada server because odevice_data is: "{odevice_data[cNAME]} and naxname is: "{naxname}"']) From 1a9b9e3bf776274f4f198e94e5f97183528eb6ef Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Sat, 20 Jul 2024 11:54:08 +1000 Subject: [PATCH 06/44] =?UTF-8?q?=F0=9F=94=8CTZ=20logging=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/php/templates/language/de_de.json | 0 front/php/templates/language/en_us.json | 0 front/php/templates/language/es_es.json | 0 front/php/templates/language/it_it.json | 0 front/php/templates/language/nb_no.json | 0 front/php/templates/language/pl_pl.json | 0 front/php/templates/language/ru_ru.json | 0 front/plugins/README.md | 2 +- front/plugins/__template/rename_me.py | 5 +++++ front/plugins/_publisher_apprise/apprise.py | 4 +++- front/plugins/_publisher_email/email_smtp.py | 3 +++ front/plugins/_publisher_mqtt/mqtt.py | 3 +++ front/plugins/_publisher_ntfy/ntfy.py | 3 +++ front/plugins/_publisher_pushover/pushover.py | 4 ++++ front/plugins/_publisher_pushsafer/pushsafer.py | 4 ++++ front/plugins/_publisher_webhook/webhook.py | 4 ++++ front/plugins/arp_scan/script.py | 5 +++++ front/plugins/csv_backup/script.py | 4 ++++ front/plugins/db_cleanup/script.py | 4 ++++ front/plugins/ddns_update/script.py | 4 ++++ front/plugins/dhcp_leases/script.py | 5 +++++ front/plugins/dhcp_servers/script.py | 5 +++++ front/plugins/internet_ip/script.py | 5 +++++ front/plugins/internet_speedtest/script.py | 5 +++++ front/plugins/maintenance/maintenance.py | 5 +++++ front/plugins/nbtscan_scan/nbtscan.py | 5 +++++ front/plugins/nmap_dev_scan/nmap_dev.py | 5 +++++ front/plugins/nmap_scan/script.py | 5 +++++ front/plugins/nslookup_scan/nslookup.py | 4 ++++ front/plugins/pholus_scan/script.py | 5 +++++ front/plugins/snmp_discovery/script.py | 5 +++++ front/plugins/sync/sync.py | 5 +++++ front/plugins/undiscoverables/script.py | 5 +++++ front/plugins/unifi_import/script.py | 6 ++++++ front/plugins/vendor_update/script.py | 5 +++++ front/plugins/website_monitor/script.py | 5 +++++ 36 files changed, 127 insertions(+), 2 deletions(-) mode change 100644 => 100755 front/php/templates/language/de_de.json mode change 100644 => 100755 front/php/templates/language/en_us.json mode change 100644 => 100755 front/php/templates/language/es_es.json mode change 100644 => 100755 front/php/templates/language/it_it.json mode change 100644 => 100755 front/php/templates/language/nb_no.json mode change 100644 => 100755 front/php/templates/language/pl_pl.json mode change 100644 => 100755 front/php/templates/language/ru_ru.json diff --git a/front/php/templates/language/de_de.json b/front/php/templates/language/de_de.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/es_es.json b/front/php/templates/language/es_es.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/it_it.json b/front/php/templates/language/it_it.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/nb_no.json b/front/php/templates/language/nb_no.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/pl_pl.json b/front/php/templates/language/pl_pl.json old mode 100644 new mode 100755 diff --git a/front/php/templates/language/ru_ru.json b/front/php/templates/language/ru_ru.json old mode 100644 new mode 100755 diff --git a/front/plugins/README.md b/front/plugins/README.md index b58eeb01..3e858ab1 100755 --- a/front/plugins/README.md +++ b/front/plugins/README.md @@ -20,7 +20,7 @@ NetAlertX supports additional plugins to extend its functionality, each with its ## 📑 Available Plugins - + Device-detecting plugins insert values into the `CurrentScan` database table. The plugins that are not required are safe to ignore, however, it makes sense to have at least some device-detecting plugins enabled, such as `ARPSCAN` or `NMAPDEV`. diff --git a/front/plugins/__template/rename_me.py b/front/plugins/__template/rename_me.py index e996402e..0c6e2180 100755 --- a/front/plugins/__template/rename_me.py +++ b/front/plugins/__template/rename_me.py @@ -5,6 +5,7 @@ import pathlib import sys import json import sqlite3 +from pytz import timezone # Define the installation path and extend the system path for plugin imports INSTALL_PATH = "/app" @@ -16,6 +17,10 @@ from logger import mylog from const import pluginsPath, fullDbPath from helper import timeNowTZ, get_setting_value from notification import write_notification +import conf + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) # Define the current path and log file paths CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) diff --git a/front/plugins/_publisher_apprise/apprise.py b/front/plugins/_publisher_apprise/apprise.py index 8542c6df..1a360ce0 100755 --- a/front/plugins/_publisher_apprise/apprise.py +++ b/front/plugins/_publisher_apprise/apprise.py @@ -19,8 +19,10 @@ from logger import mylog, append_line_to_file from helper import timeNowTZ, get_setting_value from notification import Notification_obj from database import DB +from pytz import timezone - +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log') diff --git a/front/plugins/_publisher_email/email_smtp.py b/front/plugins/_publisher_email/email_smtp.py index 11e6e45f..1d881e38 100755 --- a/front/plugins/_publisher_email/email_smtp.py +++ b/front/plugins/_publisher_email/email_smtp.py @@ -27,7 +27,10 @@ from logger import mylog, append_line_to_file, print_log from helper import timeNowTZ, get_setting_value, hide_email from notification import Notification_obj from database import DB +from pytz import timezone +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log') diff --git a/front/plugins/_publisher_mqtt/mqtt.py b/front/plugins/_publisher_mqtt/mqtt.py index b562af36..7ff61e62 100755 --- a/front/plugins/_publisher_mqtt/mqtt.py +++ b/front/plugins/_publisher_mqtt/mqtt.py @@ -29,7 +29,10 @@ from logger import mylog, append_line_to_file from helper import timeNowTZ, get_setting_value, bytes_to_string, sanitize_string from notification import Notification_obj from database import DB, get_device_stats +from pytz import timezone +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log') diff --git a/front/plugins/_publisher_ntfy/ntfy.py b/front/plugins/_publisher_ntfy/ntfy.py index 263b4a0e..b20f594a 100755 --- a/front/plugins/_publisher_ntfy/ntfy.py +++ b/front/plugins/_publisher_ntfy/ntfy.py @@ -22,7 +22,10 @@ from logger import mylog, append_line_to_file from helper import timeNowTZ, get_setting_value from notification import Notification_obj from database import DB +from pytz import timezone +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log') diff --git a/front/plugins/_publisher_pushover/pushover.py b/front/plugins/_publisher_pushover/pushover.py index c03dd883..21898d73 100755 --- a/front/plugins/_publisher_pushover/pushover.py +++ b/front/plugins/_publisher_pushover/pushover.py @@ -16,6 +16,10 @@ from notification import Notification_obj # noqa: E402 from database import DB # noqa: E402 import conf from const import confFileName +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) RESULT_FILE = os.path.join(CUR_PATH, "last_result.log") diff --git a/front/plugins/_publisher_pushsafer/pushsafer.py b/front/plugins/_publisher_pushsafer/pushsafer.py index f99312f6..e55a9beb 100755 --- a/front/plugins/_publisher_pushsafer/pushsafer.py +++ b/front/plugins/_publisher_pushsafer/pushsafer.py @@ -22,6 +22,10 @@ from logger import mylog, append_line_to_file from helper import timeNowTZ, get_setting_value, hide_string from notification import Notification_obj from database import DB +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log') diff --git a/front/plugins/_publisher_webhook/webhook.py b/front/plugins/_publisher_webhook/webhook.py index 8b995ae7..bc298e15 100755 --- a/front/plugins/_publisher_webhook/webhook.py +++ b/front/plugins/_publisher_webhook/webhook.py @@ -25,6 +25,10 @@ from logger import mylog, append_line_to_file from helper import timeNowTZ, get_setting_value, hide_string, write_file from notification import Notification_obj from database import DB +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log') diff --git a/front/plugins/arp_scan/script.py b/front/plugins/arp_scan/script.py index ffea6cb4..b25fa216 100755 --- a/front/plugins/arp_scan/script.py +++ b/front/plugins/arp_scan/script.py @@ -18,6 +18,11 @@ from plugin_helper import Plugin_Object, Plugin_Objects, handleEmpty from logger import mylog, append_line_to_file from helper import timeNowTZ, get_setting_value from const import logPath, applicationPath +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) LOG_FILE = os.path.join(CUR_PATH, 'script.log') diff --git a/front/plugins/csv_backup/script.py b/front/plugins/csv_backup/script.py index a4b8be21..cc727a3e 100755 --- a/front/plugins/csv_backup/script.py +++ b/front/plugins/csv_backup/script.py @@ -18,7 +18,11 @@ from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file from helper import timeNowTZ from const import logPath, applicationPath, fullDbPath +import conf +from pytz import timezone +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) LOG_FILE = os.path.join(CUR_PATH, 'script.log') diff --git a/front/plugins/db_cleanup/script.py b/front/plugins/db_cleanup/script.py index 2979b0fb..0ef2c732 100755 --- a/front/plugins/db_cleanup/script.py +++ b/front/plugins/db_cleanup/script.py @@ -18,7 +18,11 @@ from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file from helper import timeNowTZ, get_setting_value from const import logPath, applicationPath, fullDbPath +import conf +from pytz import timezone +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) LOG_FILE = os.path.join(CUR_PATH, 'script.log') diff --git a/front/plugins/ddns_update/script.py b/front/plugins/ddns_update/script.py index f216a6bb..9afaec6c 100755 --- a/front/plugins/ddns_update/script.py +++ b/front/plugins/ddns_update/script.py @@ -21,7 +21,11 @@ from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file from helper import timeNowTZ, check_IP_format from const import logPath, applicationPath, fullDbPath +import conf +from pytz import timezone +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) LOG_FILE = os.path.join(CUR_PATH, 'script.log') diff --git a/front/plugins/dhcp_leases/script.py b/front/plugins/dhcp_leases/script.py index 60432166..12fd29f9 100755 --- a/front/plugins/dhcp_leases/script.py +++ b/front/plugins/dhcp_leases/script.py @@ -15,6 +15,11 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, handleEmpty, is_mac from logger import mylog from dhcp_leases import DhcpLeases +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) LOG_FILE = os.path.join(CUR_PATH, 'script.log') diff --git a/front/plugins/dhcp_servers/script.py b/front/plugins/dhcp_servers/script.py index e2bb29b1..4e1e4d3f 100755 --- a/front/plugins/dhcp_servers/script.py +++ b/front/plugins/dhcp_servers/script.py @@ -12,6 +12,11 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Objects, Plugin_Object from logger import mylog +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) def main(): diff --git a/front/plugins/internet_ip/script.py b/front/plugins/internet_ip/script.py index 3c1ab38e..285bdef2 100755 --- a/front/plugins/internet_ip/script.py +++ b/front/plugins/internet_ip/script.py @@ -22,6 +22,11 @@ from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file from helper import timeNowTZ, check_IP_format, get_setting_value from const import logPath, applicationPath, fullDbPath +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) diff --git a/front/plugins/internet_speedtest/script.py b/front/plugins/internet_speedtest/script.py index 7029edde..ea948d66 100755 --- a/front/plugins/internet_speedtest/script.py +++ b/front/plugins/internet_speedtest/script.py @@ -14,6 +14,11 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Objects from logger import mylog, append_line_to_file from helper import timeNowTZ +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log') diff --git a/front/plugins/maintenance/maintenance.py b/front/plugins/maintenance/maintenance.py index 24d7fe8a..3fe6d3e4 100755 --- a/front/plugins/maintenance/maintenance.py +++ b/front/plugins/maintenance/maintenance.py @@ -19,6 +19,11 @@ from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file from helper import timeNowTZ, get_setting_value from const import logPath, applicationPath +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) diff --git a/front/plugins/nbtscan_scan/nbtscan.py b/front/plugins/nbtscan_scan/nbtscan.py index 1ac29f9b..91e5fe5f 100755 --- a/front/plugins/nbtscan_scan/nbtscan.py +++ b/front/plugins/nbtscan_scan/nbtscan.py @@ -19,6 +19,11 @@ from helper import timeNowTZ, get_setting_value from notification import write_notification from database import DB from device import Device_obj +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) # Define the current path and log file paths CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) diff --git a/front/plugins/nmap_dev_scan/nmap_dev.py b/front/plugins/nmap_dev_scan/nmap_dev.py index aad6f769..a2e2c6e6 100755 --- a/front/plugins/nmap_dev_scan/nmap_dev.py +++ b/front/plugins/nmap_dev_scan/nmap_dev.py @@ -25,6 +25,11 @@ from helper import timeNowTZ, get_setting_value, extract_between_strings, extrac from const import logPath, applicationPath, fullDbPath from database import DB from device import Device_obj +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) diff --git a/front/plugins/nmap_scan/script.py b/front/plugins/nmap_scan/script.py index 5db4306c..b93225cf 100755 --- a/front/plugins/nmap_scan/script.py +++ b/front/plugins/nmap_scan/script.py @@ -17,6 +17,11 @@ from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file from helper import timeNowTZ from const import logPath, applicationPath +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) LOG_FILE = os.path.join(CUR_PATH, 'script.log') diff --git a/front/plugins/nslookup_scan/nslookup.py b/front/plugins/nslookup_scan/nslookup.py index 68649cfc..ad1cd7ea 100755 --- a/front/plugins/nslookup_scan/nslookup.py +++ b/front/plugins/nslookup_scan/nslookup.py @@ -24,7 +24,11 @@ from helper import timeNowTZ, get_setting_value from const import logPath, applicationPath, fullDbPath from database import DB from device import Device_obj +import conf +from pytz import timezone +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) LOG_FILE = os.path.join(CUR_PATH, 'script.log') diff --git a/front/plugins/pholus_scan/script.py b/front/plugins/pholus_scan/script.py index 2c7d4171..dc0da874 100755 --- a/front/plugins/pholus_scan/script.py +++ b/front/plugins/pholus_scan/script.py @@ -18,6 +18,11 @@ from logger import mylog from plugin_helper import Plugin_Object, Plugin_Objects from helper import timeNowTZ from const import logPath, applicationPath +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) LOG_FILE = os.path.join(CUR_PATH, 'script.log') diff --git a/front/plugins/snmp_discovery/script.py b/front/plugins/snmp_discovery/script.py index f4bfa0c0..18c80bc1 100755 --- a/front/plugins/snmp_discovery/script.py +++ b/front/plugins/snmp_discovery/script.py @@ -15,6 +15,11 @@ from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64, handleEmp from logger import mylog from helper import timeNowTZ from const import logPath, applicationPath +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log') diff --git a/front/plugins/sync/sync.py b/front/plugins/sync/sync.py index dae53408..32440884 100755 --- a/front/plugins/sync/sync.py +++ b/front/plugins/sync/sync.py @@ -20,6 +20,11 @@ from const import pluginsPath, fullDbPath from helper import timeNowTZ, get_setting_value from cryptography import encrypt_data from notification import write_notification +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) # Define the current path and log file paths CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) diff --git a/front/plugins/undiscoverables/script.py b/front/plugins/undiscoverables/script.py index cd6c6e46..abf22b7b 100755 --- a/front/plugins/undiscoverables/script.py +++ b/front/plugins/undiscoverables/script.py @@ -15,6 +15,11 @@ from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file from helper import timeNowTZ from const import logPath, applicationPath +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) LOG_FILE = os.path.join(CUR_PATH, 'script.log') diff --git a/front/plugins/unifi_import/script.py b/front/plugins/unifi_import/script.py index 7729a3be..fc469a00 100755 --- a/front/plugins/unifi_import/script.py +++ b/front/plugins/unifi_import/script.py @@ -14,12 +14,18 @@ from requests import Request, Session, packages from requests.packages.urllib3.exceptions import InsecureRequestWarning from pyunifi.controller import Controller + # Register NetAlertX directories INSTALL_PATH="/app" sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects from logger import mylog +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) LOG_FILE = os.path.join(CUR_PATH, 'script.log') diff --git a/front/plugins/vendor_update/script.py b/front/plugins/vendor_update/script.py index 41d61d4f..31c429e3 100755 --- a/front/plugins/vendor_update/script.py +++ b/front/plugins/vendor_update/script.py @@ -20,6 +20,11 @@ from logger import mylog, append_line_to_file from helper import timeNowTZ from const import logPath, applicationPath, fullDbPath from device import query_MAC_vendor +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) diff --git a/front/plugins/website_monitor/script.py b/front/plugins/website_monitor/script.py index 5d809698..05d98117 100755 --- a/front/plugins/website_monitor/script.py +++ b/front/plugins/website_monitor/script.py @@ -15,6 +15,11 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Objects from datetime import datetime from const import logPath +import conf +from pytz import timezone + +# Make sure the TIMEZONE for logging is correct +conf.tz = timezone(get_setting_value('TIMEZONE')) CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) RESULT_FILE = os.path.join(CUR_PATH, 'last_result.log') From 3e35f08d6c853f025d65363810ea404ed5ce7cc3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 20 Jul 2024 11:53:39 +0000 Subject: [PATCH 07/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 33058289475c57e48ee7a634722bf6dd391728e7 Mon Sep 17 00:00:00 2001 From: ffsb Date: Sat, 20 Jul 2024 13:26:49 -0400 Subject: [PATCH 08/44] 1.1 handle failed omada devices calls. --- front/plugins/omada_sdn_imp/testre.py | 45 ++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/front/plugins/omada_sdn_imp/testre.py b/front/plugins/omada_sdn_imp/testre.py index 544e7858..4e382fe7 100644 --- a/front/plugins/omada_sdn_imp/testre.py +++ b/front/plugins/omada_sdn_imp/testre.py @@ -192,4 +192,47 @@ def testparalel(): print(f"arg:{arg}, result={results[arg]}, result2={results2[arg]}") -testparalel() \ No newline at end of file +#testparalel() + + + +import netifaces +import ipaddress + +def get_interfaces_and_subnets(): + result = [] + for interface in netifaces.interfaces(): + addrs = netifaces.ifaddresses(interface) + if netifaces.AF_INET in addrs: + for addr in addrs[netifaces.AF_INET]: + ip = addr['addr'] + mask = addr['netmask'] + try: + network = ipaddress.IPv4Network(f"{ip}/{mask}", strict=False) + result.append((interface, str(network))) + except ValueError: + pass + return result + +# Example usage: +interfaces_and_subnets = get_interfaces_and_subnets() +for interface, subnet in interfaces_and_subnets: + print(f"interface={interface}, subnet={subnet}") + + +''' +interface=lo, subnet=127.0.0.0/8 +interface=enp6s0, subnet=192.168.0.0/24 +interface=br-ba0070d71f2a, subnet=172.16.0.16/29 +interface=br-bc4a4c4e0f93, subnet=172.16.0.40/29 +interface=br-e043e0ae9c8c, subnet=172.16.0.72/29 +interface=br-6acc3945cfba, subnet=172.16.0.48/29 +interface=br-6f931807e709, subnet=172.16.0.80/29 +interface=docker0, subnet=172.17.0.0/16 +interface=br-9ce2cb7c38c3, subnet=172.16.0.24/29 +interface=br-eec81501f666, subnet=172.16.0.32/29 +interface=br-1064712a4791, subnet=172.16.0.56/29 +interface=br-a93ebdba2a28, subnet=172.16.0.8/29 +interface=br-d8fa7a3015e2, subnet=172.16.0.64/29 +interface=br-e7cdd041d3d3, subnet=172.16.0.0/29 +''' \ No newline at end of file From 43759b6b7d5fd716a242a939ef15810a671fdd4d Mon Sep 17 00:00:00 2001 From: ffsb Date: Sat, 20 Jul 2024 13:28:43 -0400 Subject: [PATCH 09/44] na --- front/plugins/omada_sdn_imp/omada_sdn.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/front/plugins/omada_sdn_imp/omada_sdn.py b/front/plugins/omada_sdn_imp/omada_sdn.py index 5395a6dc..5e9bfe9f 100755 --- a/front/plugins/omada_sdn_imp/omada_sdn.py +++ b/front/plugins/omada_sdn_imp/omada_sdn.py @@ -6,6 +6,8 @@ __version__ = "0.3" # split devices API calls to allow multithreading but had t __version__ = "0.6" # found issue with multithreading - my omada calls redirect stdout which gets clubbered by normal stdout... not sure how to fix for now... __version__ = "0.7" # avoid updating omada sdn client name when it is the MAC, and naxname is also the same MAC... __version__ = "1.0" # fixed the timzone mylog issue by resetting the tz value at the begining of the script... I suspect it doesn't inherit the tz from the main. +__version__ = "1.1" # added logic to handle gracefully a failure of omada devices so it won't try to populate uplinks on non-existent switches and AP. + # query OMADA SDN to populate NetAlertX witch omada switches, access points, clients. # try to identify and populate their connections by switch/accesspoints and ports/SSID @@ -454,7 +456,8 @@ def get_device_data(omada_clients_output,switches_and_aps,device_handler): # step4, let's go recursively through switches other links to mark update their uplinks # and pray it ends one day... # - add_uplink(default_router_mac,first_switch, device_data_bymac,sadevices_linksbymac,port_byswitchmac_byclientmac) + if len(sadevices) > 0: + add_uplink(default_router_mac,first_switch, device_data_bymac,sadevices_linksbymac,port_byswitchmac_byclientmac) return device_data_bymac.values() if __name__ == '__main__': From 54b6b1d408b04733b52fac9449719d7b2041463e Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Sun, 21 Jul 2024 11:42:59 +1000 Subject: [PATCH 10/44] =?UTF-8?q?=F0=9F=8E=A8Guess=20icons=20#738?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/plugins/csv_backup/script.py | 2 +- front/plugins/ddns_update/script.py | 2 +- front/plugins/dhcp_leases/script.py | 1 + front/plugins/dhcp_servers/script.py | 1 + front/plugins/internet_speedtest/script.py | 2 +- front/plugins/nmap_scan/script.py | 2 +- front/plugins/pholus_scan/script.py | 2 +- front/plugins/snmp_discovery/script.py | 2 +- front/plugins/undiscoverables/script.py | 2 +- front/plugins/unifi_import/script.py | 1 + front/plugins/vendor_update/script.py | 2 +- front/plugins/website_monitor/script.py | 1 + server/device.py | 224 +++++++++++++++------ server/initialise.py | 2 +- 14 files changed, 170 insertions(+), 76 deletions(-) diff --git a/front/plugins/csv_backup/script.py b/front/plugins/csv_backup/script.py index cc727a3e..8cc9ec9f 100755 --- a/front/plugins/csv_backup/script.py +++ b/front/plugins/csv_backup/script.py @@ -16,7 +16,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file -from helper import timeNowTZ +from helper import timeNowTZ, get_setting_value from const import logPath, applicationPath, fullDbPath import conf from pytz import timezone diff --git a/front/plugins/ddns_update/script.py b/front/plugins/ddns_update/script.py index 9afaec6c..ea869801 100755 --- a/front/plugins/ddns_update/script.py +++ b/front/plugins/ddns_update/script.py @@ -19,7 +19,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file -from helper import timeNowTZ, check_IP_format +from helper import timeNowTZ, get_setting_value, check_IP_format from const import logPath, applicationPath, fullDbPath import conf from pytz import timezone diff --git a/front/plugins/dhcp_leases/script.py b/front/plugins/dhcp_leases/script.py index 12fd29f9..1353aad5 100755 --- a/front/plugins/dhcp_leases/script.py +++ b/front/plugins/dhcp_leases/script.py @@ -15,6 +15,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, handleEmpty, is_mac from logger import mylog from dhcp_leases import DhcpLeases +from helper import timeNowTZ, get_setting_value import conf from pytz import timezone diff --git a/front/plugins/dhcp_servers/script.py b/front/plugins/dhcp_servers/script.py index 4e1e4d3f..28afd207 100755 --- a/front/plugins/dhcp_servers/script.py +++ b/front/plugins/dhcp_servers/script.py @@ -12,6 +12,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Objects, Plugin_Object from logger import mylog +from helper import timeNowTZ, get_setting_value import conf from pytz import timezone diff --git a/front/plugins/internet_speedtest/script.py b/front/plugins/internet_speedtest/script.py index ea948d66..5ea90963 100755 --- a/front/plugins/internet_speedtest/script.py +++ b/front/plugins/internet_speedtest/script.py @@ -13,7 +13,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Objects from logger import mylog, append_line_to_file -from helper import timeNowTZ +from helper import timeNowTZ, get_setting_value import conf from pytz import timezone diff --git a/front/plugins/nmap_scan/script.py b/front/plugins/nmap_scan/script.py index b93225cf..1dcffbd9 100755 --- a/front/plugins/nmap_scan/script.py +++ b/front/plugins/nmap_scan/script.py @@ -15,7 +15,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file -from helper import timeNowTZ +from helper import timeNowTZ, get_setting_value from const import logPath, applicationPath import conf from pytz import timezone diff --git a/front/plugins/pholus_scan/script.py b/front/plugins/pholus_scan/script.py index dc0da874..66185878 100755 --- a/front/plugins/pholus_scan/script.py +++ b/front/plugins/pholus_scan/script.py @@ -16,7 +16,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from logger import mylog from plugin_helper import Plugin_Object, Plugin_Objects -from helper import timeNowTZ +from helper import timeNowTZ, get_setting_value from const import logPath, applicationPath import conf from pytz import timezone diff --git a/front/plugins/snmp_discovery/script.py b/front/plugins/snmp_discovery/script.py index 18c80bc1..0fcb1ea6 100755 --- a/front/plugins/snmp_discovery/script.py +++ b/front/plugins/snmp_discovery/script.py @@ -13,7 +13,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64, handleEmpty, normalize_mac from logger import mylog -from helper import timeNowTZ +from helper import timeNowTZ, get_setting_value from const import logPath, applicationPath import conf from pytz import timezone diff --git a/front/plugins/undiscoverables/script.py b/front/plugins/undiscoverables/script.py index abf22b7b..2ad03361 100755 --- a/front/plugins/undiscoverables/script.py +++ b/front/plugins/undiscoverables/script.py @@ -13,7 +13,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 from logger import mylog, append_line_to_file -from helper import timeNowTZ +from helper import timeNowTZ, get_setting_value from const import logPath, applicationPath import conf from pytz import timezone diff --git a/front/plugins/unifi_import/script.py b/front/plugins/unifi_import/script.py index fc469a00..94871f08 100755 --- a/front/plugins/unifi_import/script.py +++ b/front/plugins/unifi_import/script.py @@ -21,6 +21,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects from logger import mylog +from helper import timeNowTZ, get_setting_value import conf from pytz import timezone diff --git a/front/plugins/vendor_update/script.py b/front/plugins/vendor_update/script.py index 31c429e3..f1721cb6 100755 --- a/front/plugins/vendor_update/script.py +++ b/front/plugins/vendor_update/script.py @@ -17,7 +17,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64, handleEmpty from logger import mylog, append_line_to_file -from helper import timeNowTZ +from helper import timeNowTZ, get_setting_value from const import logPath, applicationPath, fullDbPath from device import query_MAC_vendor import conf diff --git a/front/plugins/website_monitor/script.py b/front/plugins/website_monitor/script.py index 05d98117..d9a32d07 100755 --- a/front/plugins/website_monitor/script.py +++ b/front/plugins/website_monitor/script.py @@ -15,6 +15,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) from plugin_helper import Plugin_Objects from datetime import datetime from const import logPath +from helper import timeNowTZ, get_setting_value import conf from pytz import timezone diff --git a/server/device.py b/server/device.py index 3445920e..e2b24e5f 100755 --- a/server/device.py +++ b/server/device.py @@ -171,40 +171,48 @@ def create_new_devices (db): mylog('debug','[New Devices] 2 Create devices') # default New Device values preparation - newDevColumns = """dev_AlertEvents, - dev_AlertDeviceDown, - dev_PresentLastScan, - dev_Archived, - dev_NewDevice, - dev_SkipRepeated, - dev_ScanCycle, - dev_Owner, - dev_Favorite, - dev_Group, - dev_Comments, - dev_LogEvents, - dev_Location, - dev_Icon""" + newDevColumns = """dev_AlertEvents, + dev_AlertDeviceDown, + dev_PresentLastScan, + dev_Archived, + dev_NewDevice, + dev_SkipRepeated, + dev_ScanCycle, + dev_Owner, + dev_Favorite, + dev_Group, + dev_Comments, + dev_LogEvents, + dev_Location""" - newDevDefaults = f"""{get_setting_value('NEWDEV_dev_AlertEvents')}, - {get_setting_value('NEWDEV_dev_AlertDeviceDown')}, - {get_setting_value('NEWDEV_dev_PresentLastScan')}, - {get_setting_value('NEWDEV_dev_Archived')}, - {get_setting_value('NEWDEV_dev_NewDevice')}, - {get_setting_value('NEWDEV_dev_SkipRepeated')}, - {get_setting_value('NEWDEV_dev_ScanCycle')}, - '{get_setting_value('NEWDEV_dev_Owner')}', - {get_setting_value('NEWDEV_dev_Favorite')}, - '{get_setting_value('NEWDEV_dev_Group')}', - '{get_setting_value('NEWDEV_dev_Comments')}', - {get_setting_value('NEWDEV_dev_LogEvents')}, - '{get_setting_value('NEWDEV_dev_Location')}', - '{get_setting_value('NEWDEV_dev_Icon')}' - """ + newDevDefaults = f"""{get_setting_value('NEWDEV_dev_AlertEvents')}, + {get_setting_value('NEWDEV_dev_AlertDeviceDown')}, + {get_setting_value('NEWDEV_dev_PresentLastScan')}, + {get_setting_value('NEWDEV_dev_Archived')}, + {get_setting_value('NEWDEV_dev_NewDevice')}, + {get_setting_value('NEWDEV_dev_SkipRepeated')}, + {get_setting_value('NEWDEV_dev_ScanCycle')}, + '{get_setting_value('NEWDEV_dev_Owner')}', + {get_setting_value('NEWDEV_dev_Favorite')}, + '{get_setting_value('NEWDEV_dev_Group')}', + '{get_setting_value('NEWDEV_dev_Comments')}', + {get_setting_value('NEWDEV_dev_LogEvents')}, + '{get_setting_value('NEWDEV_dev_Location')}'""" - # Bulk-inserting devices from the CurrentScan table as new devices in the table Devices ... - # ... with new device defaults and ignoring specidfied IPs and MACs) - sqlQuery = f"""INSERT OR IGNORE INTO Devices + # Fetch data from CurrentScan + current_scan_data = sql.execute("SELECT cur_MAC, cur_Name, cur_Vendor, cur_IP, cur_SyncHubNodeName, cur_NetworkNodeMAC, cur_PORT, cur_NetworkSite, cur_SSID, cur_Type FROM CurrentScan").fetchall() + + for row in current_scan_data: + cur_MAC, cur_Name, cur_Vendor, cur_IP, cur_SyncHubNodeName, cur_NetworkNodeMAC, cur_PORT, cur_NetworkSite, cur_SSID, cur_Type = row + + # Handle NoneType + cur_Name = cur_Name.strip() if cur_Name else '(unknown)' + cur_Type = cur_Type.strip() if cur_Type else get_setting_value("NEWDEV_dev_DeviceType") + cur_NetworkNodeMAC = cur_NetworkNodeMAC.strip() if cur_NetworkNodeMAC else '' + cur_NetworkNodeMAC = cur_NetworkNodeMAC if cur_NetworkNodeMAC and cur_MAC != "Internet" else (get_setting_value("NEWDEV_dev_Network_Node_MAC_ADDR") if cur_MAC != "Internet" else "null") + + # Preparing the individual insert statement + sqlQuery = f"""INSERT OR IGNORE INTO Devices ( dev_MAC, dev_name, @@ -221,44 +229,28 @@ def create_new_devices (db): dev_DeviceType, {newDevColumns} ) - SELECT - cur_MAC, - CASE - WHEN LENGTH(TRIM(cur_Name)) > 0 THEN cur_Name ELSE '(unknown)' - END, - cur_Vendor, - cur_IP, + VALUES + ( + '{cur_MAC}', + '{cur_Name}', + '{cur_Vendor}', + '{cur_IP}', ?, ?, - cur_SyncHubNodeName, - {sql_generateGuid}, - CASE - WHEN LENGTH(TRIM(cur_NetworkNodeMAC)) > 0 - AND cur_MAC != 'Internet' - THEN cur_NetworkNodeMAC - ELSE - CASE - WHEN cur_MAC = 'Internet' - THEN 'null' - ELSE '{get_setting_value('NEWDEV_dev_Network_Node_MAC_ADDR')}' - END - END, - cur_PORT, - cur_NetworkSite, - cur_SSID, - CASE - WHEN LENGTH(TRIM(cur_Type)) > 0 THEN cur_Type ELSE '{get_setting_value('NEWDEV_dev_DeviceType')}' - END, + '{cur_SyncHubNodeName}', + {sql_generateGuid}, + '{cur_NetworkNodeMAC}', + '{cur_PORT}', + '{cur_NetworkSite}', + '{cur_SSID}', + '{cur_Type}', {newDevDefaults} - FROM CurrentScan - WHERE 1=1 - {list_to_where('OR', 'cur_MAC', 'NOT LIKE', get_setting_value('NEWDEV_ignored_MACs'))} - {list_to_where('OR', 'cur_IP', 'NOT LIKE', get_setting_value('NEWDEV_ignored_IPs'))} - """ + )""" - mylog('debug',f'[New Devices] Create devices SQL: {sqlQuery}') + mylog('trace', f'[New Devices] Create device SQL: {sqlQuery}') + + sql.execute(sqlQuery, (startTime, startTime)) - sql.execute (sqlQuery, (startTime, startTime) ) mylog('debug','[New Devices] New Devices end') db.commitDB() @@ -410,6 +402,7 @@ def update_devices_data_from_scan (db): AND cur_Name <> '' ) """) + # Update VENDORS recordsToUpdate = [] query = """SELECT * FROM Devices WHERE dev_Vendor = '(unknown)' OR dev_Vendor ='' @@ -420,8 +413,24 @@ def update_devices_data_from_scan (db): if vendor != -1 and vendor != -2 : recordsToUpdate.append ([vendor, device['dev_MAC']]) - sql.executemany ("UPDATE Devices SET dev_Vendor = ? WHERE dev_MAC = ? ", - recordsToUpdate ) + if len(recordsToUpdate) > 0: + sql.executemany ("UPDATE Devices SET dev_Vendor = ? WHERE dev_MAC = ? ", recordsToUpdate ) + + # Guess ICONS + recordsToUpdate = [] + query = """SELECT * FROM Devices + WHERE dev_Icon in ('', 'null') + OR dev_Icon IS NULL""" + default_icon = get_setting_value('NEWDEV_dev_Icon') + + for device in sql.execute (query) : + # Conditional logic for dev_Icon guessing + dev_Icon = guess_icon(device['dev_Vendor'], device['dev_MAC'], device['dev_LastIP'], device['dev_Name'], default_icon) + + recordsToUpdate.append ([dev_Icon, device['dev_MAC']]) + + if len(recordsToUpdate) > 0: + sql.executemany ("UPDATE Devices SET dev_Icon = ? WHERE dev_MAC = ? ", recordsToUpdate ) mylog('debug','[Update Devices] Update devices end') @@ -582,3 +591,84 @@ def query_MAC_vendor (pMAC): mylog('none', [f"[Vendor Check] ⚠ ERROR: Vendors file {vendorsPath} not found."]) return -1 + +#=============================================================================== +# Icons +#=============================================================================== +#------------------------------------------------------------------------------- +# Base64 encoded HTML string for FontAwesome icons +icons = { + "globe": "PGkgY2xhc3M9ImZhcyBmYS1nbG9iZSI+PC9pPg==", # globe icon + "phone": "PGkgY2xhc3M9ImZhcyBmYS1tb2JpbGUtYWx0Ij48L2k+", + "laptop": "PGkgY2xhc3M9ImZhIGZhLWxhcHRvcCI+PC9pPg==", + "printer": "PGkgY2xhc3M9ImZhIGZhLXByaW50ZXIiPjwvaT4=", + "router": "PGkgY2xhc3M9ImZhcyBmYS1yYW5kb20iPjwvaT4=", + "tv": "PGkgY2xhc3M9ImZhIGZhLXR2Ij48L2k+", + "desktop": "PGkgY2xhc3M9ImZhIGZhLWRlc2t0b3AiPjwvaT4=", + "tablet": "PGkgY2xhc3M9ImZhIGZhLXRhYmxldCI+PC9pPg==", + "watch": "PGkgY2xhc3M9ImZhIGZhLXdhbmNoIj48L2k+", + "camera": "PGkgY2xhc3M9ImZhIGZhLWNhbWVyYSI+PC9pPg==", + "home": "PGkgY2xhc3M9ImZhIGZhLWhvbWUiPjwvaT4=", + "apple": "PGkgY2xhc3M9ImZhYiBmYS1hcHBsZSI+PC9pPg==", + "ethernet": "PGkgY2xhc3M9ImZhcyBmYS1ldGhlcm5ldCI+PC9pPg==", + "google": "PGkgY2xhc3M9ImZhYiBmYS1nb29nbGUiPjwvaT4=", + "raspberry": "PGkgY2xhc3M9ImZhYiBmYS1yYXNwYmVycnktcGkiPjwvaT4=", + "microchip": "PGkgY2xhc3M9ImZhcyBmYS1taWNyb2NoaXAiPjwvaT4=" +} + +#------------------------------------------------------------------------------- +# Guess device icon +def guess_icon(vendor, mac, ip, name, default): + result = default + mac = mac.upper() + vendor = vendor.lower() + name = name.lower() + + # Guess icon based on vendor + if any(brand in vendor for brand in {"samsung", "motorola"}): + result = icons.get("phone") + elif "dell" in vendor: + result = icons.get("laptop") + elif "hp" in vendor: + result = icons.get("printer") + elif "cisco" in vendor: + result = icons.get("router") + elif "lg" in vendor: + result = icons.get("tv") + elif "raspberry" in vendor: + result = icons.get("raspberry") + elif "apple" in vendor: + result = icons.get("apple") + elif "google" in vendor: + result = icons.get("google") + elif "ubiquiti" in vendor: + result = icons.get("router") + elif any(brand in vendor for brand in {"espressif"}): + result = icons.get("microchip") + + # Guess icon based on MAC address patterns + elif mac == "INTERNET": # Apple + result = icons.get("globe") + elif mac.startswith("00:1A:79"): # Apple + result = icons.get("apple") + elif mac.startswith("B0:BE:83"): # Apple + result = icons.get("apple") + elif mac.startswith("00:1B:63"): # Sony + result = icons.get("tablet") + elif mac.startswith("74:AC:B9"): # Unifi + result = icons.get("ethernet") + + + # Guess icon based on name + elif 'google' in name: + result = icons.get("google") + elif 'desktop' in name: + result = icons.get("desktop") + + # Guess icon based on IP address ranges + elif ip.startswith("192.168.1."): + result = icons.get("laptop") + + + return result + \ No newline at end of file diff --git a/server/initialise.py b/server/initialise.py index a53b84ba..e6cabe66 100755 --- a/server/initialise.py +++ b/server/initialise.py @@ -145,7 +145,7 @@ def importConfigs (db, all_plugins): # UI conf.UI_LANG = ccd('UI_LANG', 'English' , c_d, 'Language Interface', '{"dataType":"string", "elements": [{"elementType" : "select", "elementOptions" : [] ,"transformers": []}]}', "['English', 'French', 'German', 'Norwegian', 'Russian', 'Spanish', 'Italian (it_it)', 'Portuguese (pt_br)', 'Polish (pl_pl)', 'Turkish (tr_tr)', 'Chinese (zh_cn)' ]", 'UI') conf.UI_NOT_RANDOM_MAC = ccd('UI_NOT_RANDOM_MAC', [] , c_d, 'Exlude from Random Prefix', '{"dataType": "array","elements": [ {"elementType": "input","elementOptions": [{ "placeholder": "Enter value" },{ "suffix": "_in" },{ "cssClasses": "col-sm-10" },{ "prefillValue": "null" }],"transformers": [] }, {"elementType": "button","elementOptions": [{ "sourceSuffixes": ["_in"] },{ "separator": "" },{ "cssClasses": "col-xs-12" },{ "onClick": "addList(this, false)" },{ "getStringKey": "Gen_Add" }],"transformers": [] }, {"elementType": "button","elementOptions": [{ "sourceSuffixes": [] },{ "separator": "" },{ "cssClasses": "col-xs-6" },{ "onClick": "removeAllOptions(this)" },{ "getStringKey": "Gen_Remove_All" }],"transformers": []},{"elementType": "button","elementOptions": [{ "sourceSuffixes": [] },{ "separator": "" },{ "cssClasses": "col-xs-6" },{ "onClick": "removeFromList(this)" },{ "getStringKey": "Gen_Remove_Last" }],"transformers": []}, {"elementType": "select","elementOptions": [{ "multiple": "true" },{ "readonly": "true" },{ "editable": "true" }],"transformers": [] }]}', "[]", 'UI') - conf.UI_ICONS = ccd('UI_ICONS', ['PGkgY2xhc3M9ImZhIGZhLWNvbXB1dGVyIj48L2k+', 'PGkgY2xhc3M9ImZhIGZhLWV0aGVybmV0Ij48L2k+', 'PGkgY2xhc3M9ImZhIGZhLWdhbWVwYWQiPjwvaT4', 'PGkgY2xhc3M9ImZhIGZhLWdsb2JlIj48L2k+', 'PGkgY2xhc3M9ImZhIGZhLWxhcHRvcCI+PC9pPg==', 'PGkgY2xhc3M9ImZhIGZhLWxpZ2h0YnVsYiI+PC9pPg==', 'PGkgY2xhc3M9ImZhIGZhLXNoaWVsZCI+PC9pPg==', 'PGkgY2xhc3M9ImZhIGZhLXdpZmkiPjwvaT4'] , c_d, 'Icons', '{"dataType": "array","elements": [ {"elementType": "input","elementOptions": [{ "placeholder": "Enter value" },{ "suffix": "_in" },{ "cssClasses": "col-sm-10" },{ "prefillValue": "null" }],"transformers": [] }, {"elementType": "button","elementOptions": [{ "sourceSuffixes": ["_in"] },{ "separator": "" },{ "cssClasses": "col-xs-12" },{ "onClick": "addList(this, false)" },{ "getStringKey": "Gen_Add" }],"transformers": [] }, {"elementType": "button","elementOptions": [{ "sourceSuffixes": [] },{ "separator": "" },{ "cssClasses": "col-xs-6" },{ "onClick": "removeAllOptions(this)" },{ "getStringKey": "Gen_Remove_All" }],"transformers": []},{"elementType": "button","elementOptions": [{ "sourceSuffixes": [] },{ "separator": "" },{ "cssClasses": "col-xs-6" },{ "onClick": "removeFromList(this)" },{ "getStringKey": "Gen_Remove_Last" }],"transformers": []}, {"elementType": "select","elementOptions": [{ "multiple": "true" },{ "readonly": "true" },{ "editable": "true" }],"transformers": [] }]}', "[]", 'UI') + conf.UI_ICONS = ccd('UI_ICONS', ['PGkgY2xhc3M9J2ZhIGZhLXdpZmknPjwvaT4=', 'PGkgY2xhc3M9ImZhIGZhLWNvbXB1dGVyIj48L2k+', 'PGkgY2xhc3M9ImZhIGZhLWV0aGVybmV0Ij48L2k+', 'PGkgY2xhc3M9ImZhIGZhLWdhbWVwYWQiPjwvaT4', 'PGkgY2xhc3M9ImZhIGZhLWdsb2JlIj48L2k+', 'PGkgY2xhc3M9ImZhIGZhLWxhcHRvcCI+PC9pPg==', 'PGkgY2xhc3M9ImZhIGZhLWxpZ2h0YnVsYiI+PC9pPg==', 'PGkgY2xhc3M9ImZhIGZhLXNoaWVsZCI+PC9pPg==', 'PGkgY2xhc3M9ImZhIGZhLXdpZmkiPjwvaT4', 'PGkgY2xhc3M9J2ZhIGZhLWdhbWVwYWQnPjwvaT4'] , c_d, 'Icons', '{"dataType": "array","elements": [ {"elementType": "input","elementOptions": [{ "placeholder": "Enter value" },{ "suffix": "_in" },{ "cssClasses": "col-sm-10" },{ "prefillValue": "null" }],"transformers": [] }, {"elementType": "button","elementOptions": [{ "sourceSuffixes": ["_in"] },{ "separator": "" },{ "cssClasses": "col-xs-12" },{ "onClick": "addList(this, false)" },{ "getStringKey": "Gen_Add" }],"transformers": [] }, {"elementType": "button","elementOptions": [{ "sourceSuffixes": [] },{ "separator": "" },{ "cssClasses": "col-xs-6" },{ "onClick": "removeAllOptions(this)" },{ "getStringKey": "Gen_Remove_All" }],"transformers": []},{"elementType": "button","elementOptions": [{ "sourceSuffixes": [] },{ "separator": "" },{ "cssClasses": "col-xs-6" },{ "onClick": "removeFromList(this)" },{ "getStringKey": "Gen_Remove_Last" }],"transformers": []}, {"elementType": "select","elementOptions": [{ "multiple": "true" },{ "readonly": "true" },{ "editable": "true" }],"transformers": [] }]}', "[]", 'UI') conf.UI_REFRESH = ccd('UI_REFRESH', 0 , c_d, 'Refresh interval', '{"dataType":"integer", "elements": [{"elementType" : "input", "elementOptions" : [{"type": "number"}] ,"transformers": []}]}', "[]", 'UI') conf.UI_DEV_SECTIONS = ccd('UI_DEV_SECTIONS', [] , c_d, 'Show sections', '{"dataType":"array", "elements": [{"elementType" : "select", "elementOptions" : [{"multiple":"true"}] ,"transformers": []}]}', "['Tile Cards', 'Device Presence']", 'UI') conf.UI_PRESENCE = ccd('UI_PRESENCE', ['online', 'offline', 'archived'] , c_d, 'Include in presence', '{"dataType":"array", "elements": [{"elementType" : "select", "elementOptions" : [{"multiple":"true"}] ,"transformers": []}]}', "['online', 'offline', 'archived']", 'UI') From df40b5caf9c3be44dcfa3d909d2d076e9f29fd83 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Sun, 21 Jul 2024 12:04:42 +1000 Subject: [PATCH 11/44] =?UTF-8?q?=F0=9F=94=80Guess=20types=20#738?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/network.php | 6 ++++-- server/device.py | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/front/network.php b/front/network.php index 88bcfa86..a85ac2d4 100755 --- a/front/network.php +++ b/front/network.php @@ -673,7 +673,9 @@ (!emptyArr.includes(nodeData.data.port )) ? port = nodeData.data.port : port = ""; - (port == "" || port == 0 ) ? portBckgIcon = `` : portBckgIcon = ``; + (port == "" || port == 0 || port == 'None' ) ? portBckgIcon = `` : portBckgIcon = ``; + + portHtml = (port == "" || port == 0 || port == 'None' ) ? "" : port // Build HTML for individual nodes in the network diagram deviceIcon = (!emptyArr.includes(nodeData.data.icon )) ? @@ -682,7 +684,7 @@ ` : ""; devicePort = `
- ${port}
+ ${portHtml}
${portBckgIcon} diff --git a/server/device.py b/server/device.py index e2b24e5f..7851639a 100755 --- a/server/device.py +++ b/server/device.py @@ -431,6 +431,22 @@ def update_devices_data_from_scan (db): if len(recordsToUpdate) > 0: sql.executemany ("UPDATE Devices SET dev_Icon = ? WHERE dev_MAC = ? ", recordsToUpdate ) + + # Guess Type + recordsToUpdate = [] + query = """SELECT * FROM Devices + WHERE dev_DeviceType in ('', 'null') + OR dev_DeviceType IS NULL""" + default_type = get_setting_value('NEWDEV_dev_DeviceType') + + for device in sql.execute (query) : + # Conditional logic for dev_Icon guessing + dev_DeviceType = guess_type(device['dev_Vendor'], device['dev_MAC'], device['dev_LastIP'], device['dev_Name'], default_type) + + recordsToUpdate.append ([dev_DeviceType, device['dev_MAC']]) + + if len(recordsToUpdate) > 0: + sql.executemany ("UPDATE Devices SET dev_DeviceType = ? WHERE dev_MAC = ? ", recordsToUpdate ) mylog('debug','[Update Devices] Update devices end') @@ -671,4 +687,38 @@ def guess_icon(vendor, mac, ip, name, default): return result + +#------------------------------------------------------------------------------- +# Guess device type +def guess_type(vendor, mac, ip, name, default): + result = default + mac = mac.upper() + vendor = vendor.lower() + name = name.lower() + + # Guess icon based on vendor + if any(brand in vendor for brand in {"samsung", "motorola"}): + result = "Phone" + elif "cisco" in vendor: + result = "Router" + elif "lg" in vendor: + result = "TV" + elif "google" in vendor: + result = "Phone" + elif "ubiquiti" in vendor: + result = "Router" + + # Guess type based on MAC address patterns + elif mac == "INTERNET": + result = "Internet" + + # Guess type based on name + elif 'google' in name: + result = "Phone" + + # Guess type based on IP address ranges + elif ip == ("192.168.1.1"): + result = "Router" + + return result \ No newline at end of file From f86b374ed3cb12b26bea326bb42e60523c1674d1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 21 Jul 2024 11:53:32 +0000 Subject: [PATCH 12/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From ab08e2ce85ebc9dc6efefe699ae1f27e5a889ddc Mon Sep 17 00:00:00 2001 From: ffsb Date: Sun, 21 Jul 2024 09:00:38 -0400 Subject: [PATCH 13/44] testing arays vs elif performance --- front/plugins/omada_sdn_imp/testre.py | 49 ++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/front/plugins/omada_sdn_imp/testre.py b/front/plugins/omada_sdn_imp/testre.py index 4e382fe7..430d68ee 100644 --- a/front/plugins/omada_sdn_imp/testre.py +++ b/front/plugins/omada_sdn_imp/testre.py @@ -235,4 +235,51 @@ interface=br-1064712a4791, subnet=172.16.0.56/29 interface=br-a93ebdba2a28, subnet=172.16.0.8/29 interface=br-d8fa7a3015e2, subnet=172.16.0.64/29 interface=br-e7cdd041d3d3, subnet=172.16.0.0/29 -''' \ No newline at end of file +''' + + +import timeit + +# Setup: Create a dictionary and a function with if-elif statements +data = { + "apple": 1, + "banana": 2, + "cherry": 3, + "date": 4, + "elderberry": 5 +} + +def get_value_dict(key): + return data.get(key, 0) + +def get_value_if_elif(key): + if key == "apple": + return 1 + elif key == "banana": + return 2 + elif key == "cherry": + return 3 + elif key == "date": + return 4 + elif key == "elderberry": + return 5 + else: + return 0 + +# Test dictionary lookup +dict_time = timeit.timeit( + 'get_value_dict("elderberry")', + setup='from __main__ import get_value_dict', + number=1000000 +) + +# Test if-elif statements +if_elif_time = timeit.timeit( + 'get_value_if_elif("elderberry")', + setup='from __main__ import get_value_if_elif', + number=1000000 +) + +print(f"Dictionary lookup time: {dict_time:.6f} seconds") +print(f"If-elif statements time: {if_elif_time:.6f} seconds") +print(f"Dictionary is {if_elif_time / dict_time:.2f}x faster") \ No newline at end of file From cfae2ea8eeb51711ab94596164c9a947151e6905 Mon Sep 17 00:00:00 2001 From: blomusti Date: Sat, 20 Jul 2024 13:18:04 +0000 Subject: [PATCH 14/44] Translated using Weblate (Turkish) Currently translated at 23.5% (163 of 691 strings) Translation: NetAlertX/core Translate-URL: https://hosted.weblate.org/projects/pialert/core/tr/ --- front/php/templates/language/tr_tr.json | 388 ++++++++++++------------ 1 file changed, 194 insertions(+), 194 deletions(-) mode change 100755 => 100644 front/php/templates/language/tr_tr.json diff --git a/front/php/templates/language/tr_tr.json b/front/php/templates/language/tr_tr.json old mode 100755 new mode 100644 index caafd50c..a004c7cc --- a/front/php/templates/language/tr_tr.json +++ b/front/php/templates/language/tr_tr.json @@ -4,14 +4,14 @@ "API_display_name": "", "API_icon": "", "About_Design": "", - "About_Exit": "", + "About_Exit": "Oturum kapat", "About_Title": "", "AppEvents_DateTimeCreated": "", - "AppEvents_Extra": "", + "AppEvents_Extra": "Ekstra", "AppEvents_GUID": "", - "AppEvents_Helper1": "", - "AppEvents_Helper2": "", - "AppEvents_Helper3": "", + "AppEvents_Helper1": "Yardımcı 1", + "AppEvents_Helper2": "Yardımcı 2", + "AppEvents_Helper3": "Yardımcı 3", "AppEvents_ObjectForeignKey": "", "AppEvents_ObjectIndex": "", "AppEvents_ObjectIsArchived": "", @@ -24,33 +24,33 @@ "AppEvents_ObjectType": "", "AppEvents_Plugin": "", "AppEvents_Type": "", - "BackDevDetail_Actions_Ask_Run": "", + "BackDevDetail_Actions_Ask_Run": "Komutları çalıştırmak istiyor musunuz?", "BackDevDetail_Actions_Not_Registered": "", - "BackDevDetail_Actions_Title_Run": "", + "BackDevDetail_Actions_Title_Run": "Komutu çalıştır", "BackDevDetail_Copy_Ask": "", - "BackDevDetail_Copy_Title": "", - "BackDevDetail_Tools_WOL_error": "", - "BackDevDetail_Tools_WOL_okay": "", + "BackDevDetail_Copy_Title": "Ayrıntıları kopyala", + "BackDevDetail_Tools_WOL_error": "Komut çalıştırılmadı.", + "BackDevDetail_Tools_WOL_okay": "Komut çalıştırıldı.", "BackDevices_Arpscan_disabled": "", "BackDevices_Arpscan_enabled": "", "BackDevices_Backup_CopError": "", "BackDevices_Backup_Failed": "", "BackDevices_Backup_okay": "", - "BackDevices_DBTools_DelDevError_a": "", - "BackDevices_DBTools_DelDevError_b": "", - "BackDevices_DBTools_DelDev_a": "", - "BackDevices_DBTools_DelDev_b": "", + "BackDevices_DBTools_DelDevError_a": "Cihaz silinirken hata oluştu", + "BackDevices_DBTools_DelDevError_b": "Cihazlar silinirken hata oluştu", + "BackDevices_DBTools_DelDev_a": "Cihaz silindi", + "BackDevices_DBTools_DelDev_b": "Cihazlar silindi", "BackDevices_DBTools_DelEvents": "", "BackDevices_DBTools_DelEventsError": "", "BackDevices_DBTools_ImportCSV": "", "BackDevices_DBTools_ImportCSVError": "", "BackDevices_DBTools_ImportCSVMissing": "", "BackDevices_DBTools_Purge": "", - "BackDevices_DBTools_UpdDev": "", - "BackDevices_DBTools_UpdDevError": "", - "BackDevices_DBTools_Upgrade": "", - "BackDevices_DBTools_UpgradeError": "", - "BackDevices_Device_UpdDevError": "", + "BackDevices_DBTools_UpdDev": "Cihaz başarılı bir şekilde güncellendi", + "BackDevices_DBTools_UpdDevError": "Cihaz güncellenirken hata oluştu", + "BackDevices_DBTools_Upgrade": "Veritabanı başarılı bir şekilde güncellendi", + "BackDevices_DBTools_UpgradeError": "Veritabanı güncellenemedi", + "BackDevices_Device_UpdDevError": "Cihazlar güncellenirken hata oluştu, daha sonra tekrar deneyiz. Veritabanı, devam eden bir komut nedeniyle kilitli olabilir.", "BackDevices_Restore_CopError": "", "BackDevices_Restore_Failed": "", "BackDevices_Restore_okay": "", @@ -63,7 +63,7 @@ "DevDetail_EveandAl_AlertAllEvents": "", "DevDetail_EveandAl_AlertDown": "", "DevDetail_EveandAl_Archived": "", - "DevDetail_EveandAl_NewDevice": "", + "DevDetail_EveandAl_NewDevice": "Yeni Cihaz", "DevDetail_EveandAl_NewDevice_Tooltip": "", "DevDetail_EveandAl_RandomMAC": "", "DevDetail_EveandAl_ScanCycle": "", @@ -75,17 +75,17 @@ "DevDetail_GoToNetworkNode": "", "DevDetail_Icon": "", "DevDetail_Icon_Descr": "", - "DevDetail_Loading": "", - "DevDetail_MainInfo_Comments": "", + "DevDetail_Loading": "YÜkleniyor...", + "DevDetail_MainInfo_Comments": "Yorumlar", "DevDetail_MainInfo_Favorite": "", - "DevDetail_MainInfo_Group": "", - "DevDetail_MainInfo_Location": "", - "DevDetail_MainInfo_Name": "", + "DevDetail_MainInfo_Group": "Grup", + "DevDetail_MainInfo_Location": "Konum", + "DevDetail_MainInfo_Name": "İsim", "DevDetail_MainInfo_Network": "", "DevDetail_MainInfo_Network_Port": "", "DevDetail_MainInfo_Network_Site": "", "DevDetail_MainInfo_Network_Title": "", - "DevDetail_MainInfo_Owner": "", + "DevDetail_MainInfo_Owner": "Sahip", "DevDetail_MainInfo_SSID": "", "DevDetail_MainInfo_Title": "", "DevDetail_MainInfo_Type": "", @@ -97,70 +97,70 @@ "DevDetail_Nmap_Scans_desc": "", "DevDetail_Nmap_buttonDefault": "", "DevDetail_Nmap_buttonDefault_text": "", - "DevDetail_Nmap_buttonDetail": "", + "DevDetail_Nmap_buttonDetail": "Detaylı Tarama", "DevDetail_Nmap_buttonDetail_text": "", - "DevDetail_Nmap_buttonFast": "", + "DevDetail_Nmap_buttonFast": "Hızlı Tarama", "DevDetail_Nmap_buttonFast_text": "", "DevDetail_Nmap_buttonSkipDiscovery": "", "DevDetail_Nmap_buttonSkipDiscovery_text": "", - "DevDetail_Nmap_resultsLink": "", + "DevDetail_Nmap_resultsLink": "Tarama başlattıktan sonra bu sayfadan çıkabilirsiniz. Sonuçlara app_front.log dosyasından da ulaşılabilir.", "DevDetail_Owner_hover": "", - "DevDetail_Periodselect_All": "", - "DevDetail_Periodselect_LastMonth": "", - "DevDetail_Periodselect_LastWeek": "", - "DevDetail_Periodselect_LastYear": "", - "DevDetail_Periodselect_today": "", - "DevDetail_Run_Actions_Title": "", + "DevDetail_Periodselect_All": "Tüm Bilgi", + "DevDetail_Periodselect_LastMonth": "Geçen Ay", + "DevDetail_Periodselect_LastWeek": "Geçen Hafta", + "DevDetail_Periodselect_LastYear": "Geçen Yıl", + "DevDetail_Periodselect_today": "Bugün", + "DevDetail_Run_Actions_Title": "Komutu cihazda çalıştır", "DevDetail_Run_Actions_Tooltip": "", - "DevDetail_SessionInfo_FirstSession": "", - "DevDetail_SessionInfo_LastIP": "", + "DevDetail_SessionInfo_FirstSession": "İlk Oturum", + "DevDetail_SessionInfo_LastIP": "Son IP", "DevDetail_SessionInfo_LastSession": "", "DevDetail_SessionInfo_StaticIP": "", - "DevDetail_SessionInfo_Status": "", - "DevDetail_SessionInfo_Title": "", - "DevDetail_SessionTable_Additionalinfo": "", - "DevDetail_SessionTable_Connection": "", + "DevDetail_SessionInfo_Status": "Durum", + "DevDetail_SessionInfo_Title": " Oturum Bİlgisi", + "DevDetail_SessionTable_Additionalinfo": "Ek bilgi", + "DevDetail_SessionTable_Connection": "Bağlantı", "DevDetail_SessionTable_Disconnection": "", - "DevDetail_SessionTable_Duration": "", - "DevDetail_SessionTable_IP": "", - "DevDetail_SessionTable_Order": "", - "DevDetail_Shortcut_CurrentStatus": "", + "DevDetail_SessionTable_Duration": "Süre", + "DevDetail_SessionTable_IP": "IP", + "DevDetail_SessionTable_Order": "Sıra", + "DevDetail_Shortcut_CurrentStatus": "Mevcut Durum", "DevDetail_Shortcut_DownAlerts": "", "DevDetail_Shortcut_Presence": "", - "DevDetail_Shortcut_Sessions": "", - "DevDetail_Tab_Details": "", + "DevDetail_Shortcut_Sessions": "Oturumlar", + "DevDetail_Tab_Details": " Detaylar", "DevDetail_Tab_Events": "", - "DevDetail_Tab_EventsTableDate": "", + "DevDetail_Tab_EventsTableDate": "Tarih", "DevDetail_Tab_EventsTableEvent": "", - "DevDetail_Tab_EventsTableIP": "", - "DevDetail_Tab_EventsTableInfo": "", + "DevDetail_Tab_EventsTableIP": "IP", + "DevDetail_Tab_EventsTableInfo": "Ek bilgi", "DevDetail_Tab_Nmap": "", "DevDetail_Tab_NmapEmpty": "", - "DevDetail_Tab_NmapTableExtra": "", - "DevDetail_Tab_NmapTableHeader": "", + "DevDetail_Tab_NmapTableExtra": "Ekstra", + "DevDetail_Tab_NmapTableHeader": "Planlanmış tarama sonuçları", "DevDetail_Tab_NmapTableIndex": "", "DevDetail_Tab_NmapTablePort": "", "DevDetail_Tab_NmapTableService": "", "DevDetail_Tab_NmapTableState": "", "DevDetail_Tab_NmapTableText": "", - "DevDetail_Tab_NmapTableTime": "", + "DevDetail_Tab_NmapTableTime": "Zaman", "DevDetail_Tab_Plugins": "", "DevDetail_Tab_Presence": "", - "DevDetail_Tab_Sessions": "", + "DevDetail_Tab_Sessions": " Oturumlar", "DevDetail_Tab_Tools": "", "DevDetail_Tab_Tools_Internet_Info_Description": "", - "DevDetail_Tab_Tools_Internet_Info_Error": "", + "DevDetail_Tab_Tools_Internet_Info_Error": "Bir hata oluştu", "DevDetail_Tab_Tools_Internet_Info_Start": "", "DevDetail_Tab_Tools_Internet_Info_Title": "", "DevDetail_Tab_Tools_Nslookup_Description": "", - "DevDetail_Tab_Tools_Nslookup_Error": "", + "DevDetail_Tab_Tools_Nslookup_Error": "Hata: Geçersiz IP adresi.", "DevDetail_Tab_Tools_Nslookup_Start": "", "DevDetail_Tab_Tools_Nslookup_Title": "", "DevDetail_Tab_Tools_Speedtest_Description": "", "DevDetail_Tab_Tools_Speedtest_Start": "", "DevDetail_Tab_Tools_Speedtest_Title": "", "DevDetail_Tab_Tools_Traceroute_Description": "", - "DevDetail_Tab_Tools_Traceroute_Error": "", + "DevDetail_Tab_Tools_Traceroute_Error": "Hata: Geçersiz IP adresi", "DevDetail_Tab_Tools_Traceroute_Start": "", "DevDetail_Tab_Tools_Traceroute_Title": "", "DevDetail_Tools_WOL": "", @@ -169,45 +169,45 @@ "DevDetail_Type_hover": "", "DevDetail_Vendor_hover": "", "DevDetail_WOL_Title": "", - "DevDetail_button_AddIcon": "", + "DevDetail_button_AddIcon": "Yeni İkon Ekle", "DevDetail_button_AddIcon_Help": "", "DevDetail_button_AddIcon_Tooltip": "", - "DevDetail_button_Delete": "", + "DevDetail_button_Delete": "Cihazı Sil", "DevDetail_button_DeleteEvents": "", "DevDetail_button_DeleteEvents_Warning": "", "DevDetail_button_OverwriteIcons": "", "DevDetail_button_OverwriteIcons_Tooltip": "", "DevDetail_button_OverwriteIcons_Warning": "", - "DevDetail_button_Reset": "", - "DevDetail_button_Save": "", + "DevDetail_button_Reset": "Değişiklikleri Sıfırla", + "DevDetail_button_Save": "Kaydet", "Device_MultiEdit": "", "Device_MultiEdit_Backup": "", "Device_MultiEdit_Fields": "", - "Device_MultiEdit_MassActions": "", + "Device_MultiEdit_MassActions": "Toplu komutlar:", "Device_MultiEdit_Tooltip": "", "Device_Searchbox": "", - "Device_Shortcut_AllDevices": "", + "Device_Shortcut_AllDevices": "Cihazlarım", "Device_Shortcut_Archived": "", - "Device_Shortcut_Connected": "", - "Device_Shortcut_Devices": "", + "Device_Shortcut_Connected": "Bağlandı", + "Device_Shortcut_Devices": "Cihazlar", "Device_Shortcut_DownAlerts": "", "Device_Shortcut_DownOnly": "", - "Device_Shortcut_Favorites": "", - "Device_Shortcut_NewDevices": "", + "Device_Shortcut_Favorites": "Favoriler", + "Device_Shortcut_NewDevices": "Yeni Cİhazlar", "Device_Shortcut_OnlineChart": "", - "Device_TableHead_Connected_Devices": "", + "Device_TableHead_Connected_Devices": "Bağlantılar", "Device_TableHead_Favorite": "", - "Device_TableHead_FirstSession": "", + "Device_TableHead_FirstSession": "İlk Oturum", "Device_TableHead_GUID": "", - "Device_TableHead_Group": "", + "Device_TableHead_Group": "Grup", "Device_TableHead_Icon": "", "Device_TableHead_LastIP": "", "Device_TableHead_LastIPOrder": "", "Device_TableHead_LastSession": "", - "Device_TableHead_Location": "", + "Device_TableHead_Location": "Konum", "Device_TableHead_MAC": "", "Device_TableHead_MAC_full": "", - "Device_TableHead_Name": "", + "Device_TableHead_Name": "İsim", "Device_TableHead_NetworkSite": "", "Device_TableHead_Owner": "", "Device_TableHead_Parent_MAC": "", @@ -215,96 +215,96 @@ "Device_TableHead_RowID": "", "Device_TableHead_Rowid": "", "Device_TableHead_SSID": "", - "Device_TableHead_Status": "", + "Device_TableHead_Status": "Durum", "Device_TableHead_SyncHubNodeName": "", "Device_TableHead_Type": "", "Device_TableHead_Vendor": "", - "Device_Table_Not_Network_Device": "", + "Device_Table_Not_Network_Device": "Ağ cihazı olarak ayarlanmadı", "Device_Table_info": "", - "Device_Table_nav_next": "", - "Device_Table_nav_prev": "", + "Device_Table_nav_next": "Sonraki", + "Device_Table_nav_prev": "Önceki", "Device_Tablelenght": "", "Device_Tablelenght_all": "", - "Device_Title": "", - "Donations_Others": "", + "Device_Title": "Cihazlar", + "Donations_Others": "Diğerleri", "Donations_Platforms": "", "Donations_Text": "", "Donations_Title": "", "ENABLE_PLUGINS_description": "", "ENABLE_PLUGINS_name": "", - "Email_display_name": "", - "Email_icon": "", - "Events_Loading": "", + "Email_display_name": "Eposta", + "Email_icon": "", + "Events_Loading": "Yükleniyor...", "Events_Periodselect_All": "", - "Events_Periodselect_LastMonth": "", - "Events_Periodselect_LastWeek": "", - "Events_Periodselect_LastYear": "", - "Events_Periodselect_today": "", + "Events_Periodselect_LastMonth": "Geçen Ay", + "Events_Periodselect_LastWeek": "Geçen Hafta", + "Events_Periodselect_LastYear": "Geçen Yıl", + "Events_Periodselect_today": "Bugün", "Events_Searchbox": "", "Events_Shortcut_AllEvents": "", "Events_Shortcut_DownAlerts": "", "Events_Shortcut_Events": "", "Events_Shortcut_MissSessions": "", - "Events_Shortcut_NewDevices": "", - "Events_Shortcut_Sessions": "", + "Events_Shortcut_NewDevices": "Yeni Cİhazlar", + "Events_Shortcut_Sessions": "Oturumlar", "Events_Shortcut_VoidSessions": "", - "Events_TableHead_AdditionalInfo": "", - "Events_TableHead_Connection": "", - "Events_TableHead_Date": "", - "Events_TableHead_Device": "", + "Events_TableHead_AdditionalInfo": "Ek Bilgi", + "Events_TableHead_Connection": "Bağlantı", + "Events_TableHead_Date": "Tarih", + "Events_TableHead_Device": "Cihaz", "Events_TableHead_Disconnection": "", - "Events_TableHead_Duration": "", + "Events_TableHead_Duration": "Süre", "Events_TableHead_DurationOrder": "", "Events_TableHead_EventType": "", "Events_TableHead_IP": "", "Events_TableHead_IPOrder": "", - "Events_TableHead_Order": "", + "Events_TableHead_Order": "Sıra", "Events_TableHead_Owner": "", "Events_TableHead_PendingAlert": "", "Events_Table_info": "", "Events_Table_nav_next": "", - "Events_Table_nav_prev": "", + "Events_Table_nav_prev": "Önceki", "Events_Tablelenght": "", "Events_Tablelenght_all": "", "Events_Title": "", - "Gen_Action": "", - "Gen_Add": "", - "Gen_Add_All": "", - "Gen_All_Devices": "", - "Gen_AreYouSure": "", + "Gen_Action": "Komut", + "Gen_Add": "Ekle", + "Gen_Add_All": "Tümünü ekle", + "Gen_All_Devices": "Tüm Cihazlar", + "Gen_AreYouSure": "Emin misiniz?", "Gen_Backup": "", - "Gen_Cancel": "", - "Gen_Copy": "", - "Gen_DataUpdatedUITakesTime": "", - "Gen_Delete": "", - "Gen_DeleteAll": "", - "Gen_Error": "", - "Gen_Filter": "", + "Gen_Cancel": "İptal", + "Gen_Copy": "Çalıştır", + "Gen_DataUpdatedUITakesTime": "TAMAM - Eğer bir tarama çalışıyorsa arayüzün güncellenmesi biraz zaman alabilir", + "Gen_Delete": "Sil", + "Gen_DeleteAll": "Tümünü sil", + "Gen_Error": "Hata", + "Gen_Filter": "Filtre", "Gen_LockedDB": "", - "Gen_Offline": "", - "Gen_Okay": "", - "Gen_Purge": "", + "Gen_Offline": "Çevrimdışı", + "Gen_Okay": "Tamam", + "Gen_Purge": "Çıkar", "Gen_ReadDocs": "", - "Gen_Remove_All": "", + "Gen_Remove_All": "Tümünü kaldır", "Gen_Remove_Last": "", "Gen_Restore": "", - "Gen_Run": "", - "Gen_Save": "", - "Gen_Saved": "", + "Gen_Run": "Çalıştır", + "Gen_Save": "Kaydet", + "Gen_Saved": "Kaydedildi", "Gen_Search": "", - "Gen_Selected_Devices": "", + "Gen_Selected_Devices": "Seçilmiş Cihazlar:", "Gen_Switch": "", - "Gen_Upd": "", + "Gen_Upd": "Başarılı bir şekilde güncellendi", "Gen_Upd_Fail": "", "Gen_Update": "", "Gen_Update_Value": "", - "Gen_Warning": "", + "Gen_Warning": "Uyarı", "Gen_Work_In_Progress": "", - "General_display_name": "", - "General_icon": "", + "General_display_name": "Genel", + "General_icon": "", "HRS_TO_KEEP_NEWDEV_description": "", "HRS_TO_KEEP_NEWDEV_name": "", - "HelpFAQ_Cat_Detail": "", + "HelpFAQ_Cat_Detail": "Detaylar", "HelpFAQ_Cat_Detail_300_head": "", "HelpFAQ_Cat_Detail_300_text_a": "", "HelpFAQ_Cat_Detail_300_text_b": "", @@ -314,24 +314,24 @@ "HelpFAQ_Cat_Detail_302_head_a": "", "HelpFAQ_Cat_Detail_302_head_b": "", "HelpFAQ_Cat_Detail_302_text": "", - "HelpFAQ_Cat_Detail_303_head": "", - "HelpFAQ_Cat_Detail_303_text": "", - "HelpFAQ_Cat_Device_200_head": "", + "HelpFAQ_Cat_Detail_303_head": "Nmap nedir ve ne içindir?", + "HelpFAQ_Cat_Detail_303_text": "Nmap birden fazla fonksiyona sahip bir ağ tarayıcısıdır..
Listenizde yeni bir cihaz belirdiği zaman, Nmap taraması sayesinde o cihaz hakkında daha çok bilgi alabilme olanağınız var.", + "HelpFAQ_Cat_Device_200_head": "Listemde bilmediğim cihazlar var. Sildiğim zaman yeniden ortaya çıkıyorlar.", "HelpFAQ_Cat_Device_200_text": "", - "HelpFAQ_Cat_General": "", + "HelpFAQ_Cat_General": "Genel", "HelpFAQ_Cat_General_100_head": "", "HelpFAQ_Cat_General_100_text_a": "", "HelpFAQ_Cat_General_100_text_b": "", "HelpFAQ_Cat_General_100_text_c": "", "HelpFAQ_Cat_General_101_head": "", "HelpFAQ_Cat_General_101_text": "", - "HelpFAQ_Cat_General_102_head": "", + "HelpFAQ_Cat_General_102_head": "Veritabanının salt okunur olduğu mesajını alıyorum.", "HelpFAQ_Cat_General_102_text": "", "HelpFAQ_Cat_General_102docker_head": "", "HelpFAQ_Cat_General_102docker_text": "", "HelpFAQ_Cat_General_103_head": "", "HelpFAQ_Cat_General_103_text": "", - "HelpFAQ_Cat_Network_600_head": "", + "HelpFAQ_Cat_Network_600_head": "Bu sayfa ne işe yarar?", "HelpFAQ_Cat_Network_600_text": "", "HelpFAQ_Cat_Network_601_head": "", "HelpFAQ_Cat_Network_601_text": "", @@ -339,34 +339,34 @@ "HelpFAQ_Cat_Presence_400_text": "", "HelpFAQ_Cat_Presence_401_head": "", "HelpFAQ_Cat_Presence_401_text": "", - "HelpFAQ_Title": "", + "HelpFAQ_Title": "Yardım / SSS", "LOADED_PLUGINS_description": "", "LOADED_PLUGINS_name": "", "LOG_LEVEL_description": "", "LOG_LEVEL_name": "", - "Loading": "", - "Login_Box": "", - "Login_Default_PWD": "", - "Login_Psw-box": "", + "Loading": "Yükleniyor...", + "Login_Box": "Şifrenizi giriniz", + "Login_Default_PWD": "Varsayılan şifre \"123456\" hâlâ aktif.", + "Login_Psw-box": "Şİfre", "Login_Psw_alert": "", "Login_Psw_folder": "", - "Login_Psw_new": "", + "Login_Psw_new": "yeni_sifre", "Login_Psw_run": "", - "Login_Remember": "", - "Login_Remember_small": "", - "Login_Submit": "", + "Login_Remember": "Hatırla", + "Login_Remember_small": "(7 gün geçerli)", + "Login_Submit": "Oturum aç", "Login_Toggle_Alert_headline": "", "Login_Toggle_Info": "", "Login_Toggle_Info_headline": "", "Maint_PurgeLog": "", "Maint_RestartServer": "", "Maint_Restart_Server_noti_text": "", - "Maintenance_Running_Version": "", - "Maintenance_Status": "", + "Maintenance_Running_Version": "Yüklenmiş sürüm", + "Maintenance_Status": "Durum", "Maintenance_Title": "", "Maintenance_Tool_ExportCSV": "", "Maintenance_Tool_ExportCSV_noti": "", - "Maintenance_Tool_ExportCSV_noti_text": "", + "Maintenance_Tool_ExportCSV_noti_text": "Bir CSV dosyası oluşturmak istediğinize emin misiniz?", "Maintenance_Tool_ExportCSV_text": "", "Maintenance_Tool_ImportCSV": "", "Maintenance_Tool_ImportCSV_noti": "", @@ -392,9 +392,9 @@ "Maintenance_Tool_del_ActHistory_noti": "", "Maintenance_Tool_del_ActHistory_noti_text": "", "Maintenance_Tool_del_ActHistory_text": "", - "Maintenance_Tool_del_alldev": "", + "Maintenance_Tool_del_alldev": "Tüm Cihazları Sil", "Maintenance_Tool_del_alldev_noti": "", - "Maintenance_Tool_del_alldev_noti_text": "", + "Maintenance_Tool_del_alldev_noti_text": "Tüm cihazları silmek istediğinize emin misiniz?", "Maintenance_Tool_del_alldev_text": "", "Maintenance_Tool_del_allevents": "", "Maintenance_Tool_del_allevents30": "", @@ -405,12 +405,12 @@ "Maintenance_Tool_del_allevents_noti_text": "", "Maintenance_Tool_del_allevents_text": "", "Maintenance_Tool_del_empty_macs": "", - "Maintenance_Tool_del_empty_macs_noti": "", + "Maintenance_Tool_del_empty_macs_noti": "Cihazları Sil", "Maintenance_Tool_del_empty_macs_noti_text": "", "Maintenance_Tool_del_empty_macs_text": "", - "Maintenance_Tool_del_selecteddev": "", + "Maintenance_Tool_del_selecteddev": "Seçilmiş cihazları sil", "Maintenance_Tool_del_selecteddev_text": "", - "Maintenance_Tool_del_unknowndev": "", + "Maintenance_Tool_del_unknowndev": "(bilinmeyen) Cihazları Sil", "Maintenance_Tool_del_unknowndev_noti": "", "Maintenance_Tool_del_unknowndev_noti_text": "", "Maintenance_Tool_del_unknowndev_text": "", @@ -430,59 +430,59 @@ "Maintenance_Tool_upgrade_database_text": "", "Maintenance_Tools_Tab_BackupRestore": "", "Maintenance_Tools_Tab_Logging": "", - "Maintenance_Tools_Tab_Settings": "", - "Maintenance_Tools_Tab_Tools": "", - "Maintenance_Tools_Tab_UISettings": "", - "Maintenance_arp_status": "", - "Maintenance_arp_status_off": "", - "Maintenance_arp_status_on": "", + "Maintenance_Tools_Tab_Settings": "Ayarlar", + "Maintenance_Tools_Tab_Tools": "Araçlar", + "Maintenance_Tools_Tab_UISettings": "Arayüz Ayarları", + "Maintenance_arp_status": "Tarama Durumu", + "Maintenance_arp_status_off": "şu anda devre dışı", + "Maintenance_arp_status_on": "tarama(lar) şu anda çalışıyor", "Maintenance_built_on": "", "Maintenance_current_version": "", "Maintenance_database_backup": "", - "Maintenance_database_backup_found": "", + "Maintenance_database_backup_found": "yedekler bulundu", "Maintenance_database_backup_total": "", "Maintenance_database_lastmod": "", "Maintenance_database_path": "", "Maintenance_database_rows": "", "Maintenance_database_size": "", - "Maintenance_lang_selector_apply": "", + "Maintenance_lang_selector_apply": "Uygula", "Maintenance_lang_selector_empty": "", "Maintenance_lang_selector_lable": "", "Maintenance_lang_selector_text": "", "Maintenance_new_version": "", - "Maintenance_themeselector_apply": "", + "Maintenance_themeselector_apply": "Uygula", "Maintenance_themeselector_empty": "", "Maintenance_themeselector_lable": "", "Maintenance_themeselector_text": "", "Maintenance_version": "", "NETWORK_DEVICE_TYPES_description": "", "NETWORK_DEVICE_TYPES_name": "", - "Navigation_About": "", - "Navigation_Devices": "", + "Navigation_About": "Hakkında", + "Navigation_Devices": "Cihazlar", "Navigation_Donations": "", "Navigation_Events": "", - "Navigation_HelpFAQ": "", + "Navigation_HelpFAQ": "Yardım / SSS", "Navigation_Integrations": "", "Navigation_Maintenance": "", "Navigation_Monitoring": "", "Navigation_Network": "", - "Navigation_Notifications": "", + "Navigation_Notifications": "Bildirimler", "Navigation_Plugins": "", "Navigation_Presence": "", "Navigation_Report": "", - "Navigation_Settings": "", + "Navigation_Settings": "Ayarlar", "Navigation_SystemInfo": "", "Navigation_Workflows": "", "Network_Assign": "", "Network_Cant_Assign": "", - "Network_Configuration_Error": "", - "Network_Connected": "", - "Network_ManageAdd": "", - "Network_ManageAdd_Name": "", - "Network_ManageAdd_Name_text": "", + "Network_Configuration_Error": "Kurulum Hatası", + "Network_Connected": "Bağlanmış cihazlar", + "Network_ManageAdd": "Cihaz Ekle", + "Network_ManageAdd_Name": "Cihaz İsmi", + "Network_ManageAdd_Name_text": "Özel karakterler olmadan isim veriniz", "Network_ManageAdd_Port": "", "Network_ManageAdd_Port_text": "", - "Network_ManageAdd_Submit": "", + "Network_ManageAdd_Submit": "Cihaz Ekle", "Network_ManageAdd_Type": "", "Network_ManageAdd_Type_text": "", "Network_ManageAssign": "", @@ -490,15 +490,15 @@ "Network_ManageDel_Name": "", "Network_ManageDel_Name_text": "", "Network_ManageDel_Submit": "", - "Network_ManageDevices": "", + "Network_ManageDevices": "Cihazları Yönet", "Network_ManageEdit": "", "Network_ManageEdit_ID": "", "Network_ManageEdit_ID_text": "", - "Network_ManageEdit_Name": "", + "Network_ManageEdit_Name": "Yeni Cihaz İsmi", "Network_ManageEdit_Name_text": "", "Network_ManageEdit_Port": "", "Network_ManageEdit_Port_text": "", - "Network_ManageEdit_Submit": "", + "Network_ManageEdit_Submit": "Ayarları Kaydet", "Network_ManageEdit_Type": "", "Network_ManageEdit_Type_text": "", "Network_ManageLeaf": "", @@ -516,7 +516,7 @@ "Network_Table_State": "", "Network_Title": "", "Network_UnassignedDevices": "", - "Notifications_All": "", + "Notifications_All": "Tüm Bildirimler", "Notifications_Mark_All_Read": "", "PIALERT_WEB_PASSWORD_description": "", "PIALERT_WEB_PASSWORD_name": "", @@ -531,21 +531,21 @@ "Plugins_Out_of": "", "Plugins_Unprocessed_Events": "", "Plugins_no_control": "", - "Presence_CalHead_day": "", + "Presence_CalHead_day": "gün", "Presence_CalHead_lang": "", "Presence_CalHead_month": "", - "Presence_CalHead_quarter": "", - "Presence_CalHead_week": "", - "Presence_CalHead_year": "", - "Presence_CallHead_Devices": "", - "Presence_Loading": "", - "Presence_Shortcut_AllDevices": "", + "Presence_CalHead_quarter": "çeyrek", + "Presence_CalHead_week": "hafta", + "Presence_CalHead_year": "yıl", + "Presence_CallHead_Devices": "Cihazlar", + "Presence_Loading": "Yükleniyor...", + "Presence_Shortcut_AllDevices": "Cihazlarım", "Presence_Shortcut_Archived": "", "Presence_Shortcut_Connected": "", - "Presence_Shortcut_Devices": "", + "Presence_Shortcut_Devices": "Cihazlar", "Presence_Shortcut_DownAlerts": "", - "Presence_Shortcut_Favorites": "", - "Presence_Shortcut_NewDevices": "", + "Presence_Shortcut_Favorites": "Favoriler", + "Presence_Shortcut_NewDevices": "Yeni Cihazlar", "Presence_Title": "", "REPORT_DASHBOARD_URL_description": "", "REPORT_DASHBOARD_URL_name": "", @@ -571,21 +571,21 @@ "Systeminfo_CPU_Vendor": "", "Systeminfo_Client_Resolution": "", "Systeminfo_Client_User_Agent": "", - "Systeminfo_General": "", - "Systeminfo_General_Date": "", + "Systeminfo_General": "Genel", + "Systeminfo_General_Date": "Tarih:", "Systeminfo_General_Date2": "", "Systeminfo_General_Full_Date": "", - "Systeminfo_General_TimeZone": "", + "Systeminfo_General_TimeZone": "Zaman dilimi:", "Systeminfo_Memory": "", "Systeminfo_Memory_Total_Memory": "", "Systeminfo_Memory_Usage": "", "Systeminfo_Memory_Usage_Percent": "", - "Systeminfo_Motherboard": "", + "Systeminfo_Motherboard": "Anakart", "Systeminfo_Motherboard_BIOS": "", "Systeminfo_Motherboard_BIOS_Date": "", "Systeminfo_Motherboard_BIOS_Vendor": "", "Systeminfo_Motherboard_Manufactured": "", - "Systeminfo_Motherboard_Name": "", + "Systeminfo_Motherboard_Name": "İsim:", "Systeminfo_Motherboard_Revision": "", "Systeminfo_Network": "", "Systeminfo_Network_Accept_Encoding": "", @@ -596,7 +596,7 @@ "Systeminfo_Network_HTTP_Referer_String": "", "Systeminfo_Network_Hardware": "", "Systeminfo_Network_Hardware_Interface_Mask": "", - "Systeminfo_Network_Hardware_Interface_Name": "", + "Systeminfo_Network_Hardware_Interface_Name": "Arayüz İsmi", "Systeminfo_Network_Hardware_Interface_RX": "", "Systeminfo_Network_Hardware_Interface_TX": "", "Systeminfo_Network_IP": "", @@ -617,35 +617,35 @@ "Systeminfo_Services_Description": "", "Systeminfo_Services_Name": "", "Systeminfo_Storage": "", - "Systeminfo_Storage_Device": "", + "Systeminfo_Storage_Device": "Cihaz:", "Systeminfo_Storage_Mount": "", - "Systeminfo_Storage_Size": "", + "Systeminfo_Storage_Size": "Boyut:", "Systeminfo_Storage_Type": "", "Systeminfo_Storage_Usage": "", "Systeminfo_Storage_Usage_Free": "", "Systeminfo_Storage_Usage_Mount": "", "Systeminfo_Storage_Usage_Total": "", "Systeminfo_Storage_Usage_Used": "", - "Systeminfo_System": "", + "Systeminfo_System": "Sistem", "Systeminfo_System_AVG": "", "Systeminfo_System_Architecture": "", "Systeminfo_System_Kernel": "", "Systeminfo_System_OSVersion": "", "Systeminfo_System_Running_Processes": "", - "Systeminfo_System_System": "", + "Systeminfo_System_System": "Sistem:", "Systeminfo_System_Uname": "", "Systeminfo_System_Uptime": "", "Systeminfo_This_Client": "", - "Systeminfo_USB_Devices": "", + "Systeminfo_USB_Devices": "USB Aygıtları", "TICKER_MIGRATE_TO_NETALERTX": "", "TIMEZONE_description": "", - "TIMEZONE_name": "", + "TIMEZONE_name": "Zaman dilimi", "UI_DEV_SECTIONS_description": "", "UI_DEV_SECTIONS_name": "", "UI_ICONS_description": "", "UI_ICONS_name": "", "UI_LANG_description": "", - "UI_LANG_name": "", + "UI_LANG_name": "Arayüz Dili", "UI_MY_DEVICES_description": "", "UI_MY_DEVICES_name": "", "UI_NOT_RANDOM_MAC_description": "", @@ -654,13 +654,13 @@ "UI_PRESENCE_name": "", "UI_REFRESH_description": "", "UI_REFRESH_name": "", - "devices_old": "", + "devices_old": "Yenileniyor...", "general_event_description": "", "general_event_title": "", "report_guid": "", "report_guid_missing": "", "report_select_format": "", - "report_time": "", + "report_time": "Bildirim zamanı:", "run_event_icon": "", "run_event_tooltip": "", "settings_core_icon": "", @@ -679,15 +679,15 @@ "settings_old": "", "settings_other_scanners": "", "settings_other_scanners_icon": "", - "settings_other_scanners_label": "", + "settings_other_scanners_label": "Diğer tarayıcılar", "settings_publishers": "", "settings_publishers_icon": "", "settings_publishers_info": "", "settings_publishers_label": "", "settings_saved": "", "settings_system_icon": "", - "settings_system_label": "", + "settings_system_label": "Sistem", "settings_update_item_warning": "", "test_event_icon": "", "test_event_tooltip": "" -} \ No newline at end of file +} From d14944c2bd1bf989413552e603c0a39e120810c6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:53:39 +0000 Subject: [PATCH 15/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 8b1b86eeb7132f75677802a4605dd28b3b297659 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 23 Jul 2024 11:53:47 +0000 Subject: [PATCH 16/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From a31469373f6975827276a3a07cee2a354c11b637 Mon Sep 17 00:00:00 2001 From: Ariel Debrouvier Date: Tue, 23 Jul 2024 11:25:11 -0300 Subject: [PATCH 17/44] Add mqtts support --- front/plugins/_publisher_mqtt/config.json | 32 +++++++++++++++++++++++ front/plugins/_publisher_mqtt/mqtt.py | 6 +++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/front/plugins/_publisher_mqtt/config.json b/front/plugins/_publisher_mqtt/config.json index 365ff877..5a6324b6 100755 --- a/front/plugins/_publisher_mqtt/config.json +++ b/front/plugins/_publisher_mqtt/config.json @@ -499,6 +499,38 @@ } ] }, + { + "function": "TLS", + "type": { + "dataType": "boolean", + "elements": [ + { + "elementType": "input", + "elementOptions": [{ "type": "checkbox" }], + "transformers": [] + } + ] + }, + "default_value": false, + "options": [], + "localized": ["name", "description"], + "name": [ + { + "language_code": "en_us", + "string": "MQTT TLS" + } + ], + "description": [ + { + "language_code": "en_us", + "string": "Enable TLS support." + }, + { + "language_code": "es_es", + "string": "Habilitar soporte TLS." + } + ] + }, { "function": "USER", "type": { diff --git a/front/plugins/_publisher_mqtt/mqtt.py b/front/plugins/_publisher_mqtt/mqtt.py index 7ff61e62..30a947a1 100755 --- a/front/plugins/_publisher_mqtt/mqtt.py +++ b/front/plugins/_publisher_mqtt/mqtt.py @@ -295,9 +295,11 @@ def mqtt_create_client(): if get_setting_value('MQTT_VERSION') == 1: mqtt_client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1) else: - mqtt_client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2) + mqtt_client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2) + + if get_setting_value('MQTT_TLS'): + mqtt_client.tls_set() - mqtt_client.username_pw_set(get_setting_value('MQTT_USER'), get_setting_value('MQTT_PASSWORD')) mqtt_client.on_connect = on_connect mqtt_client.on_disconnect = on_disconnect From 68b691df0930f1bccdb81eab853aa79fe5223c07 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:53:59 +0000 Subject: [PATCH 18/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 78db3c708912caacd7b2f6fdb1212242c1eea6e0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:53:36 +0000 Subject: [PATCH 19/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 4ef1bb257d39d46caeefc13fd5368a052ad6a3fe Mon Sep 17 00:00:00 2001 From: Safeguard Date: Thu, 25 Jul 2024 08:39:29 +0000 Subject: [PATCH 20/44] Translated using Weblate (Russian) Currently translated at 99.8% (690 of 691 strings) Translation: NetAlertX/core Translate-URL: https://hosted.weblate.org/projects/pialert/core/ru/ --- front/php/templates/language/ru_ru.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) mode change 100755 => 100644 front/php/templates/language/ru_ru.json diff --git a/front/php/templates/language/ru_ru.json b/front/php/templates/language/ru_ru.json old mode 100755 new mode 100644 index cf6d7d14..61765af0 --- a/front/php/templates/language/ru_ru.json +++ b/front/php/templates/language/ru_ru.json @@ -370,11 +370,11 @@ "Maintenance_Tool_ExportCSV_text": "Создайте файл CSV (значения, разделенные запятыми), содержащий список устройств, включая сетевые отношения между сетевыми узлами и подключенными устройствами. Вы также можете открыть этот URL-адрес URL Вашего NetAlertX/php/server/devices.php?action=ExportCSV или включить плагин Резервное копирование в CSV.", "Maintenance_Tool_ImportCSV": "CSV Импорт", "Maintenance_Tool_ImportCSV_noti": "CSV Импорт", - "Maintenance_Tool_ImportCSV_noti_text": "Вы уверены, что хотите импортировать файл CSV? Это полностью перезапишет устройства в вашей базе данных.", + "Maintenance_Tool_ImportCSV_noti_text": "Вы уверены, что хотите импортировать файл CSV? Это полностью перезапишет устройства в вашей базе данных.", "Maintenance_Tool_ImportCSV_text": "Прежде чем использовать эту функцию, сделайте резервную копию. Импортируйте файл CSV (значения, разделенные запятыми), содержащий список устройств, включая сетевые отношения между сетевыми узлами и подключенными устройствами. Для этого поместите файл CSV с именем devices.csv в папку /config.", - "Maintenance_Tool_ImportPastedCSV": "", - "Maintenance_Tool_ImportPastedCSV_noti_text": "", - "Maintenance_Tool_ImportPastedCSV_text": "", + "Maintenance_Tool_ImportPastedCSV": "Импорт CSV (вставка)", + "Maintenance_Tool_ImportPastedCSV_noti_text": "Вы уверены, что хотите импортировать вставленный CSV? Это полностью перезапишет устройства в вашей базе данных.", + "Maintenance_Tool_ImportPastedCSV_text": "Перед использованием этой функции, пожалуйста, создайте резервную копию. Импортируйте файл формата CSV (значения, разделенные запятыми), содержащий список устройств, включая сетевые связи между узлами сети и подключенными устройствами.", "Maintenance_Tool_arpscansw": "Переключить arp-скан (ВКЛ./ВЫКЛ.)", "Maintenance_Tool_arpscansw_noti": "Включить или выключить arp-скан", "Maintenance_Tool_arpscansw_noti_text": "Когда сканирование было выключено, оно остается выключенным до тех пор, пока не будет активировано снова.", From 1243cf896f42f79945ece691c4e5b608b4364b06 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:53:35 +0000 Subject: [PATCH 21/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 67e467d45a0bb3fe1f9a918f5ca89e3080c43c82 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 27 Jul 2024 11:53:56 +0000 Subject: [PATCH 22/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 8193f7f9e55e472ffa2560739761f65c1d964cb3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 28 Jul 2024 11:53:56 +0000 Subject: [PATCH 23/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 01986a712be7991abefd41526458988094c8dfb5 Mon Sep 17 00:00:00 2001 From: GoldBull3t Date: Sun, 28 Jul 2024 06:42:02 +0000 Subject: [PATCH 24/44] Translated using Weblate (Portuguese (Brazil)) Currently translated at 12.4% (86 of 691 strings) Translation: NetAlertX/core Translate-URL: https://hosted.weblate.org/projects/pialert/core/pt_BR/ --- front/php/templates/language/pt_br.json | 202 ++++++++++++------------ 1 file changed, 101 insertions(+), 101 deletions(-) mode change 100755 => 100644 front/php/templates/language/pt_br.json diff --git a/front/php/templates/language/pt_br.json b/front/php/templates/language/pt_br.json old mode 100755 new mode 100644 index 74f59937..36581d95 --- a/front/php/templates/language/pt_br.json +++ b/front/php/templates/language/pt_br.json @@ -56,15 +56,15 @@ "BackDevices_Restore_okay": "Restauração executada com sucesso.", "BackDevices_darkmode_disabled": "Modo Noturno Desabilitado", "BackDevices_darkmode_enabled": "Modo Noturno Habilitado", - "DAYS_TO_KEEP_EVENTS_description": "", + "DAYS_TO_KEEP_EVENTS_description": "Esta é uma definição de manutenção. Especifica o número de dias de entradas de eventos que serão mantidas. Todos os eventos mais antigos serão eliminados periodicamente. Também se aplica ao Histórico de eventos do plug-in.", "DAYS_TO_KEEP_EVENTS_name": "Excluir eventos mais antigos que", "DevDetail_Copy_Device_Title": " Copiar detalhes do dispositivo", - "DevDetail_Copy_Device_Tooltip": "", + "DevDetail_Copy_Device_Tooltip": "Copiar detalhes do dispositivo a partir da lista pendente. Tudo o que se encontra nesta página será substituído", "DevDetail_EveandAl_AlertAllEvents": "Alerte Todos os Eventos", "DevDetail_EveandAl_AlertDown": "Alerta Desligado", "DevDetail_EveandAl_Archived": "Arquivado", "DevDetail_EveandAl_NewDevice": "Novo Dispositivo", - "DevDetail_EveandAl_NewDevice_Tooltip": "", + "DevDetail_EveandAl_NewDevice_Tooltip": "Mostra o estado Novo do dispositivo e inclui-o nas listas quando o filtro Novos dispositivos está ativo. Não afecta as notificações.", "DevDetail_EveandAl_RandomMAC": "MAC Aleatório", "DevDetail_EveandAl_ScanCycle": "Rastrear dispositivo", "DevDetail_EveandAl_ScanCycle_a": "Rastrear Dispositivo", @@ -72,104 +72,104 @@ "DevDetail_EveandAl_Skip": "Pular notificações repetidas para", "DevDetail_EveandAl_Title": " Configuração de Eventos & Alertas", "DevDetail_Events_CheckBox": "Esconder Eventos de Conexão", - "DevDetail_GoToNetworkNode": "", + "DevDetail_GoToNetworkNode": "Navega para a página Rede do nó indicado.", "DevDetail_Icon": "Icone", - "DevDetail_Icon_Descr": "", - "DevDetail_Loading": "", - "DevDetail_MainInfo_Comments": "", - "DevDetail_MainInfo_Favorite": "", - "DevDetail_MainInfo_Group": "", - "DevDetail_MainInfo_Location": "", - "DevDetail_MainInfo_Name": "", - "DevDetail_MainInfo_Network": "", - "DevDetail_MainInfo_Network_Port": "", - "DevDetail_MainInfo_Network_Site": "", - "DevDetail_MainInfo_Network_Title": "", - "DevDetail_MainInfo_Owner": "", - "DevDetail_MainInfo_SSID": "", - "DevDetail_MainInfo_Title": "", - "DevDetail_MainInfo_Type": "", - "DevDetail_MainInfo_Vendor": "", - "DevDetail_MainInfo_mac": "", - "DevDetail_Network_Node_hover": "", - "DevDetail_Network_Port_hover": "", - "DevDetail_Nmap_Scans": "", - "DevDetail_Nmap_Scans_desc": "", - "DevDetail_Nmap_buttonDefault": "", - "DevDetail_Nmap_buttonDefault_text": "", - "DevDetail_Nmap_buttonDetail": "", - "DevDetail_Nmap_buttonDetail_text": "", - "DevDetail_Nmap_buttonFast": "", - "DevDetail_Nmap_buttonFast_text": "", - "DevDetail_Nmap_buttonSkipDiscovery": "", - "DevDetail_Nmap_buttonSkipDiscovery_text": "", - "DevDetail_Nmap_resultsLink": "", - "DevDetail_Owner_hover": "", - "DevDetail_Periodselect_All": "", - "DevDetail_Periodselect_LastMonth": "", - "DevDetail_Periodselect_LastWeek": "", - "DevDetail_Periodselect_LastYear": "", - "DevDetail_Periodselect_today": "", - "DevDetail_Run_Actions_Title": "", - "DevDetail_Run_Actions_Tooltip": "", - "DevDetail_SessionInfo_FirstSession": "", - "DevDetail_SessionInfo_LastIP": "", - "DevDetail_SessionInfo_LastSession": "", - "DevDetail_SessionInfo_StaticIP": "", - "DevDetail_SessionInfo_Status": "", - "DevDetail_SessionInfo_Title": "", - "DevDetail_SessionTable_Additionalinfo": "", - "DevDetail_SessionTable_Connection": "", - "DevDetail_SessionTable_Disconnection": "", - "DevDetail_SessionTable_Duration": "", - "DevDetail_SessionTable_IP": "", - "DevDetail_SessionTable_Order": "", - "DevDetail_Shortcut_CurrentStatus": "", - "DevDetail_Shortcut_DownAlerts": "", - "DevDetail_Shortcut_Presence": "", - "DevDetail_Shortcut_Sessions": "", - "DevDetail_Tab_Details": "", - "DevDetail_Tab_Events": "", - "DevDetail_Tab_EventsTableDate": "", - "DevDetail_Tab_EventsTableEvent": "", - "DevDetail_Tab_EventsTableIP": "", - "DevDetail_Tab_EventsTableInfo": "", - "DevDetail_Tab_Nmap": "", - "DevDetail_Tab_NmapEmpty": "", - "DevDetail_Tab_NmapTableExtra": "", - "DevDetail_Tab_NmapTableHeader": "", - "DevDetail_Tab_NmapTableIndex": "", - "DevDetail_Tab_NmapTablePort": "", - "DevDetail_Tab_NmapTableService": "", - "DevDetail_Tab_NmapTableState": "", - "DevDetail_Tab_NmapTableText": "", - "DevDetail_Tab_NmapTableTime": "", - "DevDetail_Tab_Plugins": "", - "DevDetail_Tab_Presence": "", - "DevDetail_Tab_Sessions": "", - "DevDetail_Tab_Tools": "", - "DevDetail_Tab_Tools_Internet_Info_Description": "", - "DevDetail_Tab_Tools_Internet_Info_Error": "", - "DevDetail_Tab_Tools_Internet_Info_Start": "", - "DevDetail_Tab_Tools_Internet_Info_Title": "", - "DevDetail_Tab_Tools_Nslookup_Description": "", - "DevDetail_Tab_Tools_Nslookup_Error": "", - "DevDetail_Tab_Tools_Nslookup_Start": "", - "DevDetail_Tab_Tools_Nslookup_Title": "", - "DevDetail_Tab_Tools_Speedtest_Description": "", - "DevDetail_Tab_Tools_Speedtest_Start": "", - "DevDetail_Tab_Tools_Speedtest_Title": "", - "DevDetail_Tab_Tools_Traceroute_Description": "", - "DevDetail_Tab_Tools_Traceroute_Error": "", - "DevDetail_Tab_Tools_Traceroute_Start": "", - "DevDetail_Tab_Tools_Traceroute_Title": "", - "DevDetail_Tools_WOL": "", - "DevDetail_Tools_WOL_noti": "", - "DevDetail_Tools_WOL_noti_text": "", - "DevDetail_Type_hover": "", - "DevDetail_Vendor_hover": "", - "DevDetail_WOL_Title": "", - "DevDetail_button_AddIcon": "", + "DevDetail_Icon_Descr": "Introduza o nome de um ícone fantástico do tipo de letra sem o prefixo fa- ou com a classe completa, por exemplo: fa fa-brands fa-apple.", + "DevDetail_Loading": "A carregar...", + "DevDetail_MainInfo_Comments": "Comentários", + "DevDetail_MainInfo_Favorite": "Favorito", + "DevDetail_MainInfo_Group": "Grupo", + "DevDetail_MainInfo_Location": "Localização", + "DevDetail_MainInfo_Name": "Nome", + "DevDetail_MainInfo_Network": " Node (MAC)", + "DevDetail_MainInfo_Network_Port": "Porta", + "DevDetail_MainInfo_Network_Site": "Site", + "DevDetail_MainInfo_Network_Title": " Rede", + "DevDetail_MainInfo_Owner": "Proprietário", + "DevDetail_MainInfo_SSID": "SSID", + "DevDetail_MainInfo_Title": " Informações principais", + "DevDetail_MainInfo_Type": "Tipo", + "DevDetail_MainInfo_Vendor": "Vendedor", + "DevDetail_MainInfo_mac": "MAC", + "DevDetail_Network_Node_hover": "Selecione o dispositivo de rede principal ao qual o dispositivo atual está conectado, para preencher a árvore Rede.", + "DevDetail_Network_Port_hover": "A porta a que este dispositivo está ligado no dispositivo de rede principal. Se for deixado vazio, é apresentado um ícone wifi na árvore Rede.", + "DevDetail_Nmap_Scans": "Varreduras manuais do Nmap", + "DevDetail_Nmap_Scans_desc": "Aqui você pode executar varreduras manuais NMAP. Você também pode agendar varreduras automáticas regulares de NMAP através do plugin Serviços & Ports (NMAP). Cabeça para Configurações para descobrir mais", + "DevDetail_Nmap_buttonDefault": "Verificação predefinida", + "DevDetail_Nmap_buttonDefault_text": "Scan padrão: Nmap verifica as 1.000 portas superiores para cada protocolo de digitalização solicitado. Isto atinge cerca de 93% das portas TCP e 49% das portas UDP. (cerca de 5 segundos)", + "DevDetail_Nmap_buttonDetail": "Verificação Detalhada", + "DevDetail_Nmap_buttonDetail_text": "Verificação detalhada: Verificação predefinida com deteção de SO activada, deteção de versão, verificação de scripts e traceroute (até 30 segundos ou mais)", + "DevDetail_Nmap_buttonFast": "Verificação rápida", + "DevDetail_Nmap_buttonFast_text": "Verificação rápida: Verifica menos portas (100) do que a verificação predefinida (alguns segundos)", + "DevDetail_Nmap_buttonSkipDiscovery": "Saltar descoberta do host", + "DevDetail_Nmap_buttonSkipDiscovery_text": "Ignorar a descoberta do host (-Pn opção): Verificação padrão sem descoberta do host", + "DevDetail_Nmap_resultsLink": "Você pode deixar esta página depois de iniciar uma varredura. Os resultados também estarão disponíveis no arquivo app_front.log.", + "DevDetail_Owner_hover": "Quem é o dono deste dispositivo. Campo de texto gratuito.", + "DevDetail_Periodselect_All": "Todas as informações", + "DevDetail_Periodselect_LastMonth": "Último mês", + "DevDetail_Periodselect_LastWeek": "Semana passada", + "DevDetail_Periodselect_LastYear": "Ano passado", + "DevDetail_Periodselect_today": "Hoje", + "DevDetail_Run_Actions_Title": " Executar ação no dispositivo", + "DevDetail_Run_Actions_Tooltip": "Execute uma ação no dispositivo atual da lista suspensa.", + "DevDetail_SessionInfo_FirstSession": "Primeira sessão", + "DevDetail_SessionInfo_LastIP": "Último IP", + "DevDetail_SessionInfo_LastSession": "Último offline", + "DevDetail_SessionInfo_StaticIP": "IP estático", + "DevDetail_SessionInfo_Status": "Estado", + "DevDetail_SessionInfo_Title": " Informações de Sessão", + "DevDetail_SessionTable_Additionalinfo": "Informações adicionais", + "DevDetail_SessionTable_Connection": "Conexão", + "DevDetail_SessionTable_Disconnection": "Desconexão", + "DevDetail_SessionTable_Duration": "Duração", + "DevDetail_SessionTable_IP": "IP", + "DevDetail_SessionTable_Order": "Ordem", + "DevDetail_Shortcut_CurrentStatus": "Estado atual", + "DevDetail_Shortcut_DownAlerts": "Alertas para baixo", + "DevDetail_Shortcut_Presence": "Presença", + "DevDetail_Shortcut_Sessions": "Sessões", + "DevDetail_Tab_Details": " Detalhes", + "DevDetail_Tab_Events": " Eventos", + "DevDetail_Tab_EventsTableDate": "Data", + "DevDetail_Tab_EventsTableEvent": "Tipo de evento", + "DevDetail_Tab_EventsTableIP": "IP", + "DevDetail_Tab_EventsTableInfo": "Informações adicionais", + "DevDetail_Tab_Nmap": " ", + "DevDetail_Tab_NmapEmpty": "Nenhuma porta detectada com Nmap neste dispositivo.", + "DevDetail_Tab_NmapTableExtra": "Adicional", + "DevDetail_Tab_NmapTableHeader": "Resultados da verificação programada", + "DevDetail_Tab_NmapTableIndex": "Índice", + "DevDetail_Tab_NmapTablePort": "Porta", + "DevDetail_Tab_NmapTableService": "Serviço", + "DevDetail_Tab_NmapTableState": "Estado", + "DevDetail_Tab_NmapTableText": "Configure uma programação em Configurações", + "DevDetail_Tab_NmapTableTime": "Tempo", + "DevDetail_Tab_Plugins": " Plugins", + "DevDetail_Tab_Presence": " Presença", + "DevDetail_Tab_Sessions": " Sessões", + "DevDetail_Tab_Tools": " Ferramentas", + "DevDetail_Tab_Tools_Internet_Info_Description": "A ferramenta info Internet exibe informações sobre a conexão com a Internet, como endereço IP, cidade, país, código de área e fuso horário.", + "DevDetail_Tab_Tools_Internet_Info_Error": "Um erro ocorreu", + "DevDetail_Tab_Tools_Internet_Info_Start": "Iniciar informações da Internet", + "DevDetail_Tab_Tools_Internet_Info_Title": "Info Internet", + "DevDetail_Tab_Tools_Nslookup_Description": "Nslookup é uma ferramenta de linha de comando usada para consultar o Sistema de Nomes de Domínio (DNS). DNS é um sistema que traduz nomes de domínio, como www.google.com, em endereços IP, como 172.217.0.142.", + "DevDetail_Tab_Tools_Nslookup_Error": "Erro: O endereço IP não é válido", + "DevDetail_Tab_Tools_Nslookup_Start": "Iniciar Nslookup", + "DevDetail_Tab_Tools_Nslookup_Title": "Nslookup", + "DevDetail_Tab_Tools_Speedtest_Description": "A ferramenta Speedtest mede a velocidade de download, velocidade de upload e latência da conexão de internet.", + "DevDetail_Tab_Tools_Speedtest_Start": "Iniciar Speedtest", + "DevDetail_Tab_Tools_Speedtest_Title": "Speedtest Online", + "DevDetail_Tab_Tools_Traceroute_Description": "Traceroute é um comando de diagnóstico de rede usado para rastrear o caminho que os pacotes de dados levam de um host para outro.

O comando usa o Protocolo de Mensagem de Controle da Internet (ICMP) para enviar pacotes para nós intermediários na rota, cada nó intermediário responde com um pacote ICMP time-out (TTL timed out) .

A saída do comando traceroute exibe o endereço IP de cada nó intermediário na rota.

O comando traceroute pode ser usado para diagnosticar problemas de rede, como atrasos, perda de pacotes e rotas bloqueadas.

Também pode ser usado para identificar a localização de um nó intermediário em uma rede.", + "DevDetail_Tab_Tools_Traceroute_Error": "Erro: O endereço IP não é válido", + "DevDetail_Tab_Tools_Traceroute_Start": "Iniciar Traceroute", + "DevDetail_Tab_Tools_Traceroute_Title": "Rastreamento", + "DevDetail_Tools_WOL": "Enviar comando WoL ", + "DevDetail_Tools_WOL_noti": "Wake-on-LAN", + "DevDetail_Tools_WOL_noti_text": "O comando Wake-on-LAN é enviado para o endereço de transmissão. Se o alvo não estiver na sub-rede/VLAN do NetAlertX, o dispositivo de destino não responderá.", + "DevDetail_Type_hover": "O tipo do dispositivo. Se você selecionar qualquer um dos dispositivos de rede pré-definidos (por exemplo: AP, Firewall, Router, Switch...) eles aparecerão na configuração da árvore de rede como possíveis nós de rede pai.", + "DevDetail_Vendor_hover": "O fornecedor deve ser auto-detectado. Você pode substituir ou adicionar seu valor personalizado.", + "DevDetail_WOL_Title": "", + "DevDetail_button_AddIcon": "Adicionar novo ícone", "DevDetail_button_AddIcon_Help": "", "DevDetail_button_AddIcon_Tooltip": "", "DevDetail_button_Delete": "", @@ -690,4 +690,4 @@ "settings_update_item_warning": "", "test_event_icon": "", "test_event_tooltip": "" -} \ No newline at end of file +} From aeee584939b283a9bf4eb82bf8c6b2bd9da7b2cf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 11:53:49 +0000 Subject: [PATCH 25/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 73785179292cd4849845b44e852d03586c3d65f1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 11:53:53 +0000 Subject: [PATCH 26/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From d18cfb07ff1f0e7007b6cad355a916dc774ec6be Mon Sep 17 00:00:00 2001 From: ffsb Date: Tue, 30 Jul 2024 18:00:36 -0400 Subject: [PATCH 27/44] enabled multiprocessing to parse siwtches and update names... --- .gitignore | 4 +- front/plugins/omada_sdn_imp/omada_sdn.py | 71 +++++++++++++++++++++--- 2 files changed, 65 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index ff1ef480..f833b22a 100755 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,6 @@ __pycache__/ **/last_result.log **/script.log **/pialert.conf_bak -**/pialert.db_bak \ No newline at end of file +**/pialert.db_bak +docker-compose.yml.ffsb42 +.env.omada.ffsb42 diff --git a/front/plugins/omada_sdn_imp/omada_sdn.py b/front/plugins/omada_sdn_imp/omada_sdn.py index 5e9bfe9f..e2a7e4bf 100755 --- a/front/plugins/omada_sdn_imp/omada_sdn.py +++ b/front/plugins/omada_sdn_imp/omada_sdn.py @@ -7,6 +7,7 @@ __version__ = "0.6" # found issue with multithreading - my omada calls redirect __version__ = "0.7" # avoid updating omada sdn client name when it is the MAC, and naxname is also the same MAC... __version__ = "1.0" # fixed the timzone mylog issue by resetting the tz value at the begining of the script... I suspect it doesn't inherit the tz from the main. __version__ = "1.1" # added logic to handle gracefully a failure of omada devices so it won't try to populate uplinks on non-existent switches and AP. +__version__ = "1.2" # finally got multiprocessing to work to parse devices AND to update names! yeah! # query OMADA SDN to populate NetAlertX witch omada switches, access points, clients. @@ -28,8 +29,10 @@ import importlib.util import time import io import re -import concurrent.futures - +#import concurrent.futures +import subprocess +import multiprocessing + #import netifaces @@ -46,6 +49,7 @@ from notification import write_notification from pytz import timezone import conf conf.tz = timezone(get_setting_value('TIMEZONE')) +PARALLELISM = 4 # Define the current path and log file paths CUR_PATH = str(pathlib.Path(__file__).parent.resolve()) @@ -271,6 +275,20 @@ def get_omada_devices_details(msadevice_data): nswitch_dump = '' return mswitch_detail, mswitch_dump +def get_omada_devices_details_parallel(msadevice_data): + mthisswitch = msadevice_data[dMAC] + mtype = msadevice_data[dTYPE] + mswitch_detail = '' + mswitch_dump = '' + if mtype == 'ap': + mswitch_detail = subprocess.run('omada access-point '+mthisswitch, capture_output=True, text=True, shell=True).stdout + elif mtype == 'switch': + mswitch_detail = subprocess.run('omada switch '+mthisswitch, capture_output=True, text=True, shell=True).stdout + mswitch_dump = subprocess.run('omada access-point '+mthisswitch, capture_output=True, text=True, shell=True).stdout + else: + mswitch_detail = '' + mswitch_dump = '' + return mthisswitch, mswitch_detail, mswitch_dump # ---------------------------------------------- @@ -296,19 +314,36 @@ def get_device_data(omada_clients_output,switches_and_aps,device_handler): omada_force_overwrite = get_setting_value('OMDSDN_force_overwrite') switch_details = {} switch_dumps = {} - + ''' + command = 'which omada' + def run_command(command, index): + result = subprocess.run(command, capture_output=True, text=True, shell=True) + return str(index), result.stdout.strip() + + myindex, command_output= run_command(command, 2) + mylog('verbose', [f'[{pluginName}] command={command} index={myindex} results={command_output}']) + ''' sadevices = switches_and_aps.splitlines() mylog(OMDLOGLEVEL, [f'[{pluginName}] switches_and_aps rows: "{len(sadevices)}"']) + with multiprocessing.Pool(processes = PARALLELISM) as mypool: + oresults = mypool.map(get_omada_devices_details_parallel, [sadevice.split() for sadevice in sadevices]) + + for thisswitch, details, dump in oresults: + switch_details[thisswitch] = details + switch_dumps[thisswitch] = dump + mylog(OMDLOGLEVEL, [f'[{pluginName}] switch={thisswitch} details={details}']) + + ''' for sadevice in sadevices: sadevice_data = sadevice.split() thisswitch = sadevice_data[dMAC] thistype = sadevice_data[dTYPE] switch_details[thisswitch], switch_dumps[thisswitch] = get_omada_devices_details(sadevice_data) + ''' mylog('verbose', [f'[{pluginName}] switches details collected "{len(switch_details)}"']) mylog('verbose', [f'[{pluginName}] dump details collected "{len(switch_details)}"']) - # Using ThreadPoolExecutor for parallel execution for sadevice in sadevices: sadevice_data = sadevice.split() @@ -381,6 +416,8 @@ def get_device_data(omada_clients_output,switches_and_aps,device_handler): odevices = omada_clients_output.splitlines() mylog(OMDLOGLEVEL, [f'[{pluginName}] omada_clients_outputs rows: "{len(odevices)}"']) + omada_clients_to_rename = [] + for odevice in odevices: odevice_data = odevice.split() odevice_data_reordered = [ MAC, IP, NAME, SWITCH_AP, PORT_SSID, TYPE] @@ -392,7 +429,7 @@ def get_device_data(omada_clients_output,switches_and_aps,device_handler): # if the name stored in Nax for a device is empty or the MAC addres or has some parenthhesis or is the same as in omada # don't bother updating omada's name at all. # - + naxname = real_naxname if real_naxname != None: if '(' in real_naxname: @@ -406,17 +443,25 @@ def get_device_data(omada_clients_output,switches_and_aps,device_handler): mylog('debug', [f'[{pluginName}] TEST name from MAC: {naxname}']) if odevice_data[cNAME] in ('null', ''): mylog('verbose', [f'[{pluginName}] updating omada server because odevice_data is: {odevice_data[cNAME]} and naxname is: "{naxname}"']) - callomada(['set-client-name', odevice_data[cMAC], naxname]) + omada_clients_to_rename.append(['set-client-name',odevice_data[cMAC], naxname]) + #callomada(['set-client-name', odevice_data[cMAC], naxname]) odevice_data_reordered[NAME] = naxname elif odevice_data[cNAME] == odevice_data[cMAC] and ieee2ietf_mac_formater(naxname) != ieee2ietf_mac_formater(odevice_data[cNAME]) : mylog('verbose', [f'[{pluginName}] updating omada server because odevice_data is: "{odevice_data[cNAME]} and naxname is: "{naxname}"']) - callomada(['set-client-name', odevice_data[cMAC], naxname]) + omada_clients_to_rename.append(['set-client-name',odevice_data[cMAC], naxname]) + #callomada(['set-client-name', odevice_data[cMAC], naxname]) odevice_data_reordered[NAME] = naxname else: if omada_force_overwrite and naxname != odevice_data[cNAME] : mylog('verbose', [f'[{pluginName}] updating omada server because odevice_data is: "{odevice_data[cNAME]} and naxname is: "{naxname}"']) - callomada(['set-client-name', odevice_data[cMAC], naxname]) + omada_clients_to_rename.append(['set-client-name',odevice_data[cMAC], naxname]) + #callomada(['set-client-name', odevice_data[cMAC], naxname]) odevice_data_reordered[NAME] = naxname + + + + + mightbeport = odevice_data[cPORT_SSID].lstrip('(') mightbeport = mightbeport.rstrip(')') if mightbeport.isdigit(): @@ -438,9 +483,17 @@ def get_device_data(omada_clients_output,switches_and_aps,device_handler): device_data_mac_byip[odevice_data_reordered[IP]] = odevice_data_reordered[MAC] mylog(OMDLOGLEVEL, [f'[{pluginName}] tokens: "{odevice_data}"']) mylog(OMDLOGLEVEL, [f'[{pluginName}] tokens_reordered: "{odevice_data_reordered}"']) + # RENAMING + #for omada_client_to_rename in omada_clients_to_rename: + # mylog('verbose', [f'[{pluginName}] calling omada: "{omada_client_to_rename}"']) + #callomada(omada_client_to_rename) + # populating the uplinks nodes of the omada switches and access points manually # since OMADA SDN makes is unreliable if the gateway is not their own tplink hardware... - + # + with multiprocessing.Pool(processes = PARALLELISM) as mypool2: + oresults = mypool2.map(callomada, omada_clients_to_rename) + mylog(OMDLOGLEVEL, [f'[{pluginName}] results are: "{oresults}"']) # step1 let's find the the default router # From 4d329d47f37ec6455d0dfe3a6a97f71be1aece90 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:53:43 +0000 Subject: [PATCH 28/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 2e45cf36f2418c42e3b46ac5cd57ee8e6c84cc14 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:53:44 +0000 Subject: [PATCH 29/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 9cc994e1577e00ef90c4b02123b52690e766d946 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Fri, 2 Aug 2024 07:47:12 +1000 Subject: [PATCH 30/44] =?UTF-8?q?=F0=9F=93=A5Bare-metal=20install=20work?= =?UTF-8?q?=20#753?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 8 +++++++- docker-compose.yml | 1 + install/install_dependencies.debian.sh | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ff1ef480..f7dd804a 100755 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,10 @@ __pycache__/ **/last_result.log **/script.log **/pialert.conf_bak -**/pialert.db_bak \ No newline at end of file +**/pialert.db_bak + + +front/img/account/* +**/account.php +**/account.js +front/css/account.css \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 06e13f02..8bb12e09 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -54,6 +54,7 @@ services: - ${DEV_LOCATION}/front/presence.php:/app/front/presence.php - ${DEV_LOCATION}/front/settings.php:/app/front/settings.php - ${DEV_LOCATION}/front/systeminfo.php:/app/front/systeminfo.php + - ${DEV_LOCATION}/front/account.php:/app/front/account.php - ${DEV_LOCATION}/front/report.php:/app/front/report.php - ${DEV_LOCATION}/front/workflows.php:/app/front/workflows.php - ${DEV_LOCATION}/front/appEventsCore.php:/app/front/appEventsCore.php diff --git a/install/install_dependencies.debian.sh b/install/install_dependencies.debian.sh index 247067b5..293e2e8c 100755 --- a/install/install_dependencies.debian.sh +++ b/install/install_dependencies.debian.sh @@ -16,7 +16,7 @@ fi apt-get install -y \ tini snmp ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo \ nginx-light php php-cgi php-fpm php-sqlite3 php-curl php-openssl sqlite3 dnsutils net-tools \ - python3 python3-dev iproute2 nmap python3-pip zip systemctl usbutils traceroute nbtscan + python3 python3-dev iproute2 nmap python3-pip zip systemctl usbutils traceroute nbtscan build-essential # alternate dependencies sudo apt-get install nginx nginx-core mtr php-fpm php8.2-fpm php-cli php8.2 php8.2-sqlite3 -y From 4b2b8d6dd138b93edf59678bbaa6f5760da84b76 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Fri, 2 Aug 2024 08:01:08 +1000 Subject: [PATCH 31/44] =?UTF-8?q?=F0=9F=93=A5Bare-metal=20install=20work?= =?UTF-8?q?=20#753?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/app.conf | 2 +- install/netalertx.debian.conf | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/back/app.conf b/back/app.conf index bfc6cc34..c122d021 100755 --- a/back/app.conf +++ b/back/app.conf @@ -17,7 +17,7 @@ # Scan multiple interfaces (eth1 and eth0): # SCAN_SUBNETS = [ '192.168.1.0/24 --interface=eth1', '192.168.1.0/24 --interface=eth0' ] -SCAN_SUBNETS=['192.168.1.0/24 --interface=eth1'] +SCAN_SUBNETS=['192.168.1.0/24 --interface=eth0'] TIMEZONE='Europe/Berlin' LOADED_PLUGINS = ['ARPSCAN','CSVBCKP','DBCLNP', 'INTRNT','MAINT','NEWDEV','NSLOOKUP','NTFPRCS', 'PHOLUS','SETPWD','SMTP', 'SYNC', 'VNDRPDT', 'WORKFLOWS'] diff --git a/install/netalertx.debian.conf b/install/netalertx.debian.conf index 537675ad..4cb02a9a 100755 --- a/install/netalertx.debian.conf +++ b/install/netalertx.debian.conf @@ -1,10 +1,10 @@ server { listen 20211 default_server; - root /var/www/html/app; + root /var/www/html/netalertx; index index.php; #rewrite /app/(.*) / permanent; - add_header X-Forwarded-Prefix "/app" always; - proxy_set_header X-Forwarded-Prefix "/app"; + add_header X-Forwarded-Prefix "/netalertx" always; + proxy_set_header X-Forwarded-Prefix "/netalertx"; location ~* \.php$ { # Set Cache-Control header to prevent caching on the first load From e066a65f1b8e535c30bd5f333c08dcba18bfd6a8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 11:53:39 +0000 Subject: [PATCH 32/44] =?UTF-8?q?[=F0=9F=A4=96Automation]=20Update=20READM?= =?UTF-8?q?E=20with=20sponsors=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 1f7a38593dfc5335a3fcd3c556e4fff227e51ca7 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Sat, 3 Aug 2024 21:07:12 +1000 Subject: [PATCH 33/44] =?UTF-8?q?=F0=9F=94=84Cache=20+=20Settings=20work?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/deviceDetails.php | 2 +- front/devices.php | 30 +-- front/js/common.js | 237 ++++++++++++++-------- front/js/db_methods.js | 2 +- front/js/settings_utils.js | 31 +-- front/js/ui_components.js | 136 +++++-------- front/multiEditCore.php | 21 +- front/plugins/__template/config.json | 19 +- front/plugins/dhcp_leases/config.json | 19 +- front/plugins/newdev_template/config.json | 73 +++---- front/plugins/omada_sdn_imp/config.json | 19 +- front/plugins/snmp_discovery/config.json | 19 +- front/plugins/undiscoverables/config.json | 19 +- front/plugins/unifi_import/config.json | 20 +- front/plugins/website_monitor/config.json | 19 +- front/settings.php | 29 ++- server/initialise.py | 4 +- 17 files changed, 370 insertions(+), 329 deletions(-) diff --git a/front/deviceDetails.php b/front/deviceDetails.php index 03c44d92..2847d15f 100755 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -1149,7 +1149,7 @@ function initializeCalendar () { } else { setTimeout(() => { updateIconPreview('#txtIcon') - }, 100); + }, 500); hideSpinner() } diff --git a/front/devices.php b/front/devices.php index f5e8001a..092a845b 100755 --- a/front/devices.php +++ b/front/devices.php @@ -143,9 +143,23 @@ var tableOrder = [[3,'desc'], [0,'asc']]; var tableColumnHide = []; + var tableColumnOrder = []; + var tableColumnVisible = []; - //initialize the table headers in the correct order - var headersDefaultOrder = [ + + + + // Read parameters & Initialize components + callAfterAppInitialized(main) + showSpinner(); + + + +// ----------------------------------------------------------------------------- +function main () { + + //initialize the table headers in the correct order + var headersDefaultOrder = [ getString('Device_TableHead_Name'), getString('Device_TableHead_Owner'), getString('Device_TableHead_Type'), @@ -173,16 +187,8 @@ // generate default order lists of given length var columnsStr = JSON.stringify(Array.from({ length: headersDefaultOrder.length }, (_, i) => i)); - var tableColumnOrder = Array.from({ length: headersDefaultOrder.length }, (_, i) => i); - var tableColumnVisible = tableColumnOrder; - - // Read parameters & Initialize components - showSpinner(); - main(); - - -// ----------------------------------------------------------------------------- -function main () { + tableColumnOrder = Array.from({ length: headersDefaultOrder.length }, (_, i) => i); + tableColumnVisible = tableColumnOrder; handleLoadingDialog() diff --git a/front/js/common.js b/front/js/common.js index d659ff71..20b5322b 100755 --- a/front/js/common.js +++ b/front/js/common.js @@ -10,9 +10,10 @@ // ----------------------------------------------------------------------------- var timerRefreshData = '' -var emptyArr = ['undefined', "", undefined, null, 'null']; -var UI_LANG = "English"; -var settingsJSON = {} +var emptyArr = ['undefined', "", undefined, null, 'null']; +var UI_LANG = "English"; +const allLanguages = ["en_us", "es_es", "de_de", "fr_fr", "it_it", "ru_ru", "nb_no", "pl_pl", "zh_cn"]; // needs to be same as in lang.php +var settingsJSON = {} // ----------------------------------------------------------------------------- @@ -207,98 +208,123 @@ function getSetting (key) { // ----------------------------------------------------------------------------- // Get language string // ----------------------------------------------------------------------------- -function cacheStrings() -{ +function cacheStrings() { return new Promise((resolve, reject) => { - if(!getCache('completedCalls').includes('cacheStrings')) - { - // handle core strings and translations - var allLanguages = ["en_us", "es_es", "de_de", "fr_fr", "it_it", "ru_ru", "nb_no", "pl_pl", "zh_cn"]; // needs to be same as in lang.php - - allLanguages.forEach(function (language_code) { - $.get(`php/templates/language/${language_code}.json?nocache=${Date.now()}`, function (res) { - // Iterate over each language - Object.entries(res).forEach(([key, value]) => { - // Store translations for each key-value pair - setCache(`pia_lang_${key}_${language_code}`, value) - }); - - // handle strings and translations from plugins - $.get(`api/table_plugins_language_strings.json?nocache=${Date.now()}`, function(res) { - - data = res["data"]; - - data.forEach((langString) => { - setCache(`pia_lang_${langString.String_Key}_${langString.Language_Code}`, langString.String_Value) - }); - }).then(() => handleSuccess('cacheStrings', resolve())).catch(() => handleFailure('cacheStrings', reject("cacheStrings already completed"))); // handle AJAX synchronization + + // Create a promise for each language + const languagePromises = allLanguages.map((language_code) => { + return new Promise((resolveLang, rejectLang) => { + // Fetch core strings and translations + $.get(`php/templates/language/${language_code}.json?nocache=${Date.now()}`) + .done((res) => { + // Iterate over each key-value pair and store the translations + Object.entries(res).forEach(([key, value]) => { + setCache(`pia_lang_${key}_${language_code}`, value); + }); + + // Fetch strings and translations from plugins + $.get(`api/table_plugins_language_strings.json?nocache=${Date.now()}`) + .done((pluginRes) => { + const data = pluginRes["data"]; + + // Store plugin translations + data.forEach((langString) => { + setCache(`pia_lang_${langString.String_Key}_${langString.Language_Code}`, langString.String_Value); + }); + + // Handle successful completion of language processing + handleSuccess(`cacheStrings[${language_code}]`, resolveLang); + }) + .fail((pluginError) => { + // Handle failure in plugin strings fetching + rejectLang(pluginError); + }); + }) + .fail((error) => { + // Handle failure in core strings fetching + rejectLang(error); + }); }); }); - } + + // Wait for all language promises to complete + Promise.all(languagePromises) + .then(() => { + // All languages processed successfully + resolve(); + }) + .catch((error) => { + // Handle failure in any of the language processing + handleFailure('cacheStrings', reject); + }); + }); } +// ----------------------------------------------------------------------------- // Get translated language string -function getString (key) { +function getString(key) { - // handle initial load to make sure everything is set-up and cached - handleFirstLoad(getString) - - UI_LANG = getSetting("UI_LANG"); + function fetchString(key) { + UI_LANG = getSetting("UI_LANG"); - lang_code = 'en_us'; + let lang_code = 'en_us'; - switch(UI_LANG) - { - case 'English': - lang_code = 'en_us'; - break; - case 'Spanish': - lang_code = 'es_es'; - break; - case 'German': - lang_code = 'de_de'; - break; - case 'French': - lang_code = 'fr_fr'; - break; - case 'Norwegian': - lang_code = 'nb_no'; - break; - case 'Polish (pl_pl)': - lang_code = 'pl_pl'; - break; - case 'Portuguese (pt_br)': - lang_code = 'pt_br'; - break; - case 'Turkish (tr_tr)': - lang_code = 'tr_tr'; - break; - case 'Italian (it_it)': - lang_code = 'it_it'; - break; - case 'Russian': - lang_code = 'ru_ru'; - break; - case 'Chinese (zh_cn)': - lang_code = 'zh_cn'; - break; - } - result = getCache(`pia_lang_${key}_${lang_code}`, true); + switch (UI_LANG) { + case 'English': + lang_code = 'en_us'; + break; + case 'Spanish': + lang_code = 'es_es'; + break; + case 'German': + lang_code = 'de_de'; + break; + case 'French': + lang_code = 'fr_fr'; + break; + case 'Norwegian': + lang_code = 'nb_no'; + break; + case 'Polish (pl_pl)': + lang_code = 'pl_pl'; + break; + case 'Portuguese (pt_br)': + lang_code = 'pt_br'; + break; + case 'Turkish (tr_tr)': + lang_code = 'tr_tr'; + break; + case 'Italian (it_it)': + lang_code = 'it_it'; + break; + case 'Russian': + lang_code = 'ru_ru'; + break; + case 'Chinese (zh_cn)': + lang_code = 'zh_cn'; + break; + } + let result = getCache(`pia_lang_${key}_${lang_code}`, true); - if(isEmpty(result)) - { - result = getCache(`pia_lang_${key}_en_us`, true); + if (isEmpty(result)) { + result = getCache(`pia_lang_${key}_en_us`, true); + } + + return result; } - return result; + if (isAppInitialized()) { + return fetchString(key); + } else { + callAfterAppInitialized(() => fetchString(key)); + } } - // ----------------------------------------------------------------------------- // String utilities // ----------------------------------------------------------------------------- @@ -334,6 +360,15 @@ function isValidBase64(str) { } +function isValidJSON(jsonString) { + try { + JSON.parse(jsonString); + return true; + } catch (e) { + return false; + } +} + // ----------------------------------------------------------------------------- // General utilities // ----------------------------------------------------------------------------- @@ -835,7 +870,7 @@ function getDeviceDataByMac(macAddress, dbColumn) { } // ----------------------------------------------------------------------------- -// Cache teh devices as one JSON +// Cache the devices as one JSON function cacheDevices() { @@ -918,6 +953,8 @@ function showSpinner(stringKey='Loading') text = getString(stringKey) } + text = isEmpty(text) ? "Loading" : text; + if($("#loadingSpinner").length) { $("#loadingSpinner").show(); @@ -1102,6 +1139,8 @@ function arraysContainSameValues(arr1, arr2) { const sessionStorageKey = "myScriptExecuted_common_js"; var completedCalls = [] var completedCalls_final = ['cacheSettings', 'cacheStrings', 'cacheDevices']; +var completedCallsCount = 0; +var completedCallsCount_final = allLanguages.length + 2; // number of language files + cacheDevices + cacheSettings // ----------------------------------------------------------------------------- // Clearing all the caches @@ -1139,10 +1178,24 @@ async function handleFirstLoad(callback) { } } +// ----------------------------------------------------------------------------- +// Execute callback once app initialized +function callAfterAppInitialized(callback) { + if (!isAppInitialized()) { + setTimeout(() => { + callAfterAppInitialized(callback) + }, 500); + } else + { + callback(); + } +} + // ----------------------------------------------------------------------------- // Check if the code has been executed before by checking sessionStorage function isAppInitialized() { - return arraysContainSameValues(getCache("completedCalls").split(',').filter(Boolean), completedCalls_final); + // return arraysContainSameValues(getCache("completedCalls").split(',').filter(Boolean), completedCalls_final); + return (parseInt(getCache("completedCallsCount")) == completedCallsCount_final); } // Define a function that will execute the code only once @@ -1151,9 +1204,10 @@ async function executeOnce() { if (!isAppInitialized()) { try { - await cacheStrings(); - await cacheSettings(); await cacheDevices(); + await cacheSettings(); + await cacheStrings(); + console.log("✅ All AJAX callbacks have completed"); onAllCallsComplete(); } catch (error) { @@ -1166,8 +1220,20 @@ async function executeOnce() { // Function to handle successful completion of an AJAX call const handleSuccess = (callName) => { console.log(`AJAX call successful: ${callName}`); - completedCalls.push(callName); - setCache('completedCalls', mergeUniqueArrays(getCache('completedCalls').split(','), [callName])); + // completedCalls.push(callName); + // setCache('completedCalls', mergeUniqueArrays(getCache('completedCalls').split(','), [callName])); + + val = getCache('completedCallsCount'); + + if(val == "") + { + val = 0; + } else + { + val = parseInt(val) + } + + setCache('completedCallsCount', val + 1) }; // ----------------------------------------------------------------------------- @@ -1190,6 +1256,10 @@ const onAllCallsComplete = () => { sessionStorage.setItem(sessionStorageKey + '_time', millisecondsNow); console.log('✔ Cache initialized'); + // setTimeout(() => { + // location.reload() + // }, 10); + } else { // If not all strings are initialized, retry initialization console.log('❌ Not all strings are initialized. Retrying...'); @@ -1199,14 +1269,13 @@ const onAllCallsComplete = () => { // Call any other initialization functions here if needed - // No need for location.reload() here }; // Function to check if all necessary strings are initialized const areAllStringsInitialized = () => { // Implement logic to check if all necessary strings are initialized // Return true if all strings are initialized, false otherwise - return getString('UI_LANG') != "" + return getString('UI_LANG_name') != "" }; // Call the function to execute the code diff --git a/front/js/db_methods.js b/front/js/db_methods.js index 363f273f..c0373a99 100755 --- a/front/js/db_methods.js +++ b/front/js/db_methods.js @@ -89,7 +89,7 @@ function checkDbLock() { type: "GET", success: function (response) { - console.log(response); + // console.log(response); if (response == 0) { // console.log('Database is not locked'); $(".header-status-locked-db").hide(); diff --git a/front/js/settings_utils.js b/front/js/settings_utils.js index a810e41f..52ae1b81 100755 --- a/front/js/settings_utils.js +++ b/front/js/settings_utils.js @@ -259,7 +259,8 @@ function addList(element, clearInput = true) { .attr("value", input) .text(input); - const el = $(`#${toId}`).append(newOption); + // add new option + $(`#${toId}`).append(newOption); // clear input if (clearInput) { @@ -269,6 +270,7 @@ function addList(element, clearInput = true) { // Initialize interaction options only for the newly added option initListInteractionOptions(newOption); + // flag something changes to prevent navigating from page settingsChanged(); } @@ -279,31 +281,6 @@ function removeFromList(element) { .find("option:last") .remove(); } -// --------------------------------------------------------- -function addInterface() { - ipMask = $("#ipMask").val(); - ipInterface = $("#ipInterface").val(); - - full = ipMask + " --interface=" + ipInterface; - - console.log(full); - - if (ipMask == "" || ipInterface == "") { - showModalOk( - "Validation error", - "Specify both, the network mask and the interface" - ); - } else { - $("#SCAN_SUBNETS").append( - $("").attr("value", full).text(full) - ); - - $("#ipMask").val(""); - $("#ipInterface").val(""); - - settingsChanged(); - } -} // ------------------------------------------------------------------- // Function to remove an item from the select element @@ -555,7 +532,7 @@ function generateOptionsOrSetOptions( transformers = [] // Transformers to be applied to the values ) { - console.log(codeName); + // console.log(codeName); // NOTE {value} options to replace with a setting or SQL value are handled in the cacheSettings() function options = arrayToObject(createArray(getSettingOptions(codeName))) diff --git a/front/js/ui_components.js b/front/js/ui_components.js index 9158b185..40a5f0fe 100755 --- a/front/js/ui_components.js +++ b/front/js/ui_components.js @@ -11,16 +11,7 @@ // ----------------------------------------------------------------------------- // Initialize device selectors / pickers fields // ----------------------------------------------------------------------------- -function initDeviceSelectors() { - - // console.log(devicesList) - // Retrieve device list from session variable - var devicesListAll_JSON = getCache('devicesListAll_JSON'); - - var devicesList = JSON.parse(devicesListAll_JSON); - - // console.log(devicesList); - +function initDeviceSelectors(devicesListAll_JSON) { // Check if both device list exists if (devicesListAll_JSON) { @@ -78,52 +69,6 @@ function initDeviceSelectors() { -// // ----------------------------------------------------------------------------- -// // (ASYNC) Initiate dropdown -// function generateSetOptions(settingKey, // Identifier for the setting -// valuesArray, // Array of values to be pre-selected in the dropdown -// targetLocation, // ID of the HTML element where dropdown should be rendered (will be replaced) -// callbackToGenerateEntries, // Callback function to generate entries based on options -// targetField, // Target field or element where selected value should be applied or updated -// nameTransformer) // callback to transform the name (e.g. base64) -// { - -// var optionsHtml = "" - -// // NOTE {value} options to replace with a setting or SQL value are handled in the cacheSettings() function -// optionsArray = createArray(getSettingOptions(settingKey)) - - -// // check if the result is a SQL query -// if(optionsArray.length > 0 && isSQLQuery(optionsArray[0])) -// { - -// if (settingKey == "NEWDEV_dev_Network_Node_MAC_ADDR") { -// console.log("isSQLQuery in generateSetOptions"); - -// } -// readData(optionsArray[0], callbackToGenerateEntries, valuesArray, targetLocation, targetField, nameTransformer); - -// } else // this should be already an array, e.g. from a setting or pre-defined -// { -// optionsArray.forEach(option => { -// let selected = valuesArray.includes(option) ? 'selected' : ''; -// optionsHtml += ``; -// }); - -// // Replace the specified placeholder div with the resulting HTML -// setTimeout(() => { - -// $("#" + targetLocation).replaceWith(optionsHtml); - -// }, 50); -// } - - - -// } - - // ----------------------------------------------------------------------------- // Hide elements on the page based on the supplied setting function hideUIelements(settingKey) { @@ -290,42 +235,57 @@ function getCellValue(row, index) { // initialize // ----------------------------------------------------------------------------- +function initSelect2() { -setTimeout(() => { + // Retrieve device list from session variable + var devicesListAll_JSON = getCache('devicesListAll_JSON'); - initDeviceSelectors(); + // check if cache ready + if(isValidJSON(devicesListAll_JSON)) + { + // prepare HTML DOM before initializing the frotend + initDeviceSelectors(devicesListAll_JSON) - - // -------------------------------------------------------- - //Initialize Select2 Elements and make them sortable - - $(function () { - // Iterate over each Select2 dropdown - $('.select2').each(function() { - var selectEl = $(this).select2(); - - // Apply sortable functionality to the dropdown's dropdown-container - selectEl.next().children().children().children().sortable({ - containment: 'parent', - update: function () { - var sortedValues = $(this).children().map(function() { - return $(this).attr('title'); - }).get(); - - var sortedOptions = selectEl.find('option').sort(function(a, b) { - return sortedValues.indexOf($(a).text()) - sortedValues.indexOf($(b).text()); - }); - - // Replace all options in selectEl - selectEl.empty().append(sortedOptions); - - // Trigger change event on Select2 - selectEl.trigger('change'); - } - }); + + // -------------------------------------------------------- + //Initialize Select2 Elements and make them sortable + $(function () { + // Iterate over each Select2 dropdown + $('.select2').each(function() { + var selectEl = $(this).select2(); + + // Apply sortable functionality to the dropdown's dropdown-container + selectEl.next().children().children().children().sortable({ + containment: 'parent', + update: function () { + var sortedValues = $(this).children().map(function() { + return $(this).attr('title'); + }).get(); + + var sortedOptions = selectEl.find('option').sort(function(a, b) { + return sortedValues.indexOf($(a).text()) - sortedValues.indexOf($(b).text()); + }); + + // Replace all options in selectEl + selectEl.empty().append(sortedOptions); + + // Trigger change event on Select2 + selectEl.trigger('change'); + } + }); + }); }); - }); - + } else // cache not ready try later + { + setTimeout(() => { + initSelect2() + }, 1000); + } +} + +// try to initialize select2 +setTimeout(() => { + initSelect2() }, 500); diff --git a/front/multiEditCore.php b/front/multiEditCore.php index c8f6bb38..987327ab 100755 --- a/front/multiEditCore.php +++ b/front/multiEditCore.php @@ -101,10 +101,19 @@ for (let j = i * elementsPerColumn; j < Math.min((i + 1) * elementsPerColumn, columns.length); j++) { const setTypeObject = JSON.parse(columns[j].Type.replace(/'/g, '"')); - // console.log(setTypeObject); - const lastElementObj = setTypeObject.elements[setTypeObject.elements.length - 1] + // console.log(setTypeObject); 🔽 + // const lastElementObj = setTypeObject.elements[setTypeObject.elements.length - 1] - const { elementType, elementOptions = [], transformers = [] } = lastElementObj; + // get the element with the input value(s) + let elementsWithInputValue = setTypeObject.elements.filter(element => element.elementHasInputValue === 1); + + // if none found, take last + if(elementsWithInputValue.length == 0) + { + elementsWithInputValue = setTypeObject.elements[setTypeObject.elements.length - 1] + } + + const { elementType, elementOptions = [], transformers = [] } = elementsWithInputValue; const { inputType, readOnly, @@ -123,8 +132,8 @@ // console.log(setTypeObject); // console.log(inputType); - // render based on element type - if (lastElementObj.elementType === 'select') { + // render based on element type + if (elementsWithInputValue.elementType === 'select') { targetLocation = columns[j].Code_Name + "_generateSetOptions" @@ -154,7 +163,7 @@ } - } else if (lastElementObj.elementType === 'input'){ + } else if (elementsWithInputValue.elementType === 'input'){ // Add classes specifically for checkboxes inputType === 'checkbox' ? inputClass = 'checkbox' : inputClass = 'form-control'; diff --git a/front/plugins/__template/config.json b/front/plugins/__template/config.json index dafc1986..639bb89f 100755 --- a/front/plugins/__template/config.json +++ b/front/plugins/__template/config.json @@ -173,6 +173,16 @@ ], "transformers": [] }, + { + "elementType": "select", + "elementHasInputValue": 1, + "elementOptions": [ + { "multiple": "true" }, + { "readonly": "true" }, + { "editable": "true" } + ], + "transformers": [] + }, { "elementType": "button", "elementOptions": [ @@ -194,15 +204,6 @@ { "getStringKey": "Gen_Remove_Last" } ], "transformers": [] - }, - { - "elementType": "select", - "elementOptions": [ - { "multiple": "true" }, - { "readonly": "true" }, - { "editable": "true" } - ], - "transformers": [] } ] }, diff --git a/front/plugins/dhcp_leases/config.json b/front/plugins/dhcp_leases/config.json index 4900929b..996d7e92 100755 --- a/front/plugins/dhcp_leases/config.json +++ b/front/plugins/dhcp_leases/config.json @@ -525,6 +525,16 @@ ], "transformers": [] }, + { + "elementType": "select", + "elementHasInputValue": 1, + "elementOptions": [ + { "multiple": "true" }, + { "readonly": "true" }, + { "editable": "true" } + ], + "transformers": [] + }, { "elementType": "button", "elementOptions": [ @@ -546,15 +556,6 @@ { "getStringKey": "Gen_Remove_Last" } ], "transformers": [] - }, - { - "elementType": "select", - "elementOptions": [ - { "multiple": "true" }, - { "readonly": "true" }, - { "editable": "true" } - ], - "transformers": [] } ] }, diff --git a/front/plugins/newdev_template/config.json b/front/plugins/newdev_template/config.json index 1d2b0357..c61653e3 100755 --- a/front/plugins/newdev_template/config.json +++ b/front/plugins/newdev_template/config.json @@ -52,6 +52,16 @@ ], "transformers": [] }, + { + "elementType": "select", + "elementHasInputValue": 1, + "elementOptions": [ + { "multiple": "true" }, + { "readonly": "true" }, + { "editable": "true" } + ], + "transformers": [] + }, { "elementType": "button", "elementOptions": [ @@ -73,15 +83,6 @@ { "getStringKey": "Gen_Remove_Last" } ], "transformers": [] - }, - { - "elementType": "select", - "elementOptions": [ - { "multiple": "true" }, - { "readonly": "true" }, - { "editable": "true" } - ], - "transformers": [] } ] }, @@ -127,6 +128,16 @@ ], "transformers": [] }, + { + "elementType": "select", + "elementHasInputValue": 1, + "elementOptions": [ + { "multiple": "true" }, + { "readonly": "true" }, + { "editable": "true" } + ], + "transformers": [] + }, { "elementType": "button", "elementOptions": [ @@ -148,15 +159,6 @@ { "getStringKey": "Gen_Remove_Last" } ], "transformers": [] - }, - { - "elementType": "select", - "elementOptions": [ - { "multiple": "true" }, - { "readonly": "true" }, - { "editable": "true" } - ], - "transformers": [] } ] }, @@ -194,14 +196,24 @@ { "elementType": "button", "elementOptions": [ - { "sourceSuffixes": [] }, + { "sourceSuffixes": ["_in"] }, { "separator": "" }, - { "cssClasses": "col-sm-3" }, - { "onClick": "removeAllOptions(this)" }, - { "getStringKey": "Gen_Remove_All" } + { "cssClasses": "col-sm-2" }, + { "onClick": "addList(this, false)" }, + { "getStringKey": "Gen_Add" } ], "transformers": [] }, + { + "elementType": "select", + "elementHasInputValue": 1, + "elementOptions": [ + { "multiple": "true" }, + { "readonly": "true" }, + { "editable": "true" } + ], + "transformers": ["base64"] + }, { "elementType": "button", "elementOptions": [ @@ -216,22 +228,13 @@ { "elementType": "button", "elementOptions": [ - { "sourceSuffixes": ["_in"] }, + { "sourceSuffixes": [] }, { "separator": "" }, - { "cssClasses": "col-sm-2" }, - { "onClick": "addList(this, false)" }, - { "getStringKey": "Gen_Add" } + { "cssClasses": "col-sm-3" }, + { "onClick": "removeAllOptions(this)" }, + { "getStringKey": "Gen_Remove_All" } ], "transformers": [] - }, - { - "elementType": "select", - "elementOptions": [ - { "multiple": "true" }, - { "readonly": "true" }, - { "editable": "true" } - ], - "transformers": ["base64"] } ] }, diff --git a/front/plugins/omada_sdn_imp/config.json b/front/plugins/omada_sdn_imp/config.json index 3aff59b6..31fc14d0 100755 --- a/front/plugins/omada_sdn_imp/config.json +++ b/front/plugins/omada_sdn_imp/config.json @@ -155,6 +155,16 @@ ], "transformers": [] }, + { + "elementType": "select", + "elementHasInputValue": 1, + "elementOptions": [ + { "multiple": "true" }, + { "readonly": "true" }, + { "editable": "true" } + ], + "transformers": [] + }, { "elementType": "button", "elementOptions": [ @@ -176,15 +186,6 @@ { "getStringKey": "Gen_Remove_Last" } ], "transformers": [] - }, - { - "elementType": "select", - "elementOptions": [ - { "multiple": "true" }, - { "readonly": "true" }, - { "editable": "true" } - ], - "transformers": [] } ] }, diff --git a/front/plugins/snmp_discovery/config.json b/front/plugins/snmp_discovery/config.json index 67f72466..7c58372f 100755 --- a/front/plugins/snmp_discovery/config.json +++ b/front/plugins/snmp_discovery/config.json @@ -434,6 +434,16 @@ ], "transformers": [] }, + { + "elementType": "select", + "elementHasInputValue": 1, + "elementOptions": [ + { "multiple": "true" }, + { "readonly": "true" }, + { "editable": "true" } + ], + "transformers": [] + }, { "elementType": "button", "elementOptions": [ @@ -455,15 +465,6 @@ { "getStringKey": "Gen_Remove_Last" } ], "transformers": [] - }, - { - "elementType": "select", - "elementOptions": [ - { "multiple": "true" }, - { "readonly": "true" }, - { "editable": "true" } - ], - "transformers": [] } ] }, diff --git a/front/plugins/undiscoverables/config.json b/front/plugins/undiscoverables/config.json index 106e252a..a9be9fef 100755 --- a/front/plugins/undiscoverables/config.json +++ b/front/plugins/undiscoverables/config.json @@ -301,6 +301,16 @@ ], "transformers": [] }, + { + "elementType": "select", + "elementHasInputValue": 1, + "elementOptions": [ + { "multiple": "true" }, + { "readonly": "true" }, + { "editable": "true" } + ], + "transformers": [] + }, { "elementType": "button", "elementOptions": [ @@ -322,15 +332,6 @@ { "getStringKey": "Gen_Remove_Last" } ], "transformers": [] - }, - { - "elementType": "select", - "elementOptions": [ - { "multiple": "true" }, - { "readonly": "true" }, - { "editable": "true" } - ], - "transformers": [] } ] }, diff --git a/front/plugins/unifi_import/config.json b/front/plugins/unifi_import/config.json index 85d7763e..2336d062 100755 --- a/front/plugins/unifi_import/config.json +++ b/front/plugins/unifi_import/config.json @@ -271,6 +271,7 @@ }, { "column": "Watched_Value3", + "mapped_to_column": "cur_Type", "css_classes": "col-sm-2", "default_value": "", "localized": ["name"], @@ -776,6 +777,16 @@ ], "transformers": [] }, + { + "elementType": "select", + "elementHasInputValue": 1, + "elementOptions": [ + { "multiple": "true" }, + { "readonly": "true" }, + { "editable": "true" } + ], + "transformers": [] + }, { "elementType": "button", "elementOptions": [ @@ -797,15 +808,6 @@ { "getStringKey": "Gen_Remove_Last" } ], "transformers": [] - }, - { - "elementType": "select", - "elementOptions": [ - { "multiple": "true" }, - { "readonly": "true" }, - { "editable": "true" } - ], - "transformers": [] } ] } diff --git a/front/plugins/website_monitor/config.json b/front/plugins/website_monitor/config.json index f151bc10..23e7ea9f 100755 --- a/front/plugins/website_monitor/config.json +++ b/front/plugins/website_monitor/config.json @@ -624,6 +624,16 @@ ], "transformers": [] }, + { + "elementType": "select", + "elementHasInputValue": 1, + "elementOptions": [ + { "multiple": "true" }, + { "readonly": "true" }, + { "editable": "true" } + ], + "transformers": [] + }, { "elementType": "button", "elementOptions": [ @@ -645,15 +655,6 @@ { "getStringKey": "Gen_Remove_Last" } ], "transformers": [] - }, - { - "elementType": "select", - "elementOptions": [ - { "multiple": "true" }, - { "readonly": "true" }, - { "editable": "true" } - ], - "transformers": [] } ] }, diff --git a/front/settings.php b/front/settings.php index 7fbae9e4..12fbe9b2 100755 --- a/front/settings.php +++ b/front/settings.php @@ -219,7 +219,7 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX try { const isMetadata = codeName.includes('__metadata'); - // is this isn't a metadata entry, get corresponding metadata object from the dummy setting + // if this isn't a metadata entry, get corresponding metadata object from the dummy setting const setObj = isMetadata ? {} : JSON.parse(getSetting(`${codeName}__metadata`)); } catch (error) { @@ -459,6 +459,8 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX } // INPUT + + console.log(codeName); // Parse the setType JSON string into an object let inputHtml = ''; @@ -614,8 +616,7 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX clearCache() }, 1500); - } else - { + } else { var settingsArray = []; // collect values for each of the different input form controls @@ -628,12 +629,18 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX setType = set["Type"] setCodeName = set["Code_Name"] + console.log(prefix); + const setTypeObject = JSON.parse(setType.replace(/'/g, '"')); // console.log(setTypeObject); const dataType = setTypeObject.dataType; - const lastElementObj = setTypeObject.elements[setTypeObject.elements.length - 1]; - const { elementType, elementOptions = [], transformers = [] } = lastElementObj; + // const lastElementObj = setTypeObject.elements[setTypeObject.elements.length - 1]; //🔽 + + // get the element with the input value(s) + const elementsWithInputValue = setTypeObject.elements.filter(element => element.elementHasInputValue === 1); + + const { elementType, elementOptions = [], transformers = [] } = elementsWithInputValue; const { inputType, readOnly, @@ -714,13 +721,15 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX success: function(data, textStatus) { if(data == "OK") - { - showMessage (getString("settings_saved"), 5000, "modal_grey"); + { + // showMessage (getString("settings_saved"), 5000, "modal_grey"); // Remove navigation prompt "Are you sure you want to leave..." window.onbeforeunload = null; // Reloads the current page - setTimeout("clearCache()", 5000); + // setTimeout("clearCache()", 5000); + + clearCache() } else{ // something went wrong // write_notification(data, 'interrupt') @@ -746,7 +755,7 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX