diff --git a/back/pialert.py b/back/pialert.py index db1334b6..3d094186 100755 --- a/back/pialert.py +++ b/back/pialert.py @@ -20,6 +20,7 @@ from email.mime.text import MIMEText import sys import subprocess import os +import tempfile import re import time import decimal @@ -112,6 +113,8 @@ def print_log (pText): # Save current time to calculate elapsed time until next log log_timestamp = log_timestamp2 + + return pText #------------------------------------------------------------------------------- # check RW access of DB and config file @@ -255,7 +258,7 @@ def importConfig (): # General global ENABLE_ARPSCAN, SCAN_SUBNETS, PRINT_LOG, TIMEZONE, PIALERT_WEB_PROTECTION, PIALERT_WEB_PASSWORD, INCLUDED_SECTIONS, SCAN_CYCLE_MINUTES, DAYS_TO_KEEP_EVENTS, REPORT_DASHBOARD_URL, DIG_GET_IP_ARG # Email - global REPORT_MAIL, SMTP_SERVER, SMTP_PORT, REPORT_TO, REPORT_FROM, SMTP_SKIP_LOGIN, SMTP_USER, SMTP_PASS, SMTP_SKIP_TLS + global REPORT_MAIL, SMTP_SERVER, SMTP_PORT, REPORT_TO, REPORT_FROM, SMTP_SKIP_LOGIN, SMTP_USER, SMTP_PASS, SMTP_SKIP_TLS, SMTP_FORCE_SSL # Webhooks global REPORT_WEBHOOK, WEBHOOK_URL, WEBHOOK_PAYLOAD, WEBHOOK_REQUEST_METHOD # Apprise @@ -312,6 +315,7 @@ def importConfig (): SMTP_USER = ccd('SMTP_USER', '' , c_d, 'SMTP user', 'text', '', 'Email') SMTP_PASS = ccd('SMTP_PASS', '' , c_d, 'SMTP password', 'password', '', 'Email') SMTP_SKIP_TLS = ccd('SMTP_SKIP_TLS', False , c_d, 'SMTP skip TLS', 'boolean', '', 'Email') + SMTP_FORCE_SSL = ccd('SMTP_FORCE_SSL', False , c_d, 'Force SSL', 'boolean', '', 'Email') # Webhooks REPORT_WEBHOOK = ccd('REPORT_WEBHOOK', False , c_d, 'Enable Webhooks', 'boolean', '', 'Webhooks', ['test']) @@ -2383,21 +2387,58 @@ def send_email (pText, pHTML): msg.attach (MIMEText (pText, 'plain')) msg.attach (MIMEText (pHTML, 'html')) - # Send mail - smtp_connection = smtplib.SMTP (SMTP_SERVER, SMTP_PORT) - smtp_connection.ehlo() + failedAt = '' - try: - if not SMTP_SKIP_TLS: + failedAt = print_log ('SMTP try') + + try: + # Send mail + failedAt = print_log('Trying to open connection to ' + str(SMTP_SERVER) + ':' + str(SMTP_PORT)) + + if SMTP_FORCE_SSL: + failedAt = print_log('SMTP_FORCE_SSL == True so using .SMTP_SSL()') + if SMTP_PORT == 0: + failedAt = print_log('SMTP_PORT == 0 so sending .SMTP_SSL(SMTP_SERVER)') + smtp_connection = smtplib.SMTP_SSL(SMTP_SERVER) + else: + failedAt = print_log('SMTP_PORT == 0 so sending .SMTP_SSL(SMTP_SERVER, SMTP_PORT)') + smtp_connection = smtplib.SMTP_SSL(SMTP_SERVER, SMTP_PORT) + + else: + failedAt = print_log('SMTP_FORCE_SSL == False so using .SMTP()') + if SMTP_PORT == 0: + failedAt = print_log('SMTP_PORT == 0 so sending .SMTP(SMTP_SERVER)') + smtp_connection = smtplib.SMTP (SMTP_SERVER) + else: + failedAt = print_log('SMTP_PORT == 0 so sending .SMTP(SMTP_SERVER, SMTP_PORT)') + smtp_connection = smtplib.SMTP (SMTP_SERVER, SMTP_PORT) + + failedAt = print_log('Setting SMTP debug level') + smtp_connection.set_debuglevel(1) + + failedAt = print_log( 'Sending .ehlo()') + smtp_connection.ehlo() + + if not SMTP_SKIP_TLS: + failedAt = print_log('SMTP_SKIP_TLS == False so sending .starttls()') smtp_connection.starttls() + failedAt = print_log('SMTP_SKIP_TLS == False so sending .ehlo()') smtp_connection.ehlo() if not SMTP_SKIP_LOGIN: + failedAt = print_log('SMTP_SKIP_LOGIN == False so sending .login()') smtp_connection.login (SMTP_USER, SMTP_PASS) - - smtp_connection.sendmail (REPORT_FROM, REPORT_TO, msg.as_string()) - smtp_connection.quit() + + failedAt = print_log('Sending .sendmail()') + smtp_connection.sendmail (REPORT_FROM, REPORT_TO, msg.as_string()) + smtp_connection.quit() except smtplib.SMTPAuthenticationError as e: - file_print(' ERROR: Couldn\'t connect to the SMTP server, skipping Email') + file_print(' ERROR: Failed at - ', failedAt) + file_print(' ERROR: Couldn\'t connect to the SMTP server (SMTPAuthenticationError), skipping Email (enable PRINT_LOG for more logging)') + except smtplib.SMTPServerDisconnected as e: + file_print(' ERROR: Failed at - ', failedAt) + file_print(' ERROR: Couldn\'t connect to the SMTP server (SMTPServerDisconnected), skipping Email (enable PRINT_LOG for more logging)') + + file_print(' DEBUG: Last executed - ', failedAt) #------------------------------------------------------------------------------- diff --git a/docker-compose.yml b/docker-compose.yml index 832f78c2..3762730c 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,9 +13,9 @@ services: # (optional) map an empty file with the name 'setting_darkmode' if you want to force the dark mode on container rebuilt - ${APP_DATA_LOCATION}/pialert/db/setting_darkmode:/home/pi/pialert/db/setting_darkmode # (optional) useful for debugging if you have issues setting up the container - - ${LOGS_LOCATION}:/home/pi/pialert/front/log + - ${LOGS_LOCATION}:/home/pi/pialert/front/log # DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes - - ${DEV_LOCATION}/back/pialert.py:/home/pi/pialert/back/pialert.py + - ${DEV_LOCATION}/back/pialert.py:/home/pi/pialert/back/pialert.py - ${DEV_LOCATION}/back/update_vendors.sh:/home/pi/pialert/back/update_vendors.sh - ${DEV_LOCATION}/back/report_template_new_version.html:/home/pi/pialert/back/report_template_new_version.html - ${DEV_LOCATION}/pholus:/home/pi/pialert/pholus diff --git a/docs/img/device_details.png b/docs/img/device_details.png index 2f13a37b..e7b7e8eb 100755 Binary files a/docs/img/device_details.png and b/docs/img/device_details.png differ diff --git a/docs/img/maintenance.png b/docs/img/maintenance.png index 752a10a5..6f08b101 100755 Binary files a/docs/img/maintenance.png and b/docs/img/maintenance.png differ diff --git a/docs/img/network.png b/docs/img/network.png index 859cd040..f480e35b 100755 Binary files a/docs/img/network.png and b/docs/img/network.png differ diff --git a/front/css/pialert.css b/front/css/pialert.css index a7127ca0..30b345ee 100755 --- a/front/css/pialert.css +++ b/front/css/pialert.css @@ -691,6 +691,9 @@ height: 50px; margin: 10px; } +#settingsPage .panel-heading:hover{ + background-color: #272c30; +} .settings-expand-icon { font-size: medium; diff --git a/front/devices.php b/front/devices.php index c3d695e2..f640f968 100755 --- a/front/devices.php +++ b/front/devices.php @@ -337,7 +337,7 @@ function initializeDatatable () { // Device Name {targets: [mapIndx(0)], 'createdCell': function (td, cellData, rowData, row, col) { - $(td).html (''+ cellData +''); + $(td).html (''+ cellData +''); } }, // Icon @@ -349,6 +349,27 @@ function initializeDatatable () { $(td).html (''); } } }, + + // Full MAC + {targets: [mapIndx(11)], + 'createdCell': function (td, cellData, rowData, row, col) { + if (!emptyArr.includes(cellData)){ + $(td).html (''+cellData+''); + } else { + $(td).html (''); + } + } }, + + // IP address + {targets: [mapIndx(12)], + 'createdCell': function (td, cellData, rowData, row, col) { + if (!emptyArr.includes(cellData)){ + $(td).html (''+cellData+''); + } else { + $(td).html (''); + } + } }, + // Favorite {targets: [mapIndx(4)], 'createdCell': function (td, cellData, rowData, row, col) { diff --git a/front/network.php b/front/network.php index d2ee61c6..f5bb5bff 100755 --- a/front/network.php +++ b/front/network.php @@ -602,9 +602,9 @@ background-color:" +nodeData.data.color+";\ border-radius:5px;'\ >\ -
smtp-relay.sendinblue.com.',
+'SMTP_SERVER_description' => 'The SMTP server host URL. For example smtp-relay.sendinblue.com. I don\'t recommend using Gmail as an SMTP server as the setup is quite complex (I couldn\'t get it to work - Please reach out with a guide if you did)',
'SMTP_PORT_name' => 'SMTP server PORT',
-'SMTP_PORT_description' => 'Port number used for the SMTP connection.',
+'SMTP_PORT_description' => 'Port number used for the SMTP connection. Set to 0 if you don\'t want to use a port when connecting to the SMTP server.',
'SMTP_SKIP_LOGIN_name' => 'Skip authentication',
'SMTP_SKIP_LOGIN_description' => 'Don\'t use authentication when connecting to the SMTP server.',
'SMTP_USER_name' => 'SMTP user',
@@ -526,6 +526,8 @@ the arp-scan will take hours to complete instead of seconds.
'SMTP_PASS_description' => 'The SMTP server password. ',
'SMTP_SKIP_TLS_name' => 'Don\'t use TLS',
'SMTP_SKIP_TLS_description' => 'Disable TLS when connecting to your SMTP server.',
+'SMTP_FORCE_SSL_name' => 'Force SSL',
+'SMTP_FORCE_SSL_description' => 'Force SSL when connecting to your SMTP server.',
'REPORT_TO_name' => 'Send email to',
'REPORT_TO_description' => 'Email address to which the notification will be send to.',
'REPORT_FROM_name' => 'Email subject',
diff --git a/front/settings.php b/front/settings.php
index 88df7100..48e432b2 100755
--- a/front/settings.php
+++ b/front/settings.php
@@ -43,7 +43,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
?>
-