mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-10 12:12:10 -07:00
Compare commits
12 Commits
a0508f2db9
...
e776c3ac41
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e776c3ac41 | ||
|
|
81af82073e | ||
|
|
cddf4cf086 | ||
|
|
a4f3d8c60e | ||
|
|
a8a2dab4bc | ||
|
|
9b0c722922 | ||
|
|
8f9c3d2091 | ||
|
|
c5ef9645e6 | ||
|
|
04faef6dae | ||
|
|
825bff9ce7 | ||
|
|
eee84b23b8 | ||
|
|
a9a4d397dc |
@@ -30,13 +30,12 @@ IEEE_OUI_URL="http://standards-oui.ieee.org/oui/oui.txt"
|
||||
# Download the file using wget
|
||||
wget "$IEEE_OUI_URL" -O ieee-oui_dl.txt
|
||||
|
||||
# Filter lines containing "(base 16)" and remove the "(base 16)" string
|
||||
grep "(base 16)" ieee-oui_dl.txt | sed 's/ *(base 16)//' > ieee-oui_new.txt
|
||||
|
||||
# Combine ieee-oui_new.txt and ieee-oui.txt, and extract unique MAC start values along with vendor names
|
||||
# Filter lines containing "(base 16)" and format them with a tab between MAC and vendor
|
||||
grep "(base 16)" ieee-oui_dl.txt | sed -E 's/ *\(base 16\)//' | awk -F' ' '{printf "%s\t%s\n", $1, substr($0, index($0, $2))}' > ieee-oui_new.txt
|
||||
|
||||
# Combine, sort, and remove duplicates, ensuring tab-separated output
|
||||
cat ieee-oui.txt ieee-oui_new.txt >> ieee-oui_all.txt
|
||||
sort ieee-oui_all.txt > ieee-oui_all_sort.txt
|
||||
awk '{$1=$1; print}' ieee-oui_all_sort.txt | sort -u > ieee-oui_all_filtered.txt
|
||||
sort ieee-oui_all.txt | awk '{$1=$1; print}' | sort -u | awk -F' ' '{printf "%s\t%s\n", $1, substr($0, index($0, $2))}' > ieee-oui_all_filtered.txt
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,9 @@
|
||||
// Size and last mod of DB ------------------------------------------------------
|
||||
|
||||
$nax_db = str_replace('front', 'db', getcwd()).'/app.db';
|
||||
$nax_wal = str_replace('front', 'db', getcwd()).'/app.db-wal';
|
||||
$nax_db_size = number_format((filesize($nax_db) / 1000000),2,",",".") . ' MB';
|
||||
$nax_wal_size = number_format((filesize($nax_wal) / 1000000),2,",",".") . ' MB';
|
||||
$nax_db_mod = date ("F d Y H:i:s", filemtime($nax_db));
|
||||
|
||||
|
||||
@@ -104,13 +106,13 @@ $db->close();
|
||||
<div class="db_info_table_row">
|
||||
<div class="db_info_table_cell" style="min-width: 140px"><?= lang('Maintenance_database_path');?></div>
|
||||
<div class="db_info_table_cell">
|
||||
<?php echo $nax_db;?>
|
||||
<?php echo $nax_db;?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="db_info_table_row">
|
||||
<div class="db_info_table_cell"><?= lang('Maintenance_database_size');?></div>
|
||||
<div class="db_info_table_cell">
|
||||
<?php echo $nax_db_size;?>
|
||||
<?php echo $nax_db_size;?> (wal: <?php echo $nax_wal_size;?>)
|
||||
</div>
|
||||
</div>
|
||||
<div class="db_info_table_row">
|
||||
|
||||
2
front/php/templates/language/es_es.json
Normal file → Executable file
2
front/php/templates/language/es_es.json
Normal file → Executable file
@@ -790,7 +790,7 @@
|
||||
"settings_publishers_icon": "fa-solid fa-paper-plane",
|
||||
"settings_publishers_info": "Cargue más editor@s con el ajuste <a href=\"/settings.php#LOADED_PLUGINS\">LOADED_PLUGINS</a>",
|
||||
"settings_publishers_label": "Editores",
|
||||
"settings_readonly": "",
|
||||
"settings_readonly": "No se puede LEER ni ESCRIBIR <code>app.conf</code>. Intente reiniciar el contenedor y lea la <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/FILE_PERMISSIONS.md\" target=\"_blank\">documentación de permisos de archivo</a>",
|
||||
"settings_saved": "<br/>Ajustes guardados. <br/><br/> Recargando... <br/><i class=\"ion ion-ios-loop-strong fa-spin fa-2x fa-fw\"></i> <br/>",
|
||||
"settings_system_icon": "fa-solid fa-gear",
|
||||
"settings_system_label": "Sistema",
|
||||
|
||||
2
front/php/templates/language/fr_fr.json
Normal file → Executable file
2
front/php/templates/language/fr_fr.json
Normal file → Executable file
@@ -711,7 +711,7 @@
|
||||
"settings_publishers_icon": "fa-solid fa-paper-plane",
|
||||
"settings_publishers_info": "Charger plus de passerelles de publication avec le paramètre <a href=\"/settings.php#LOADED_PLUGINS\">LOADED_PLUGINS</a>",
|
||||
"settings_publishers_label": "Passerelles de publication",
|
||||
"settings_readonly": "",
|
||||
"settings_readonly": "Impossible de LIRE ou ÉCRIRE <code>app.conf</code>. Essayer de relancer le container et lire la <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/FILE_PERMISSIONS.md\" target=\"_blank\">documentation sur les droits des fichiers</a>",
|
||||
"settings_saved": "<br/>Paramètres enregistrés. <br/> Rechargement... <br/><i class=\"ion ion-ios-loop-strong fa-spin fa-2x fa-fw\"></i> <br/>",
|
||||
"settings_system_icon": "fa-solid fa-gear",
|
||||
"settings_system_label": "Système",
|
||||
|
||||
@@ -711,7 +711,7 @@
|
||||
"settings_publishers_icon": "fa-solid fa-paper-plane",
|
||||
"settings_publishers_info": "Carica più editori con l'impostazione <a href=\"/settings.php#LOADED_PLUGINS\">LOADED_PLUGINS</a>",
|
||||
"settings_publishers_label": "Editori",
|
||||
"settings_readonly": "",
|
||||
"settings_readonly": "Impossibile LEGGERE o SCRIVERE <code>app.conf</code>. Prova a riavviare il contenitore e leggi la <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/FILE_PERMISSIONS.md\" target=\"_blank\">documentazione sulle autorizzazioni dei file</a>",
|
||||
"settings_saved": "<br/>Impostazioni salvate. <br/> Aggiornamento in corso... <br/> <i class=\"ion ion-ios-loop-strong fa-spin fa-2x fa-fw\"></i> <br/>",
|
||||
"settings_system_icon": "fa-solid fa-gear",
|
||||
"settings_system_label": "Sistema",
|
||||
|
||||
@@ -60,7 +60,7 @@ def cleanup_database (dbPath, DAYS_TO_KEEP_EVENTS, PHOLUS_DAYS_DATA, HRS_TO_KEEP
|
||||
mylog('verbose', [f'[{pluginName}] Upkeep Database:' ])
|
||||
|
||||
# Connect to the App database
|
||||
conn = sqlite3.connect(dbPath)
|
||||
conn = sqlite3.connect(dbPath, timeout=30)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# -----------------------------------------------------
|
||||
@@ -149,7 +149,7 @@ def cleanup_database (dbPath, DAYS_TO_KEEP_EVENTS, PHOLUS_DAYS_DATA, HRS_TO_KEEP
|
||||
# Cleanup Offline Devices
|
||||
if HRS_TO_KEEP_OFFDEV != 0:
|
||||
mylog('verbose', [f'[{pluginName}] Devices: Delete all New Devices older than {str(HRS_TO_KEEP_OFFDEV)} hours (HRS_TO_KEEP_OFFDEV setting)'])
|
||||
query = f"""DELETE FROM Devices WHERE devPresentLastScan = 0 AND devLastConnection < date('now', '-{str(HRS_TO_KEEP_OFFDEV)} hour'))"""
|
||||
query = f"""DELETE FROM Devices WHERE devPresentLastScan = 0 AND devLastConnection < date('now', '-{str(HRS_TO_KEEP_OFFDEV)} hour')"""
|
||||
mylog('verbose', [f'[{pluginName}] Query: {query} '])
|
||||
cursor.execute (query)
|
||||
|
||||
@@ -204,13 +204,18 @@ def cleanup_database (dbPath, DAYS_TO_KEEP_EVENTS, PHOLUS_DAYS_DATA, HRS_TO_KEEP
|
||||
|
||||
conn.commit()
|
||||
|
||||
# Check WAL file size
|
||||
cursor.execute("PRAGMA wal_checkpoint(TRUNCATE);")
|
||||
cursor.execute("PRAGMA wal_checkpoint(FULL);")
|
||||
|
||||
mylog('verbose', [f'[{pluginName}] WAL checkpoint executed to truncate file.'])
|
||||
|
||||
# Shrink DB
|
||||
mylog('verbose', [f'[{pluginName}] Shrink Database'])
|
||||
cursor.execute ("VACUUM;")
|
||||
|
||||
# Close the database connection
|
||||
conn.close()
|
||||
|
||||
conn.close()
|
||||
|
||||
|
||||
#===============================================================================
|
||||
|
||||
@@ -44,7 +44,7 @@ def handleEmpty(input):
|
||||
return 'null'
|
||||
else:
|
||||
# Validate and sanitize message content
|
||||
# Remove potentially problematic characters if string
|
||||
# Remove potentially problematic characters in string
|
||||
if isinstance(input, str):
|
||||
input = re.sub(r'[^\x00-\x7F]+', ' ', input)
|
||||
input = input.replace('\n', '') # Removing new lines
|
||||
|
||||
@@ -182,7 +182,7 @@ def main ():
|
||||
mylog('verbose', ['[Notification] No changes to report'])
|
||||
|
||||
# Commit SQL
|
||||
db.commitDB()
|
||||
db.commitDB()
|
||||
|
||||
# Footer
|
||||
|
||||
@@ -198,11 +198,6 @@ def main ():
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# BEGIN
|
||||
#===============================================================================
|
||||
|
||||
@@ -317,7 +317,7 @@ def update_devices_data_from_scan (db):
|
||||
WHERE EXISTS (SELECT 1 FROM CurrentScan
|
||||
WHERE devMac = cur_MAC) """)
|
||||
|
||||
# Update only devices with empty or NULL vendors
|
||||
# Update only devices with empty, NULL or (u(U)nknown) vendors
|
||||
mylog('debug', '[Update Devices] - cur_Vendor -> (if empty) devVendor')
|
||||
sql.execute("""UPDATE Devices
|
||||
SET devVendor = (
|
||||
@@ -326,7 +326,7 @@ def update_devices_data_from_scan (db):
|
||||
WHERE Devices.devMac = CurrentScan.cur_MAC
|
||||
)
|
||||
WHERE
|
||||
(devVendor IS NULL OR devVendor IN ("", "null"))
|
||||
(devVendor IS NULL OR devVendor IN ("", "null", "(unknown)", "(Unknown)"))
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM CurrentScan
|
||||
@@ -439,8 +439,8 @@ def update_devices_data_from_scan (db):
|
||||
# Update VENDORS
|
||||
recordsToUpdate = []
|
||||
query = """SELECT * FROM Devices
|
||||
WHERE devVendor = '(unknown)' OR devVendor =''
|
||||
OR devVendor IS NULL"""
|
||||
WHERE devVendor IS NULL OR devVendor IN ("", "null", "(unknown)", "(Unknown)")
|
||||
"""
|
||||
|
||||
for device in sql.execute (query) :
|
||||
vendor = query_MAC_vendor (device['devMac'])
|
||||
@@ -469,8 +469,8 @@ def update_devices_data_from_scan (db):
|
||||
# Guess Type
|
||||
recordsToUpdate = []
|
||||
query = """SELECT * FROM Devices
|
||||
WHERE devType in ('', 'null')
|
||||
OR devType IS NULL"""
|
||||
WHERE devType in ('', 'null')
|
||||
OR devType IS NULL"""
|
||||
default_type = get_setting_value('NEWDEV_devType')
|
||||
|
||||
for device in sql.execute (query) :
|
||||
@@ -634,7 +634,7 @@ def query_MAC_vendor (pMAC):
|
||||
for line in f:
|
||||
line_lower = line.lower() # Convert line to lowercase for case-insensitive matching
|
||||
if line_lower.startswith(mac_start_string6):
|
||||
parts = line.split(' ', 1)
|
||||
parts = line.split('\t', 1)
|
||||
if len(parts) > 1:
|
||||
vendor = parts[1].strip()
|
||||
mylog('debug', [f"[Vendor Check] Found '{vendor}' for '{pMAC}' in {vendorsPath}"])
|
||||
|
||||
Reference in New Issue
Block a user