Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add settings for privacy level #713

Merged
merged 5 commits into from Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions scripts/pi-hole/js/index.js
Expand Up @@ -294,6 +294,13 @@ function updateClientsOverTime() {

// convert received objects to arrays
data.over_time = objectToArray(data.over_time);

// Remove graph if there are no results (e.g. privacy mode enabled)
if(jQuery.isEmptyObject(data.over_time))
{
$("#clients").parent().remove();
return;
}
// remove last data point since it not representative
data.over_time[0].splice(-1,1);
var timestamps = data.over_time[0];
Expand Down Expand Up @@ -488,6 +495,13 @@ function updateTopClientsChart() {

}

// Remove table if there are no results (e.g. privacy mode enabled)
if(jQuery.isEmptyObject(data.top_sources))
{
$("#client-frequency").parent().remove();
return;
}

$("#client-frequency .overlay").hide();
// Update top clients list data every ten seconds
setTimeout(updateTopClientsChart, 10000);
Expand Down Expand Up @@ -529,6 +543,7 @@ function updateTopLists() {
if(jQuery.isEmptyObject(data.top_queries))
{
$("#domain-frequency").parent().remove();
return;
}

for (domain in data.top_ads) {
Expand All @@ -552,6 +567,7 @@ function updateTopLists() {
if(jQuery.isEmptyObject(data.top_ads))
{
$("#ad-frequency").parent().remove();
return;
}

$("#domain-frequency .overlay").hide();
Expand Down
14 changes: 13 additions & 1 deletion scripts/pi-hole/php/savesettings.php
Expand Up @@ -256,7 +256,7 @@ function readAdlists()
$extra .= " conditional_forwarding ".$_POST["conditionalForwardingIP"]." ".$_POST["conditionalForwardingDomain"]." $reverseAddress";
}
}

// Check if DNSinterface is set
if(isset($_POST["DNSinterface"]))
{
Expand Down Expand Up @@ -635,7 +635,19 @@ function readAdlists()

// Reread available adlists
$adlist = readAdlists();
break;

case "privacyLevel":
$level = intval($_POST["privacylevel"]);
if($level >= 0 && $level <= 3)
{
exec("sudo pihole -a privacylevel ".$level);
$success .= "The privacy level has been updated";
}
else
{
$error .= "Invalid privacy level (".$level.")!";
}
break;

default:
Expand Down
71 changes: 69 additions & 2 deletions settings.php
Expand Up @@ -9,6 +9,15 @@
require "scripts/pi-hole/php/savesettings.php";
// Reread ini file as things might have been changed
$setupVars = parse_ini_file("/etc/pihole/setupVars.conf");
$piholeFTLConfFile = "/etc/pihole/pihole-FTL.conf";
if(is_readable($piholeFTLConfFile))
{
$piholeFTLConf = parse_ini_file($piholeFTLConfFile);
}
else
{
$piholeFTLConf = array();
}

?>
<style type="text/css">
Expand Down Expand Up @@ -230,7 +239,7 @@
?>

<?php
if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists", "dns", "piholedhcp", "api", "teleporter"))) {
if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists", "dns", "piholedhcp", "api", "privacy", "teleporter"))) {
$tab = $_GET['tab'];
} else {
$tab = "sysadmin";
Expand All @@ -245,6 +254,7 @@
<li<?php if($tab === "dns"){ ?> class="active"<?php } ?>><a data-toggle="tab" href="#dns">DNS</a></li>
<li<?php if($tab === "piholedhcp"){ ?> class="active"<?php } ?>><a data-toggle="tab" href="#piholedhcp">DHCP</a></li>
<li<?php if($tab === "api"){ ?> class="active"<?php } ?>><a data-toggle="tab" href="#api">API / Web interface</a></li>
<li<?php if($tab === "privacy"){ ?> class="active"<?php } ?>><a data-toggle="tab" href="#privacy">Privacy</a></li>
<li<?php if($tab === "teleporter"){ ?> class="active"<?php } ?>><a data-toggle="tab" href="#teleporter">Teleporter</a></li>
</ul>
<div class="tab-content">
Expand Down Expand Up @@ -874,7 +884,6 @@ function convertseconds($argument)
} else {
$temperatureunit = "C";
}
// Use $boxedlayout value determined in header.php
?>
<div id="api" class="tab-pane fade<?php if($tab === "api"){ ?> in active<?php } ?>">
<div class="row">
Expand Down Expand Up @@ -969,6 +978,64 @@ function convertseconds($argument)
</div>
</div>
</div>
<!-- ######################################################### Privacy (may be expanded further later on) ######################################################### -->
<?php
// Get privacy level from piholeFTL config array
if (isset($piholeFTLConf["PRIVACYLEVEL"])) {
$privacylevel = intval($piholeFTLConf["PRIVACYLEVEL"]);
} else {
$privacylevel = 0;
}
?>
<div id="privacy" class="tab-pane fade<?php if($tab === "privacy"){ ?> in active<?php } ?>">
<div class="row">
<div class="col-md-12">
<form role="form" method="post">
<div class="box box-warning">
<div class="box-header with-border">
<h3 class="box-title">Privacy settings</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-md-12">
<h4>DNS resolver privacy level</h4>
<p>Specify if DNS queries should be anonymized, available options are:
<div class="form-group">
<div class="radio">
<label><input type="radio" name="privacylevel" value="0"
<?php if ($privacylevel === 0){ ?>checked<?php }
?>>Show everything and record everything<br>Gives maximum amount of statistics</label>
</div>
<div class="radio">
<label><input type="radio" name="privacylevel" value="1"
<?php if ($privacylevel === 1){ ?>checked<?php }
?>>Hide domains: Display and store all domains as "hidden"<br>This disables the Top Domains and Top Ads tables on the dashboard</label>
</div>
<div class="radio">
<label><input type="radio" name="privacylevel" value="2"
<?php if ($privacylevel === 2){ ?>checked<?php }
?>>Hide domains and clients: Display and store all domains as "hidden" and all clients as "0.0.0.0"<br>This disables all tables on the dashboard</label>
</div>
<div class="radio">
<label><input type="radio" name="privacylevel" value="3"
<?php if ($privacylevel === 3){ ?>checked<?php }
?>>Paranoia mode: This disables basically everything except the live anonymous stastics<br>No history is saved at all to the database, and nothing is shown in the query log. Also, there are no top item lists.</label>
</div>
</div>
<p>The privacy level may be changed at any time without having to restart the DNS resolver. However, note that queries with (partially) hidden details cannot be disclosed with a subsequent reduction of the privacy level.</p>
</div>
</div>
</div>
<div class="box-footer clearfix">
<input type="hidden" name="field" value="privacyLevel">
<input type="hidden" name="token" value="<?php echo $token ?>">
<button type="submit" class="btn btn-primary pull-right">Apply</button>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- ######################################################### Teleporter ######################################################### -->
<div id="teleporter" class="tab-pane fade<?php if($tab === "teleporter"){ ?> in active<?php } ?>">
<div class="row">
Expand Down