Browse Source

Apply functionality to dnsmasq log

pull/1235/head
billz 2 months ago
parent
commit
e422b4908e
  1. 8
      ajax/logging/clearlog.php
  2. 9
      app/js/custom.js
  3. 2
      installers/raspap.sudoers
  4. 5
      templates/dhcp/logging.php

8
ajax/logging/clearlog.php

@ -3,10 +3,10 @@
require_once '../../includes/config.php';
require_once '../../includes/functions.php';
if (isset($_POST['svc'])) {
$tmplog = '/tmp/' .$_POST['svc']. '.log';
if (isset($_POST['logfile'])) {
$logfile = $_POST['logfile'];
// clear log for requested service
exec("sudo truncate -s 0 $tmplog", $return);
// truncate requested log file
exec("sudo truncate -s 0 $logfile", $return);
echo json_encode($return);
}

9
app/js/custom.js

@ -123,12 +123,19 @@ $(document).on("click", "#gen_wpa_passphrase", function(e) {
});
$(document).on("click", "#js-clearhostapd-log", function(e) {
$.post('ajax/logging/clearlog.php?',{'svc':'hostapd'},function(data){
$.post('ajax/logging/clearlog.php?',{'logfile':'/tmp/hostapd.log'},function(data){
jsonData = JSON.parse(data);
$("#hostapd-log").val("");
});
});
$(document).on("click", "#js-cleardnsmasq-log", function(e) {
$.post('ajax/logging/clearlog.php?',{'logfile':'/var/log/dnsmasq.log'},function(data){
jsonData = JSON.parse(data);
$("#dnsmasq-log").val("");
});
});
// Enable Bootstrap tooltips
$(function () {
$('[data-toggle="tooltip"]').tooltip()

2
installers/raspap.sudoers

@ -63,4 +63,4 @@ www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wireguard/wg-*.key
www-data ALL=(ALL) NOPASSWD:/bin/rm /etc/wireguard/*.conf
www-data ALL=(ALL) NOPASSWD:/bin/rm /etc/wireguard/wg-*.key
www-data ALL=(ALL) NOPASSWD:/usr/sbin/netplan
www-data ALL=(ALL) NOPASSWD:/bin/truncate -s 0 /tmp/*.log
www-data ALL=(ALL) NOPASSWD:/bin/truncate -s 0 /tmp/*.log,/bin/truncate -s 0 /var/log/dnsmasq.log

5
templates/dhcp/logging.php

@ -9,7 +9,8 @@
</div>
<div class="custom-control custom-switch">
<input class="custom-control-input" id="log-queries" type="checkbox" name="log-queries" value="1" <?php echo $conf['log-queries'] ? ' checked="checked"' : "" ?> aria-describedby="log-dhcp-queries">
<label class="custom-control-label" for="log-queries"><?php echo _("Log DNS queries") ?></label>
<label class="custom-control-label align-middle" for="log-queries"><?php echo _("Log DNS queries") ?></label>
<input type="button" class="btn btn-outline btn-warning btn-sm align-top ml-4" id="js-cleardnsmasq-log" value="<?php echo _("Clear log"); ?>" />
</div>
<div class="row">
@ -18,7 +19,7 @@
if ($conf['log-dhcp'] == 1 || $conf['log-queries'] == 1) {
exec('sudo /bin/chmod o+r '.RASPI_DHCPCD_LOG);
$log = file_get_contents(RASPI_DHCPCD_LOG);
echo '<textarea class="logoutput">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>';
echo '<textarea class="logoutput" id="dnsmasq-log">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>';
} else {
echo '<textarea class="logoutput my-3"></textarea>';
}

Loading…
Cancel
Save