diff --git a/back/app.conf b/back/app.conf index aa70e378..818a5b6b 100755 --- a/back/app.conf +++ b/back/app.conf @@ -17,9 +17,10 @@ # Scan multiple interfaces (eth1 and eth0): # SCAN_SUBNETS = [ '192.168.1.0/24 --interface=eth1', '192.168.1.0/24 --interface=eth0' ] +DISCOVER_PLUGINS=True SCAN_SUBNETS=['192.168.1.0/24 --interface=eth0'] TIMEZONE='Europe/Berlin' -LOADED_PLUGINS = ['ARPSCAN','CSVBCKP','DBCLNP', 'INTRNT','MAINT','NEWDEV','NSLOOKUP','NTFPRCS', 'AVAHISCAN', 'SETPWD','SMTP', 'SYNC', 'VNDRPDT', 'WORKFLOWS'] +LOADED_PLUGINS = ['ARPSCAN','CSVBCKP','DBCLNP', 'INTRNT','MAINT','NEWDEV','NSLOOKUP','NTFPRCS', 'AVAHISCAN', 'SETPWD','SMTP', 'SYNC', 'VNDRPDT', 'WORKFLOWS', 'UI'] DAYS_TO_KEEP_EVENTS=90 # Used for generating links in emails. Make sure not to add a trailing slash! diff --git a/docker-compose.yml b/docker-compose.yml index 7e2dcc89..351e9c7f 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: # - ${APP_DATA_LOCATION}/netalertx_dev/db:/app/db - ${APP_DATA_LOCATION}/netalertx/db:/app/db # (optional) useful for debugging if you have issues setting up the container - # - ${LOGS_LOCATION}:/app/log + - ${DEV_LOCATION}/log:/app/log # --------------------------------------------------------------------------- # DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes - ${APP_DATA_LOCATION}/netalertx/dhcp_samples/dhcp1.leases:/mnt/dhcp1.leases diff --git a/docs/README.md b/docs/README.md index a7297587..0ea92771 100755 --- a/docs/README.md +++ b/docs/README.md @@ -29,6 +29,7 @@ There is also an in-app Help / FAQ section that should be answering frequently a - [Synology Guide](/docs/SYNOLOGY_GUIDE.md) - [Subnets and VLANs configuration for arp-scan](/docs/SUBNETS.md) +- [Scanning Remote Networks](/docs/REMOTE_NETWORKS.md) - [SMTP server config](/docs/SMTP.md) - [Custom Icon configuration and support](/docs/ICONS.md) - [Notifications](/docs/NOTIFICATIONS.md) @@ -56,7 +57,6 @@ There is also an in-app Help / FAQ section that should be answering frequently a - [Manage devices (legacy docs)](/docs/DEVICE_MANAGEMENT.md) - [Random MAC/MAC icon meaning (legacy docs)](/docs/RANDOM_MAC.md) - #### 🔎 Examples - [N8N webhook example](/docs/WEBHOOK_N8N.md) diff --git a/docs/REMOTE_NETWORKS.md b/docs/REMOTE_NETWORKS.md index b156aeaf..5fd96da4 100755 --- a/docs/REMOTE_NETWORKS.md +++ b/docs/REMOTE_NETWORKS.md @@ -2,6 +2,8 @@ By design, local network scanners such as `arp-scan` use ARP (Address Resolution Protocol) to map IP addresses to MAC addresses on the local network. Since ARP operates at Layer 2 (Data Link Layer), it typically works only within a single broadcast domain, usually limited to a single router or network segment. +To scan multiple locally accessible network segments, add them as subnets according to the [subnets](https://github.com/jokob-sk/NetAlertX/blob/main/docs/SUBNETS.md) documentation. + ## Complex Use Cases The following network setups might make some devices undetectable. Check the specific setup to understand the cause and find potential workarounds to still report on these devices. @@ -42,4 +44,6 @@ To create truly dummy devices, you can use a loopback IP address (e.g., `0.0.0.0 ## NMAP and Fake MAC Addresses -Scanning remote networks with NMAP is possible, but since it cannot retrieve the MAC address, you need to enable the `NMAPDEV_FAKE_MAC` setting. This will generate a fake MAC address based on the IP address, allowing you to track devices. However, this can lead to inconsistencies, especially if the IP address changes or a previously logged device is rediscovered. If this setting is disabled, only the IP address will be discovered, and devices with missing MAC addresses will be skipped. +Scanning remote networks with NMAP is possible (vai the `NMAPDEV` plugin), but since it cannot retrieve the MAC address, you need to enable the `NMAPDEV_FAKE_MAC` setting. This will generate a fake MAC address based on the IP address, allowing you to track devices. However, this can lead to inconsistencies, especially if the IP address changes or a previously logged device is rediscovered. If this setting is disabled, only the IP address will be discovered, and devices with missing MAC addresses will be skipped. + +Check the [NMAPDEV plugin](https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins/nmap_dev_scan) for details diff --git a/docs/SUBNETS.md b/docs/SUBNETS.md index afe32017..2a791fac 100755 --- a/docs/SUBNETS.md +++ b/docs/SUBNETS.md @@ -8,7 +8,7 @@ You need to specify the network interface and the network mask. You can also con In this example, `--interface=eth0 192.168.1.0/24` represents a neighboring subnet. If this command returns no results, the network is not accessible due to your network or firewall restrictions. -If direct scans are not possible (Wi-Fi Extenders, VPNs and inaccessible networks), check the remote [networks documentation](https://github.com/jokob-sk/NetAlertX/blob/main/front/plugins/REMOTE_NETWORKS.md). +If direct scans are not possible (Wi-Fi Extenders, VPNs and inaccessible networks), check the [remote networks documentation](https://github.com/jokob-sk/NetAlertX/blob/main/docs/REMOTE_NETWORKS.md). > [!TIP] > You may need to increase the time between scans `ARPSCAN_RUN_SCHD` and the timeout `ARPSCAN_RUN_TIMEOUT` (and similar settings for related plugins) when adding more subnets. If the timeout setting is exceeded, the scan is canceled to prevent the application from hanging due to rogue plugins. diff --git a/front/css/app.css b/front/css/app.css index e5575487..786d2f39 100755 --- a/front/css/app.css +++ b/front/css/app.css @@ -45,6 +45,7 @@ h5 .alignRight { text-align: end; + float: inline-end; } /* ----------------------------------------------------------------------------- diff --git a/front/php/templates/language/ar_ar.json b/front/php/templates/language/ar_ar.json index 7243a139..4ab8caa9 100755 --- a/front/php/templates/language/ar_ar.json +++ b/front/php/templates/language/ar_ar.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "", "DAYS_TO_KEEP_EVENTS_description": "", "DAYS_TO_KEEP_EVENTS_name": "", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": "", "DevDetail_Copy_Device_Tooltip": "", "DevDetail_DisplayFields_Title": "", diff --git a/front/php/templates/language/ca_ca.json b/front/php/templates/language/ca_ca.json index c1028ff6..ef06e962 100755 --- a/front/php/templates/language/ca_ca.json +++ b/front/php/templates/language/ca_ca.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "Netejar indicador de nou", "DAYS_TO_KEEP_EVENTS_description": "Això és una configuració de manteniment. Especifica el nombre de dies que es conservaran els esdeveniments. Els esdeveniments antics s'esborraran periòdicament. També aplica als esdeveniments dels Connectors (Plugins).", "DAYS_TO_KEEP_EVENTS_name": "Esborrar esdeveniments més vells de", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": " Copiar detalls des del dispositiu", "DevDetail_Copy_Device_Tooltip": "Copiar detalls del dispositius des de la llista desplegable. Tot el d'aquesta pàgina es sobre-escriurà", "DevDetail_DisplayFields_Title": "Pantalla", diff --git a/front/php/templates/language/cs_cz.json b/front/php/templates/language/cs_cz.json index 7243a139..4ab8caa9 100755 --- a/front/php/templates/language/cs_cz.json +++ b/front/php/templates/language/cs_cz.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "", "DAYS_TO_KEEP_EVENTS_description": "", "DAYS_TO_KEEP_EVENTS_name": "", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": "", "DevDetail_Copy_Device_Tooltip": "", "DevDetail_DisplayFields_Title": "", diff --git a/front/php/templates/language/de_de.json b/front/php/templates/language/de_de.json index 4dbd7452..9b4678d9 100755 --- a/front/php/templates/language/de_de.json +++ b/front/php/templates/language/de_de.json @@ -74,6 +74,8 @@ "CLEAR_NEW_FLAG_name": "Neues Flag löschen", "DAYS_TO_KEEP_EVENTS_description": "Dies ist eine Wartungseinstellung. Spezifiziert wie viele Tage Events gespeichert bleiben. Alle älteren Events werden periodisch gelöscht. Wird auch auf die Plugins History angewendet.", "DAYS_TO_KEEP_EVENTS_name": "Ereignisse löschen, die älter sind als", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": "Details von Gerät kopieren", "DevDetail_Copy_Device_Tooltip": "Details vom Gerät aus der Dropdown-Liste kopieren. Alles auf dieser Seite wird überschrieben", "DevDetail_DisplayFields_Title": "Anzeige", diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index dec26a7d..1a95db2e 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "Clear new flag", "DAYS_TO_KEEP_EVENTS_description": "This is a maintenance setting. This specifies the number of days worth of event entries that will be kept. All older events will be deleted periodically. Also applies on Plugin Events History.", "DAYS_TO_KEEP_EVENTS_name": "Delete events older than", + "DISCOVER_PLUGINS_description": "Disable this option to speed up initialization and settings saving. When disabled, plugins are not discovered, and you cannot add new plugins to the LOADED_PLUGINS setting.", + "DISCOVER_PLUGINS_name": "Discover plugins", "DevDetail_Copy_Device_Title": "Copy details from device", "DevDetail_Copy_Device_Tooltip": "Copy details from device from the dropdown list. Everything on this page will be overwritten", "DevDetail_DisplayFields_Title": "Display", diff --git a/front/php/templates/language/es_es.json b/front/php/templates/language/es_es.json index 083dc475..80b5a05c 100755 --- a/front/php/templates/language/es_es.json +++ b/front/php/templates/language/es_es.json @@ -72,6 +72,8 @@ "CLEAR_NEW_FLAG_name": "Eliminar la nueva bandera", "DAYS_TO_KEEP_EVENTS_description": "Esta es una configuración de mantenimiento. Esto especifica el número de días de entradas de eventos que se guardarán. Todos los eventos anteriores se eliminarán periódicamente.", "DAYS_TO_KEEP_EVENTS_name": "Eliminar eventos anteriores a", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": "Copiar detalles del dispositivo", "DevDetail_Copy_Device_Tooltip": "Copiar detalles del dispositivo de la lista desplegable. Todo en esta página se sobrescribirá", "DevDetail_DisplayFields_Title": "Mostrar", @@ -812,4 +814,4 @@ "settings_update_item_warning": "Actualice el valor a continuación. Tenga cuidado de seguir el formato anterior. O la validación no se realiza.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Guarda tus cambios antes de probar nuevos ajustes." -} +} \ No newline at end of file diff --git a/front/php/templates/language/fr_fr.json b/front/php/templates/language/fr_fr.json index 954f3350..6dad444b 100755 --- a/front/php/templates/language/fr_fr.json +++ b/front/php/templates/language/fr_fr.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "Supprime le nouveau drapeau", "DAYS_TO_KEEP_EVENTS_description": "Il s'agit d'un paramètre de maintenance. Il indique le nombre de jours pendant lesquels les entrées d'événements seront conservées. Tous les événements plus anciens seront supprimés périodiquement. S'applique également à l'historique des événements du plugin.", "DAYS_TO_KEEP_EVENTS_name": "Supprimer les événements plus anciens que", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": "Copier les détails de l'appareil", "DevDetail_Copy_Device_Tooltip": "Copier les détails de l'appareil dans la liste déroulante. Tout ce qui se trouve sur cette page sera remplacé", "DevDetail_DisplayFields_Title": "Afficher", @@ -733,4 +735,4 @@ "settings_update_item_warning": "Mettre à jour la valeur ci-dessous. Veillez à bien suivre le même format qu'auparavant. Il n'y a pas de pas de contrôle.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Enregistrer d'abord vos modifications avant de tester vôtre paramétrage." -} +} \ No newline at end of file diff --git a/front/php/templates/language/it_it.json b/front/php/templates/language/it_it.json old mode 100644 new mode 100755 index c3a4f455..4a5cde9a --- a/front/php/templates/language/it_it.json +++ b/front/php/templates/language/it_it.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "Cancella nuova bandiera", "DAYS_TO_KEEP_EVENTS_description": "Questa è un'impostazione di manutenzione. Specifica il numero di giorni delle voci degli eventi che verranno conservati. Tutti gli eventi più vecchi verranno eliminati periodicamente. Si applica anche alla cronologia degli eventi del plugin (Plugin Events History).", "DAYS_TO_KEEP_EVENTS_name": "Elimina eventi più vecchi di", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": "Copia dettagli dal dispositivo", "DevDetail_Copy_Device_Tooltip": "Copia i dettagli dal dispositivo dall'elenco a discesa. Tutto in questa pagina verrà sovrascritto", "DevDetail_DisplayFields_Title": "Visualizza", @@ -733,4 +735,4 @@ "settings_update_item_warning": "Aggiorna il valore qui sotto. Fai attenzione a seguire il formato precedente. La convalida non viene eseguita.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Salva le modifiche prima di provare le nuove impostazioni." -} +} \ No newline at end of file diff --git a/front/php/templates/language/nb_no.json b/front/php/templates/language/nb_no.json index cf581519..c59df956 100755 --- a/front/php/templates/language/nb_no.json +++ b/front/php/templates/language/nb_no.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "", "DAYS_TO_KEEP_EVENTS_description": "Dette er en vedlikeholdsinnstilling. Dette spesifiserer antall dager verdt med hendelsesoppføringer som vil beholdes. Alle eldre hendelser vil bli slettet med jevne mellomrom. Gjelder også for plugin-hendelseshistorikk.", "DAYS_TO_KEEP_EVENTS_name": "Slett hendelser eldre enn", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": " Kopier detaljer fra enhet", "DevDetail_Copy_Device_Tooltip": "Kopier detaljer fra enheten via nedtrekks menyen. Alt på denne siden vil bli overskrevet", "DevDetail_DisplayFields_Title": "", diff --git a/front/php/templates/language/pl_pl.json b/front/php/templates/language/pl_pl.json index bd6f7d55..fe1e81c0 100755 --- a/front/php/templates/language/pl_pl.json +++ b/front/php/templates/language/pl_pl.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "", "DAYS_TO_KEEP_EVENTS_description": "To jest ustawienie konserwacji. Określa ile dni mają być utrzymywane wpisy wydarzeń. Wszystkie starsze wpisy wydarzeń zostaną usunięte okresowo. Dotyczy także Historii Wydarzeń Pluginów.", "DAYS_TO_KEEP_EVENTS_name": "Usuń wydarzenia starsze niż", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": "Kopiuj opis z urządzenia", "DevDetail_Copy_Device_Tooltip": "Kopiuj opis z urządzenia z listy rozwijanej. Wszystko na tej stronie zostanie nadpisane", "DevDetail_DisplayFields_Title": "", diff --git a/front/php/templates/language/pt_br.json b/front/php/templates/language/pt_br.json index 4b40e494..d5217248 100755 --- a/front/php/templates/language/pt_br.json +++ b/front/php/templates/language/pt_br.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "", "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", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": " Copiar detalhes do dispositivo", "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_DisplayFields_Title": "", diff --git a/front/php/templates/language/ru_ru.json b/front/php/templates/language/ru_ru.json index 4d1bc970..f7e366df 100755 --- a/front/php/templates/language/ru_ru.json +++ b/front/php/templates/language/ru_ru.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "Удалить новый флаг", "DAYS_TO_KEEP_EVENTS_description": "Это настройка обслуживания. Здесь указывается количество дней, в течение которых будут храниться записи о событиях. Все старые события будут периодически удаляться. Также применимо к истории событий плагина.", "DAYS_TO_KEEP_EVENTS_name": "Удалить события старше", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": "Скопировать данные с устройства", "DevDetail_Copy_Device_Tooltip": "Скопируйте данные с устройства из раскрывающегося списка. Все на этой странице будет перезаписано", "DevDetail_DisplayFields_Title": "Дисплей", diff --git a/front/php/templates/language/tr_tr.json b/front/php/templates/language/tr_tr.json index 3fb6327d..7af90066 100755 --- a/front/php/templates/language/tr_tr.json +++ b/front/php/templates/language/tr_tr.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "", "DAYS_TO_KEEP_EVENTS_description": "", "DAYS_TO_KEEP_EVENTS_name": "", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": "", "DevDetail_Copy_Device_Tooltip": "", "DevDetail_DisplayFields_Title": "", diff --git a/front/php/templates/language/uk_ua.json b/front/php/templates/language/uk_ua.json index 1f767ba8..45a29097 100755 --- a/front/php/templates/language/uk_ua.json +++ b/front/php/templates/language/uk_ua.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "Очистити новий прапор", "DAYS_TO_KEEP_EVENTS_description": "Це налаштування обслуговування. Це визначає кількість днів записів про події, які зберігатимуться. Усі старіші події періодично видалятимуться. Також застосовується до історії подій плагінів.", "DAYS_TO_KEEP_EVENTS_name": "Видалити події, старші за", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": "Скопіюйте деталі з пристрою", "DevDetail_Copy_Device_Tooltip": "Скопіюйте деталі пристрою зі спадного списку. Усе на цій сторінці буде перезаписано", "DevDetail_DisplayFields_Title": "Дисплей", @@ -733,4 +735,4 @@ "settings_update_item_warning": "Оновіть значення нижче. Слідкуйте за попереднім форматом. Перевірка не виконана.", "test_event_icon": "fa-vial-circle- check", "test_event_tooltip": "Перш ніж перевіряти налаштування, збережіть зміни." -} +} \ No newline at end of file diff --git a/front/php/templates/language/zh_cn.json b/front/php/templates/language/zh_cn.json index 0d32f8c3..beaaaaad 100755 --- a/front/php/templates/language/zh_cn.json +++ b/front/php/templates/language/zh_cn.json @@ -62,6 +62,8 @@ "CLEAR_NEW_FLAG_name": "", "DAYS_TO_KEEP_EVENTS_description": "这是维护设置。它指定将保留的事件条目的天数。所有较旧的事件将被定期删除。也适用于插件事件历史记录。", "DAYS_TO_KEEP_EVENTS_name": "删除早于", + "DISCOVER_PLUGINS_description": "", + "DISCOVER_PLUGINS_name": "", "DevDetail_Copy_Device_Title": " 从设备复制详细信息", "DevDetail_Copy_Device_Tooltip": "从下拉列表中复制设备的详细信息。此页面上的所有内容都将被覆盖", "DevDetail_DisplayFields_Title": "", diff --git a/front/plugins/nmap_dev_scan/README.md b/front/plugins/nmap_dev_scan/README.md index 322eb346..b83dcbb0 100755 --- a/front/plugins/nmap_dev_scan/README.md +++ b/front/plugins/nmap_dev_scan/README.md @@ -11,6 +11,7 @@ NMAP-scan is a command-line tool to discover and fingerprint IP hosts on the loc - Enable the plugin by changing the RUN parameter from disabled to your preferred run time (usually: `schedule`). - Specify the schedule in the `NMAPDEV_RUN_SCHD` setting - Adjust the timeout if needed in the `NMAPDEV_RUN_TIMEOUT` setting +- If scanning remote networks you may want to enable the `NMAPDEV_FAKE_MAC` setting. Please read the setting description carefully. - Review remaining settings - SAVE - Wait for the next scan to finish diff --git a/front/plugins/sync/sync.py b/front/plugins/sync/sync.py index 62ab6247..fab78a16 100755 --- a/front/plugins/sync/sync.py +++ b/front/plugins/sync/sync.py @@ -72,7 +72,7 @@ def main(): # PUSHING/SENDING Plugins # Get all plugin configurations - all_plugins = get_plugins_configs() + all_plugins = get_plugins_configs(False) mylog('verbose', [f'[{pluginName}] plugins_to_sync {plugins_to_sync}']) diff --git a/server/api.py b/server/api.py index 8a71f955..764fdb99 100755 --- a/server/api.py +++ b/server/api.py @@ -169,7 +169,7 @@ def periodic_write(interval=1): while not stop_event.is_set(): with api_lock: for endpoint in apiEndpoints: - endpoint.try_write() # Attempt to write each endpoint if necessary + endpoint.try_write(False) # Attempt to write each endpoint if necessary time.sleep(interval) diff --git a/server/initialise.py b/server/initialise.py index f93bc8d6..29a244a1 100755 --- a/server/initialise.py +++ b/server/initialise.py @@ -9,7 +9,7 @@ import json import shutil import re - +# Register NetAlertX libraries import conf from const import fullConfPath, applicationPath, fullConfFolder from helper import fixPermissions, collect_lang_strings, updateSubnets, initOrSetParam, isJsonObject, updateState, setting_value_to_python_type, timeNowTZ, get_setting_value, generate_random_string @@ -17,7 +17,7 @@ from logger import mylog from api import update_api from scheduler import schedule_class from plugin import print_plugin_info, run_plugin_scripts -from plugin_utils import get_plugins_configs, get_plugin_setting_obj, get_set_value_for_init +from plugin_utils import get_plugins_configs, get_set_value_for_init from notification import write_notification #=============================================================================== @@ -156,7 +156,8 @@ def importConfigs (db, all_plugins): # ccd(key, default, config_dir, name, inputtype, options, group, events=[], desc = "", regex = "", setJsonMetadata = {}, overrideTemplate = {}) conf.LOADED_PLUGINS = ccd('LOADED_PLUGINS', [] , c_d, 'Loaded plugins', '{"dataType":"array", "elements": [{"elementType" : "select", "elementOptions" : [{"multiple":"true", "ordeable": "true"}] ,"transformers": []}]}', '[]', 'General') - conf.SCAN_SUBNETS = ccd('SCAN_SUBNETS', ['192.168.1.0/24 --interface=eth1', '192.168.1.0/24 --interface=eth0'] , c_d, 'Subnets to scan', '{"dataType": "array","elements": [{"elementType": "input","elementOptions": [{"placeholder": "192.168.1.0/24 --interface=eth1"},{"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": "select","elementHasInputValue": 1,"elementOptions": [{"multiple": "true"},{"readonly": "true"},{"editable": "true"}],"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": []}]}', '[]', 'General') + conf.DISCOVER_PLUGINS = ccd('DISCOVER_PLUGINS', True , c_d, 'Discover plugins', """{"dataType": "boolean","elements": [{"elementType": "input","elementOptions": [{ "type": "checkbox" }],"transformers": []}]}""", '[]', 'General') + conf.SCAN_SUBNETS = ccd('SCAN_SUBNETS', ['192.168.1.0/24 --interface=eth1', '192.168.1.0/24 --interface=eth0'] , c_d, 'Subnets to scan', '''{"dataType": "array","elements": [{"elementType": "input","elementOptions": [{"placeholder": "192.168.1.0/24 --interface=eth1"},{"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": "select","elementHasInputValue": 1,"elementOptions": [{"multiple": "true"},{"readonly": "true"},{"editable": "true"}],"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": []}]}''', '[]', 'General') conf.LOG_LEVEL = ccd('LOG_LEVEL', 'verbose' , c_d, 'Log verboseness', '{"dataType":"string", "elements": [{"elementType" : "select", "elementOptions" : [] ,"transformers": []}]}', "['none', 'minimal', 'verbose', 'debug', 'trace']", 'General') conf.TIMEZONE = ccd('TIMEZONE', 'Europe/Berlin' , c_d, 'Time zone', '{"dataType":"string", "elements": [{"elementType" : "input", "elementOptions" : [] ,"transformers": []}]}', '[]', 'General') conf.PLUGINS_KEEP_HIST = ccd('PLUGINS_KEEP_HIST', 250 , c_d, 'Keep history entries', '{"dataType":"integer", "elements": [{"elementType" : "input", "elementOptions" : [{"type": "number"}] ,"transformers": []}]}', '[]', 'General') @@ -200,7 +201,12 @@ def importConfigs (db, all_plugins): # Plugins START # ----------------- - all_plugins = get_plugins_configs() + + necessary_plugins = ['UI', 'DBCLNP', 'INTRNT','MAINT','NEWDEV', 'SETPWD', 'SYNC', 'VNDRPDT', 'WORKFLOWS'] + # make sure necessary plugins are loaded + conf.LOADED_PLUGINS += [plugin for plugin in necessary_plugins if plugin not in conf.LOADED_PLUGINS] + + all_plugins = get_plugins_configs(conf.DISCOVER_PLUGINS) mylog('none', ['[Config] Plugins: Number of all plugins (including not loaded): ', len(all_plugins)]) @@ -213,24 +219,25 @@ def importConfigs (db, all_plugins): for plugin in all_plugins: # Header on the frontend and the app_state.json - updateState(f"Check plugin {index} of {len(all_plugins)}") + updateState(f"Check plugin ({index}/{len(all_plugins)})") index +=1 - pref = plugin["unique_prefix"] - print_plugin_info(plugin, ['display_name','description']) + pref = plugin["unique_prefix"] all_plugins_prefixes.append(pref) # The below lines are used to determine if the plugin should be loaded, or skipped based on user settings (conf.LOADED_PLUGINS) # ...or based on if is already enabled, or if the default configuration loads the plugin (RUN function != disabled ) - # get default plugin run value + # get run value (computationally expensive) plugin_run = get_set_value_for_init(plugin, c_d, "RUN") # only include loaded plugins, and the ones that are enabled if pref in conf.LOADED_PLUGINS or plugin_run != 'disabled' or plugin_run is None: + print_plugin_info(plugin, ['display_name','description']) + stringSqlParams = [] # collect plugin level language strings diff --git a/server/plugin.py b/server/plugin.py index 1fc9d3ac..b517a777 100755 --- a/server/plugin.py +++ b/server/plugin.py @@ -118,6 +118,9 @@ def run_plugin_scripts(db, all_plugins, runType, pluginsState = plugins_state()) prefix = plugin["unique_prefix"] set = get_plugin_setting_obj(plugin, "RUN") + + # mylog('debug', [f'[run_plugin_scripts] plugin: {plugin}']) + # mylog('debug', [f'[run_plugin_scripts] set: {set}']) if set != None and set['value'] == runType: if runType != "schedule": shouldRun = True diff --git a/server/plugin_utils.py b/server/plugin_utils.py index 864e0b41..1fb335db 100755 --- a/server/plugin_utils.py +++ b/server/plugin_utils.py @@ -181,7 +181,7 @@ def get_layer(plugin): return int(order.split('_')[1]) #------------------------------------------------------------------------------- -def get_plugins_configs(): +def get_plugins_configs(loadAll): pluginsList = [] # Create an empty list to store plugin configurations pluginsListSorted = [] # Sorted by "execution_order" : "Layer_0" first, Layer_N last @@ -200,9 +200,14 @@ def get_plugins_configs(): if not os.path.isfile(ignore_plugin_path): # Construct the path to the config.json file within the plugin folder config_path = os.path.join(pluginsPath, d, "config.json") + + plugJson = json.loads(get_file_content(config_path)) + + # only laod plugin if needed + if loadAll or plugJson["unique_prefix"] in conf.LOADED_PLUGINS: - # Load the contents of the config.json file as a JSON object and append it to pluginsList - pluginsList.append(json.loads(get_file_content(config_path))) + # Load the contents of the config.json file as a JSON object and append it to pluginsList + pluginsList.append(plugJson) # Sort pluginsList based on "execution_order" pluginsListSorted = sorted(pluginsList, key=get_layer)