Skip to content

Commit

Permalink
New screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Jan 22, 2023
1 parent 1f3e28f commit ecc4920
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 22 deletions.
61 changes: 51 additions & 10 deletions back/pialert.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import sys
import subprocess
import os
import tempfile
import re
import time
import decimal
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'])
Expand Down Expand Up @@ -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 = ''

failedAt = print_log ('SMTP try')

try:
if not SMTP_SKIP_TLS:
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)


#-------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified docs/img/device_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/img/maintenance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/img/network.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions front/css/pialert.css
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,9 @@ height: 50px;
margin: 10px;

}
#settingsPage .panel-heading:hover{
background-color: #272c30;
}

.settings-expand-icon {
font-size: medium;
Expand Down
23 changes: 22 additions & 1 deletion front/devices.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ function initializeDatatable () {
// Device Name
{targets: [mapIndx(0)],
'createdCell': function (td, cellData, rowData, row, col) {
$(td).html ('<b><a href="deviceDetails.php?mac='+ rowData[mapIndx(11)] +'" class="">'+ cellData +'</a></b>');
$(td).html ('<b class="anonymizeDev"><a href="deviceDetails.php?mac='+ rowData[mapIndx(11)] +'" class="">'+ cellData +'</a></b>');
} },

// Icon
Expand All @@ -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 ('<span class="anonymizeMac">'+cellData+'</span>');
} else {
$(td).html ('');
}
} },

// IP address
{targets: [mapIndx(12)],
'createdCell': function (td, cellData, rowData, row, col) {
if (!emptyArr.includes(cellData)){
$(td).html ('<span class="anonymizeIp">'+cellData+'</span>');
} else {
$(td).html ('');
}
} },

// Favorite
{targets: [mapIndx(4)],
'createdCell': function (td, cellData, rowData, row, col) {
Expand Down
4 changes: 2 additions & 2 deletions front/network.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,9 @@ function initTree(myHierarchy)
background-color:" +nodeData.data.color+";\
border-radius:5px;'\
>\
<div class='netNodeText'>\
<div class='netNodeText '>\
<strong>" + deviceIcon +
"<span class='spanNetworkTree'>"+nodeData.data.name+"</span>\
"<span class='spanNetworkTree anonymizeDev'>"+nodeData.data.name+"</span>\
</strong>"
+collapseExpandHtml+
"</div></div>";
Expand Down
6 changes: 4 additions & 2 deletions front/php/templates/language/en_us.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@
'REPORT_MAIL_name' => 'Enable email',
'REPORT_MAIL_description' => 'If enabled an email is sent out with a list of changes you\'ve subscribed to. Please also fill out all remaining settings related to the SMTP setup below.',
'SMTP_SERVER_name' => 'SMTP server URL',
'SMTP_SERVER_description' => 'The SMTP server host URL. For example <code>smtp-relay.sendinblue.com</code>.',
'SMTP_SERVER_description' => 'The SMTP server host URL. For example <code>smtp-relay.sendinblue.com</code>. I don\'t recommend using Gmail as an SMTP server as the setup is <a target="_blank" href="https://support.google.com/a/answer/176600">quite complex</a> (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 <code>0</code> 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',
Expand All @@ -526,6 +526,8 @@
'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',
Expand Down
8 changes: 3 additions & 5 deletions front/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

?>
<!-- Page ------------------------------------------------------------------ -->
<div class="content-wrapper">
<div id="settingsPage" class="content-wrapper">

<!-- Content header--------------------------------------------------------- -->
<section class="content-header">
Expand Down Expand Up @@ -285,7 +285,7 @@
<script>

// number of settings has to be equal to
var settingsNumber = 60;
var settingsNumber = 61;

// Wrong number of settings processing
if(<?php echo count($settings)?> != settingsNumber)
Expand Down Expand Up @@ -374,9 +374,7 @@ function saveSettings() {
method: "POST",
url: "../php/server/util.php",
data: { function: 'savesettings', settings: collectSettings() },
success: function(data, textStatus) {
// $("#result").html(data);
// console.log(data);
success: function(data, textStatus) {
showModalOk ('Result', data );
// Remove navigation prompt "Are you sure you want to leave..."
window.onbeforeunload = null;
Expand Down

0 comments on commit ecc4920

Please sign in to comment.