From 05c8522d4fbd7de971b0304f1e3b1af21e5a1656 Mon Sep 17 00:00:00 2001 From: J den Hartog Date: Sun, 20 Nov 2016 15:17:20 +0100 Subject: [PATCH 01/39] standalone mode for iOS This will make the admin page look more like a native iOS application when started from Home Screen on iOS. It also won't create a tab in iOS Safari and will make spaceflight more convenient. See *Hiding Safari User Interface Components* on: https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html --- header.php | 1 + 1 file changed, 1 insertion(+) diff --git a/header.php b/header.php index 4412914f..54b4da1e 100644 --- a/header.php +++ b/header.php @@ -47,6 +47,7 @@ + From 363837b69d0b6e769c3bd16f56d853d9ab0882c7 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 21 Nov 2016 13:05:45 +0000 Subject: [PATCH 02/39] Update .pullapprove.yml Reflect new approvers org team. --- .pullapprove.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pullapprove.yml b/.pullapprove.yml index d0b883e9..8bd8f0a2 100644 --- a/.pullapprove.yml +++ b/.pullapprove.yml @@ -25,7 +25,7 @@ groups: - devel required: 2 teams: - - dashboard + - approvers master: approve_by_comment: From 57c262a704e69bbebb257f7c85beb9a35b70f8e4 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 21 Nov 2016 17:32:51 +0100 Subject: [PATCH 03/39] Be able to call queries.js with preset filters from the main page --- js/pihole/index.js | 17 ++++++++++++++--- js/pihole/queries.js | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/js/pihole/index.js b/js/pihole/index.js index f67bf18a..809631e7 100644 --- a/js/pihole/index.js +++ b/js/pihole/index.js @@ -224,7 +224,8 @@ function updateTopClientsChart() { $.getJSON("api.php?summaryRaw&getQuerySources", function(data) { var clienttable = $('#client-frequency').find('tbody:last'); for (domain in data.top_sources) { - clienttable.append(' ' + domain + + var url = ''+domain+''; + clienttable.append(' ' + url + ' ' + data.top_sources[domain] + '
'); } @@ -260,14 +261,24 @@ function updateTopLists() { $.getJSON("api.php?summaryRaw&topItems", function(data) { var domaintable = $('#domain-frequency').find('tbody:last'); var adtable = $('#ad-frequency').find('tbody:last'); + var url; for (domain in data.top_queries) { - domaintable.append(' ' + domain + + if(domain !== "pi.hole") + { + url = ''+domain+''; + } + else + { + url = domain; + } + domaintable.append(' ' + url + ' ' + data.top_queries[domain] + '
'); } for (domain in data.top_ads) { - adtable.append(' ' + domain + + url = ''+domain+''; + adtable.append(' ' + url + ' ' + data.top_ads[domain] + '
'); } diff --git a/js/pihole/queries.js b/js/pihole/queries.js index 29d388a1..ec55a7f1 100644 --- a/js/pihole/queries.js +++ b/js/pihole/queries.js @@ -40,6 +40,33 @@ $(document).ready(function() { add(data[2],"black"); } } ); + + // Do we want to filter queries? + var GETDict = {} + location.search.substr(1).split("&").forEach(function(item) {GETDict[item.split("=")[0]] = item.split("=")[1]}) + if("client" in GETDict) + { + if(GETDict["client"] == "localhost(127.0.0.1)") + { + // Have to use normal search, as regexp of DataTable is broken + // It should be fixed in next release which might come up next + // year. In the meantime, we work around using normal search. + tableApi.column(3).search("localhost"); + } + else + { + // Search in third column (zero indexed) + // Use regular expression to only show exact matches, i.e. + // don't show 192.168.0.100 when searching for 192.168.0.1 + // true = use regex, false = don't use smart search + tableApi.column(3).search("^"+GETDict["client"]+"$",true,false); + } + } + if("domain" in GETDict) + { + // Search in second column (zero indexed) + tableApi.column(2).search("^"+GETDict["domain"]+"$",true,false); + } } ); function refreshData() { From 214b96fea2c1f974742bee65e0192e1329842625 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 21 Nov 2016 17:58:20 +0100 Subject: [PATCH 04/39] Fixed some small errors --- js/pihole/index.js | 16 ++++++++-------- js/pihole/queries.js | 9 +++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/js/pihole/index.js b/js/pihole/index.js index 809631e7..de41e492 100644 --- a/js/pihole/index.js +++ b/js/pihole/index.js @@ -223,9 +223,9 @@ function updateQueryTypes() { function updateTopClientsChart() { $.getJSON("api.php?summaryRaw&getQuerySources", function(data) { var clienttable = $('#client-frequency').find('tbody:last'); - for (domain in data.top_sources) { - var url = ''+domain+''; - clienttable.append(' ' + url + + for (var domain in data.top_sources) { + var url = url = ""+domain+""; + clienttable.append(" " + url + ' ' + data.top_sources[domain] + '
'); } @@ -263,22 +263,22 @@ function updateTopLists() { var adtable = $('#ad-frequency').find('tbody:last'); var url; - for (domain in data.top_queries) { + for (var domain in data.top_queries) { if(domain !== "pi.hole") { - url = ''+domain+''; + url = ""+domain+""; } else { url = domain; } - domaintable.append(' ' + url + + domaintable.append(" " + url + ' ' + data.top_queries[domain] + '
'); } for (domain in data.top_ads) { - url = ''+domain+''; - adtable.append(' ' + url + + url = ""+domain+""; + adtable.append(" " + url + ' ' + data.top_ads[domain] + '
'); } diff --git a/js/pihole/queries.js b/js/pihole/queries.js index ec55a7f1..ff6a6694 100644 --- a/js/pihole/queries.js +++ b/js/pihole/queries.js @@ -1,4 +1,5 @@ -$(document).ready(function() { +var tableApi; +(document).ready(function() { tableApi = $('#all-queries').DataTable( { "rowCallback": function( row, data, index ){ if (data[4] == "Pi-holed") { @@ -42,11 +43,11 @@ $(document).ready(function() { } ); // Do we want to filter queries? - var GETDict = {} - location.search.substr(1).split("&").forEach(function(item) {GETDict[item.split("=")[0]] = item.split("=")[1]}) + var GETDict = {}; + location.search.substr(1).split("&").forEach(function(item) {GETDict[item.split("=")[0]] = item.split("=")[1]}); if("client" in GETDict) { - if(GETDict["client"] == "localhost(127.0.0.1)") + if(GETDict["client"] === "localhost(127.0.0.1)") { // Have to use normal search, as regexp of DataTable is broken // It should be fixed in next release which might come up next From e67a16a54c18a2b04826654f81c39908b0aa50b9 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 21 Nov 2016 18:29:21 +0100 Subject: [PATCH 05/39] Another minor change --- js/pihole/index.js | 2 +- js/pihole/queries.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/pihole/index.js b/js/pihole/index.js index de41e492..4d873b11 100644 --- a/js/pihole/index.js +++ b/js/pihole/index.js @@ -276,7 +276,7 @@ function updateTopLists() { ' ' + data.top_queries[domain] + '
'); } - for (domain in data.top_ads) { + for (var domain in data.top_ads) { url = ""+domain+""; adtable.append(" " + url + ' ' + data.top_ads[domain] + '
Date: Mon, 21 Nov 2016 18:33:27 +0100 Subject: [PATCH 06/39] Lost $ sign --- js/pihole/queries.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/pihole/queries.js b/js/pihole/queries.js index 796d26be..cf2a9321 100644 --- a/js/pihole/queries.js +++ b/js/pihole/queries.js @@ -1,5 +1,5 @@ var tableApi; -(document).ready(function() { +$(document).ready(function() { tableApi = $('#all-queries').DataTable( { "rowCallback": function( row, data, index ){ if (data[4] == "Pi-holed") { @@ -44,7 +44,7 @@ var tableApi; // Do we want to filter queries? var GETDict = {}; - location.search.substr(1).split("&").forEach(function(item) {GETDict[item.split("=")[0]] = item.split("=")[1];}); + location.search.substr(1).split("&").forEach(function(item) {GETDict[item.split("=")[0]] = item.split("=")[1]}); if("client" in GETDict) { if(GETDict["client"] === "localhost(127.0.0.1)") From d4aa4fce9701ed0a067c50d295c050b023719467 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 21 Nov 2016 18:34:19 +0100 Subject: [PATCH 07/39] Another semicolon --- js/pihole/queries.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/pihole/queries.js b/js/pihole/queries.js index cf2a9321..04a299a7 100644 --- a/js/pihole/queries.js +++ b/js/pihole/queries.js @@ -44,7 +44,7 @@ $(document).ready(function() { // Do we want to filter queries? var GETDict = {}; - location.search.substr(1).split("&").forEach(function(item) {GETDict[item.split("=")[0]] = item.split("=")[1]}); + location.search.substr(1).split("&").forEach(function(item) {GETDict[item.split("=")[0]] = item.split("=")[1];}); if("client" in GETDict) { if(GETDict["client"] === "localhost(127.0.0.1)") From e94a2be01664f4effdf06e0e581db5287ceda90b Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 21 Nov 2016 18:58:04 +0100 Subject: [PATCH 08/39] More codacy complaints --- js/pihole/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/pihole/index.js b/js/pihole/index.js index 4d873b11..d620e5d9 100644 --- a/js/pihole/index.js +++ b/js/pihole/index.js @@ -261,9 +261,9 @@ function updateTopLists() { $.getJSON("api.php?summaryRaw&topItems", function(data) { var domaintable = $('#domain-frequency').find('tbody:last'); var adtable = $('#ad-frequency').find('tbody:last'); - var url; + var url, domain; - for (var domain in data.top_queries) { + for (domain in data.top_queries) { if(domain !== "pi.hole") { url = ""+domain+""; @@ -276,7 +276,7 @@ function updateTopLists() { ' ' + data.top_queries[domain] + '
'); } - for (var domain in data.top_ads) { + for (domain in data.top_ads) { url = ""+domain+""; adtable.append(" " + url + ' ' + data.top_ads[domain] + '
Donate + +
  • + + Help + +
  • From 0680fd546bf87f2a85b80e5a2bef3a4d5e8c7159 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 12:43:35 +0100 Subject: [PATCH 10/39] Added help center skeleton --- help.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 help.php diff --git a/help.php b/help.php new file mode 100644 index 00000000..3df509c9 --- /dev/null +++ b/help.php @@ -0,0 +1,60 @@ + + + +
    +
    +

    Header

    +

    Top left: Status display

    +

    Top right: About

    +
    +
    +
    +
    +

    Main page

    +

    On the main page, various statistics of pi-hole are shown to the user.

    +
    +
    +
    +
    +

    Query Log

    +
    +
    +
    +
    +

    White- / Blacklist

    +
    +
    +
    +
    +

    Update lists

    +
    +
    +
    +
    +

    Disable / Enable

    +
    +
    +
    +
    +

    Donate

    +
    +
    +
    +
    +

    Help (this page)

    +
    +
    +
    +
    +

    Footer

    +
    +
    + + + From d19048f5e6b6f85bb80b50f45b67315ad215685f Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 12:44:01 +0100 Subject: [PATCH 11/39] Add changing of temperature unit from the web UI --- header.php | 14 ++++++++++++++ help.php | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/header.php b/header.php index 2c02e9b5..9e54ce18 100644 --- a/header.php +++ b/header.php @@ -8,6 +8,20 @@ $refer = $_SERVER['HTTP_REFERER']; header("location:$refer"); } + + // Web based change of temperature unit + if (isset($_GET['tempunit'])) + { + if($_GET['tempunit'] == "fahrenheit") + { + exec('sudo pihole -a -f'); + } + else + { + exec('sudo pihole -a -c'); + } + } + $cmd = "echo $((`cat /sys/class/thermal/thermal_zone0/temp | cut -c1-2`))"; $output = shell_exec($cmd); $celsius = str_replace(array("\r\n","\r","\n"),"", $output); diff --git a/help.php b/help.php index 3df509c9..323bec77 100644 --- a/help.php +++ b/help.php @@ -9,6 +9,25 @@

    Header

    Top left: Status display

    +

    Shows different status messages:

    +
      +
    • Status (Active, Offline, Starting) of the Pi-hole
    • +
    • Current CPU temperature + + (switch unit to Fahrenheit) + + (switch unit to Celsius) +
    • +
    • +

    Top right: About

    From 135de872571fc149fb947cd575636a0b79de9d0e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 12:50:34 +0100 Subject: [PATCH 12/39] Completed description of the top left header subsection --- help.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/help.php b/help.php index 323bec77..720be439 100644 --- a/help.php +++ b/help.php @@ -11,7 +11,7 @@

    Top left: Status display

    Shows different status messages:

      -
    • Status (Active, Offline, Starting) of the Pi-hole
    • +
    • Status (Active (), Offline (), Starting ()) of the Pi-hole
    • Current CPU temperature
    • -
    • +
    • Load: load averages for the last minute, 5 minutes and 15 minutes, respectively. A load average of 1 reflects the full workload of a single processor on the system. We show a red icon if the current load exceeds the number of available processors on this machine (which is )
    • +
    • Memory usage: Shows the percentage of memory acutally blocked by applications. We show a red icon if the memory usage exceeds 75%

    Top right: About

    From 2fadb46d2ccddce7d8770fdbbabe340bc73beec3 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 12:54:41 +0100 Subject: [PATCH 13/39] Added top right subsection --- help.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/help.php b/help.php index 720be439..a1f046cf 100644 --- a/help.php +++ b/help.php @@ -11,8 +11,8 @@

    Top left: Status display

    Shows different status messages:

      -
    • Status (Active (), Offline (), Starting ()) of the Pi-hole
    • -
    • Current CPU temperature +
    • Status: Current status of the Pi-hole - Active (), Offline (), or Starting ()
    • +
    • Temp: Current CPU temperature @@ -30,6 +30,12 @@
    • Memory usage: Shows the percentage of memory acutally blocked by applications. We show a red icon if the memory usage exceeds 75%

    Top right: About

    +
      +
    • GitHub: Link to pi-hole repository
    • +
    • Details: Link to Jacob Salmela's blog with some more details, describing also the concept of the Pi-hole
    • +
    • Updates: Link to list of releases
    • +
    • Update notifications: If updates are available, a link will be shown here.
    • +
    From 015089d1dab1d88a41c26d46ac2133f5fbb30138 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 13:05:42 +0100 Subject: [PATCH 14/39] Added main page section --- help.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/help.php b/help.php index a1f046cf..02d4e4c8 100644 --- a/help.php +++ b/help.php @@ -41,7 +41,24 @@

    Main page

    -

    On the main page, various statistics of pi-hole are shown to the user.

    +

    On the main page, various statistics of pi-hole are shown to the user:

    +
      +
    • Summary: A summary of statistics showing how many out of how many total DNS queries have been blocked today, how that translates into a percentage and how many domains are on the blacklist. This graph is updated every 10 seconds. Changes are highlighted.
    • +
    • Queries over time: Diagram showing DNS queries (total and blocked) over 10 minute time intervals. More information can be acquired by hovering over the lines.
    • +
    • Query Types: Shows which types of query have been processed: +
        +
      • A: IPv4 address lookup (most commonly used to map hostnames to an IP address of the host)
      • +
      • AAAA: IPv6 address lookup (most commonly used to map hostnames to an IP address of the host)
      • +
      • PTR: most common use is for implementing reverse DNS lookups
      • +
      • SRV: Service locator (often used by XMPP, SIP, and LDAP)
      • +
      +
    • +
    • Query Types: Shows to which upstream DNS the permitted requests have been forwarded to.
    • +
    • Top Domains: Ranking of requested sites by number of DNS lookups.
    • +
    • Top Advertisers: Ranking of requested sites by number of DNS lookups.
    • +
    • Top Advertisers: Ranking of requested advertisments by number of DNS lookups.
    • +
    • Top Clients: Ranking of total DNS requests separated by clients on the local network.
    • +
    From ddef2af9d52b500a0754075323e0cbe78c9187ae Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 13:18:16 +0100 Subject: [PATCH 15/39] Add "Query Log" section --- help.php | 1 + 1 file changed, 1 insertion(+) diff --git a/help.php b/help.php index 02d4e4c8..78374fbd 100644 --- a/help.php +++ b/help.php @@ -64,6 +64,7 @@

    Query Log

    +

    Shows the recent queries after parsing the pi-hole log files. It is possible to search through the whole list by using the "Search" input field. If the status is reported as "OK", then the DNS request has been permitted. Otherwise ("Pi-holed") it has been blocked. By clicking on the buttons under "Action" the corresponding domains can quickly be added to the white-/blacklist. The status of this action will be reported on this page.

    From 85defe3bcd8ea25cd9d61073eafbdcbb9586080d Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 13:20:38 +0100 Subject: [PATCH 16/39] Add "White- / Blacklist" section --- help.php | 1 + 1 file changed, 1 insertion(+) diff --git a/help.php b/help.php index 78374fbd..8e6c48b1 100644 --- a/help.php +++ b/help.php @@ -70,6 +70,7 @@

    White- / Blacklist

    +

    Add or remove domains (or subdomains) from the white-/blacklist. If a domain is added to e.g. the whitelist, any possible entry of the same domain will be automatically removed from the blacklist and vice versa. Adding wildcars is currently not supported.

    From eedb1415490ad9a0a1537a24d582b144985f0f95 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 13:23:38 +0100 Subject: [PATCH 17/39] Add "Update Lists" section --- header.php | 2 +- help.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/header.php b/header.php index 9e54ce18..ee1bcc0e 100644 --- a/header.php +++ b/header.php @@ -253,7 +253,7 @@
  • - Update lists + Update Lists
  • diff --git a/help.php b/help.php index 8e6c48b1..5b092095 100644 --- a/help.php +++ b/help.php @@ -75,7 +75,8 @@
    -

    Update lists

    +

    Update Lists

    +

    Runs the command

    sudo pihole -g
    and prints the result transparently to the web UI. The gravity.sh script will update the list of ad-serving domains

    From 8bacc06c1aa176f10c6a988d0451f9eaaf17b264 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 13:25:13 +0100 Subject: [PATCH 18/39] Added "Disable / Enable" subsection --- help.php | 1 + 1 file changed, 1 insertion(+) diff --git a/help.php b/help.php index 5b092095..921bf47d 100644 --- a/help.php +++ b/help.php @@ -82,6 +82,7 @@

    Disable / Enable

    + Disables resp. enables Pi-Hole DNS Blocking completely. The change will be reflected by a changed status (top left)
    From d02487aa9f20121d4ee96e38c1b0a0880e76cc3b Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 13:29:13 +0100 Subject: [PATCH 19/39] Add "Donate" section --- help.php | 1 + 1 file changed, 1 insertion(+) diff --git a/help.php b/help.php index 921bf47d..47e8ee52 100644 --- a/help.php +++ b/help.php @@ -88,6 +88,7 @@

    Donate

    + If you like Pi-Hole, please consider a small donation. Keep in mind that Pi-hole is free, but powered by your donations
    From 4a68be057219102b619fb8f2ee479e91c1d73153 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 13:30:03 +0100 Subject: [PATCH 20/39] Added "Help" section --- help.php | 1 + 1 file changed, 1 insertion(+) diff --git a/help.php b/help.php index 47e8ee52..76ad4e4f 100644 --- a/help.php +++ b/help.php @@ -94,6 +94,7 @@

    Help (this page)

    + Shows information about what is happening behind the scenes and what can be done with this web user interface (web UI)
    From af71be16ffb0f325b7bd38c102d258b9ce7a4649 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 13:30:50 +0100 Subject: [PATCH 21/39] Added "Footer" section --- help.php | 1 + 1 file changed, 1 insertion(+) diff --git a/help.php b/help.php index 76ad4e4f..380c529a 100644 --- a/help.php +++ b/help.php @@ -100,6 +100,7 @@

    Footer

    + Shows the currently installed Pi-hole and Web Interface version. If an update is available, this will be indicated here
    From 977980f49ba0ac90d24a37b7b1d1d0b118fec534 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 13:32:06 +0100 Subject: [PATCH 22/39] Small change to style of the new "Help center" page --- help.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/help.php b/help.php index 380c529a..afcb1605 100644 --- a/help.php +++ b/help.php @@ -1,14 +1,11 @@ - -
    +

    Help center

    Header

    -

    Top left: Status display

    +

    Top left: Status display

    Shows different status messages:

    • Status: Current status of the Pi-hole - Active (), Offline (), or Starting ()
    • @@ -29,7 +26,7 @@
    • Load: load averages for the last minute, 5 minutes and 15 minutes, respectively. A load average of 1 reflects the full workload of a single processor on the system. We show a red icon if the current load exceeds the number of available processors on this machine (which is )
    • Memory usage: Shows the percentage of memory acutally blocked by applications. We show a red icon if the memory usage exceeds 75%
    -

    Top right: About

    +

    Top right: About

    • GitHub: Link to pi-hole repository
    • Details: Link to Jacob Salmela's blog with some more details, describing also the concept of the Pi-hole
    • From bb68422262cbd031699cdfaf946afe462c356ae5 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 13:32:35 +0100 Subject: [PATCH 23/39] Consider that there are more possible DNS query types --- help.php | 1 + 1 file changed, 1 insertion(+) diff --git a/help.php b/help.php index afcb1605..9eefb865 100644 --- a/help.php +++ b/help.php @@ -48,6 +48,7 @@
    • AAAA: IPv6 address lookup (most commonly used to map hostnames to an IP address of the host)
    • PTR: most common use is for implementing reverse DNS lookups
    • SRV: Service locator (often used by XMPP, SIP, and LDAP)
    • +
    • and others
  • Query Types: Shows to which upstream DNS the permitted requests have been forwarded to.
  • From 16df80b017c5336bf06a3201b69c169d349078d2 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 13:45:45 +0100 Subject: [PATCH 24/39] Fixed some typos --- help.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/help.php b/help.php index 9eefb865..9d2527e3 100644 --- a/help.php +++ b/help.php @@ -24,7 +24,7 @@ } ?>
  • Load: load averages for the last minute, 5 minutes and 15 minutes, respectively. A load average of 1 reflects the full workload of a single processor on the system. We show a red icon if the current load exceeds the number of available processors on this machine (which is )
  • -
  • Memory usage: Shows the percentage of memory acutally blocked by applications. We show a red icon if the memory usage exceeds 75%
  • +
  • Memory usage: Shows the percentage of memory actually blocked by applications. We show a red icon if the memory usage exceeds 75%
  • Top right: About

      @@ -54,7 +54,7 @@
    • Query Types: Shows to which upstream DNS the permitted requests have been forwarded to.
    • Top Domains: Ranking of requested sites by number of DNS lookups.
    • Top Advertisers: Ranking of requested sites by number of DNS lookups.
    • -
    • Top Advertisers: Ranking of requested advertisments by number of DNS lookups.
    • +
    • Top Advertisers: Ranking of requested advertisements by number of DNS lookups.
    • Top Clients: Ranking of total DNS requests separated by clients on the local network.
    @@ -68,7 +68,7 @@

    White- / Blacklist

    -

    Add or remove domains (or subdomains) from the white-/blacklist. If a domain is added to e.g. the whitelist, any possible entry of the same domain will be automatically removed from the blacklist and vice versa. Adding wildcars is currently not supported.

    +

    Add or remove domains (or subdomains) from the white-/blacklist. If a domain is added to e.g. the whitelist, any possible entry of the same domain will be automatically removed from the blacklist and vice versa. Adding wildcards using the web UI is currently not supported.

    From 96f7bf59210595815130bbc4cd638d21b3e9f8a1 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 14:09:46 +0100 Subject: [PATCH 25/39] Add flushing of the pi-hole log file using the web UI --- help.php | 19 ++++++++++++++++++- js/pihole/help.js | 7 +++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 js/pihole/help.js diff --git a/help.php b/help.php index 9d2527e3..c6b934d5 100644 --- a/help.php +++ b/help.php @@ -1,6 +1,7 @@ +

    Help center

    @@ -101,8 +102,24 @@ Shows the currently installed Pi-hole and Web Interface version. If an update is available, this will be indicated here
    - +
    +
    +

    Emergency help

    + In case the web UI does not work properly anymore (i.e. timeout errors or diagrams not showing up) you can try to flush the Pi-hole config file by clicking FLUSH. Note that your statistics will be reset and you loose the statistics of the day until now. +
    +
    + + diff --git a/js/pihole/help.js b/js/pihole/help.js new file mode 100644 index 00000000..cfa05dbf --- /dev/null +++ b/js/pihole/help.js @@ -0,0 +1,7 @@ +$( "#flush" ).click(function() { + if (confirm('Are you sure you want to flush the pi-hole log file?')) { + document.location.href='help.php?flush=true'; + } else { + // Do nothing! + } +}); From 9f30aca516a6d96ab409719834e491f3c9f5f023 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 14:13:17 +0100 Subject: [PATCH 26/39] Strings must use doublequote --- help.php | 6 +++--- js/pihole/help.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/help.php b/help.php index c6b934d5..3a4b2490 100644 --- a/help.php +++ b/help.php @@ -111,11 +111,11 @@ Date: Tue, 22 Nov 2016 14:27:00 +0100 Subject: [PATCH 27/39] Removed "Top Advertisers" being listed twice --- help.php | 1 - 1 file changed, 1 deletion(-) diff --git a/help.php b/help.php index 3a4b2490..fc6130e7 100644 --- a/help.php +++ b/help.php @@ -54,7 +54,6 @@
  • Query Types: Shows to which upstream DNS the permitted requests have been forwarded to.
  • Top Domains: Ranking of requested sites by number of DNS lookups.
  • -
  • Top Advertisers: Ranking of requested sites by number of DNS lookups.
  • Top Advertisers: Ranking of requested advertisements by number of DNS lookups.
  • Top Clients: Ranking of total DNS requests separated by clients on the local network.
  • From 7f7604a6af97d581144f429ed03353d682c75242 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 15:23:30 +0100 Subject: [PATCH 28/39] Add "Query adlists" feature --- header.php | 6 ++++++ js/pihole/queryads.js | 36 ++++++++++++++++++++++++++++++++++++ php/queryads.php | 35 +++++++++++++++++++++++++++++++++++ queryads.php | 23 +++++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 js/pihole/queryads.js create mode 100644 php/queryads.php create mode 100644 queryads.php diff --git a/header.php b/header.php index 54b4da1e..76284ef6 100644 --- a/header.php +++ b/header.php @@ -242,6 +242,12 @@ Update lists + +
  • + + Query adlists + +
  • diff --git a/queryads.php b/queryads.php new file mode 100644 index 00000000..82d22603 --- /dev/null +++ b/queryads.php @@ -0,0 +1,23 @@ + + + + +
    + + + + +
    + + + + + + + From 7f779e482f9f16f1a45af95273fe18c354932e13 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 15:30:51 +0100 Subject: [PATCH 29/39] Check if url does exists (try to resolve!) --- php/queryads.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/php/queryads.php b/php/queryads.php index 5c56a273..fddcebae 100644 --- a/php/queryads.php +++ b/php/queryads.php @@ -4,7 +4,8 @@ if(isset($_GET["domain"])) { // Remove illegal characters $url = filter_var($_GET["domain"], FILTER_SANITIZE_URL); - if(!filter_var("http://".$url, FILTER_VALIDATE_URL ) === true) + // Is this a valid domain? + if(!filter_var(gethostbyname($url), FILTER_VALIDATE_IP)) { die("Invalid domain!"); } From 64d532a95cd15c4a18f9eb3589a547a7e933842f Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 15:36:16 +0100 Subject: [PATCH 30/39] Pass "Invalid domain!" error message to user --- js/pihole/queryads.js | 2 ++ php/queryads.php | 36 +++++++++++++++++------------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/js/pihole/queryads.js b/js/pihole/queryads.js index d0da2412..b7693bab 100644 --- a/js/pihole/queryads.js +++ b/js/pihole/queryads.js @@ -2,7 +2,9 @@ function eventsource() { var ta = $("#output"); var domain = $("#domain"); if(domain.val().length === 0) + { return; + } var source = new EventSource("php/queryads.php?domain="+domain.val()); // Reset and show field diff --git a/php/queryads.php b/php/queryads.php index fddcebae..9faac669 100644 --- a/php/queryads.php +++ b/php/queryads.php @@ -1,20 +1,4 @@ From 83cf008fcab9d911aef51cceb872150f0be8fcce Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 15:43:12 +0100 Subject: [PATCH 31/39] Fixed comment --- js/pihole/queryads.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/pihole/queryads.js b/js/pihole/queryads.js index b7693bab..26061d42 100644 --- a/js/pihole/queryads.js +++ b/js/pihole/queryads.js @@ -25,7 +25,7 @@ function eventsource() { // eventsourcetest(); // }); -// Handle enter button for adding domains +// Handle enter button $(document).keypress(function(e) { if(e.which === 13 && $("#domain").is(":focus")) { // Enter was pressed, and the input has focus From 9f3b2e2bdaafc45ee8bd80a5391fabefb74dbf0e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 22 Nov 2016 16:38:28 +0100 Subject: [PATCH 32/39] Changed title of the new page --- queryads.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queryads.php b/queryads.php index 82d22603..4392c01f 100644 --- a/queryads.php +++ b/queryads.php @@ -3,7 +3,7 @@ ?>
    From 1f9793354dbd3871dbd4045a0c33b8ec9a51b56b Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 23 Nov 2016 11:47:04 +0100 Subject: [PATCH 33/39] Be sure to sanitize domain names in links --- js/pihole/index.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/js/pihole/index.js b/js/pihole/index.js index d620e5d9..92a11fad 100644 --- a/js/pihole/index.js +++ b/js/pihole/index.js @@ -220,11 +220,26 @@ function updateQueryTypes() { }); } +// Credit: http://stackoverflow.com/questions/1787322/htmlspecialchars-equivalent-in-javascript/4835406#4835406 +function escapeHtml(text) { + var map = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + }; + + return text.replace(/[&<>"']/g, function(m) { return map[m]; }); +} + function updateTopClientsChart() { $.getJSON("api.php?summaryRaw&getQuerySources", function(data) { var clienttable = $('#client-frequency').find('tbody:last'); for (var domain in data.top_sources) { - var url = url = ""+domain+""; + // Sanitize domain + domain = escapeHtml(domain); + var url = ""+domain+""; clienttable.append(" " + url + ' ' + data.top_sources[domain] + '
    '); @@ -264,6 +279,8 @@ function updateTopLists() { var url, domain; for (domain in data.top_queries) { + // Sanitize domain + domain = escapeHtml(domain); if(domain !== "pi.hole") { url = ""+domain+""; @@ -277,6 +294,8 @@ function updateTopLists() { data.top_queries[domain] / data.dns_queries_today * 100 + '%">
    '); } for (domain in data.top_ads) { + // Sanitize domain + domain = escapeHtml(domain); url = ""+domain+""; adtable.append(" " + url + ' ' + data.top_ads[domain] + '
    Date: Wed, 23 Nov 2016 11:59:18 +0100 Subject: [PATCH 35/39] Incorporate @Mcat12's comments --- help.php | 29 +++++++++++++---------------- js/pihole/help.js | 4 ++-- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/help.php b/help.php index fc6130e7..8c416647 100644 --- a/help.php +++ b/help.php @@ -29,7 +29,7 @@

    Top right: About

      -
    • GitHub: Link to pi-hole repository
    • +
    • GitHub: Link to the Pi-hole repository
    • Details: Link to Jacob Salmela's blog with some more details, describing also the concept of the Pi-hole
    • Updates: Link to list of releases
    • Update notifications: If updates are available, a link will be shown here.
    • @@ -39,14 +39,14 @@

      Main page

      -

      On the main page, various statistics of pi-hole are shown to the user:

      +

      On the main page, you can see various Pi-hole statistics:

        -
      • Summary: A summary of statistics showing how many out of how many total DNS queries have been blocked today, how that translates into a percentage and how many domains are on the blacklist. This graph is updated every 10 seconds. Changes are highlighted.
      • -
      • Queries over time: Diagram showing DNS queries (total and blocked) over 10 minute time intervals. More information can be acquired by hovering over the lines.
      • -
      • Query Types: Shows which types of query have been processed: +
      • Summary: A summary of statistics showing how many total DNS queries have been blocked today, what percentage of DNS queries have been blocked, and how many domains are in the compiled ad list. This summary is updated every 10 seconds.
      • +
      • Queries over time: Graph showing DNS queries (total and blocked) over 10 minute time intervals. More information can be acquired by hovering over the lines.
      • +
      • Query Types: Identifies the types of processed queries:
          -
        • A: IPv4 address lookup (most commonly used to map hostnames to an IP address of the host)
        • -
        • AAAA: IPv6 address lookup (most commonly used to map hostnames to an IP address of the host)
        • +
        • A: address lookup (most commonly used to map hostnames to an IPv4 address of the host)
        • +
        • AAAA: address lookup (most commonly used to map hostnames to an IPv6 address of the host)
        • PTR: most common use is for implementing reverse DNS lookups
        • SRV: Service locator (often used by XMPP, SIP, and LDAP)
        • and others
        • @@ -55,14 +55,14 @@
        • Query Types: Shows to which upstream DNS the permitted requests have been forwarded to.
        • Top Domains: Ranking of requested sites by number of DNS lookups.
        • Top Advertisers: Ranking of requested advertisements by number of DNS lookups.
        • -
        • Top Clients: Ranking of total DNS requests separated by clients on the local network.
        • +
        • Top Clients: Ranking of how many DNS requests each client has made on the local network.

      Query Log

      -

      Shows the recent queries after parsing the pi-hole log files. It is possible to search through the whole list by using the "Search" input field. If the status is reported as "OK", then the DNS request has been permitted. Otherwise ("Pi-holed") it has been blocked. By clicking on the buttons under "Action" the corresponding domains can quickly be added to the white-/blacklist. The status of this action will be reported on this page.

      +

      Shows the recent queries by parsing Pi-hole's log. It is possible to search through the whole list by using the "Search" input field. If the status is reported as "OK", then the DNS request has been permitted. Otherwise ("Pi-holed") it has been blocked. By clicking on the buttons under "Action" the corresponding domains can quickly be added to the white-/blacklist. The status of the action will be reported on this page.

      @@ -80,13 +80,13 @@

      Disable / Enable

      - Disables resp. enables Pi-Hole DNS Blocking completely. The change will be reflected by a changed status (top left) + Disables/enables Pi-Hole blocking completely. You may have to wait a few minutes for the changes to reach all of your devices. The change will be reflected by a changed status (top left)

      Donate

      - If you like Pi-Hole, please consider a small donation. Keep in mind that Pi-hole is free, but powered by your donations + Keep in mind that Pi-hole is free. If you like Pi-hole, please consider a small donation to help support its development
      @@ -104,7 +104,7 @@

      Emergency help

      - In case the web UI does not work properly anymore (i.e. timeout errors or diagrams not showing up) you can try to flush the Pi-hole config file by clicking FLUSH. Note that your statistics will be reset and you loose the statistics of the day until now. + In case the web UI does not work properly anymore (i.e. timeout errors or diagrams not showing up) you can try to flush the Pi-hole config file by clicking FLUSH. Note that your statistics will be reset and you lose the statistics up to this point.
      @@ -112,10 +112,7 @@ // Web based flushing of pi-hole log file if (isset($_GET["flush"])) { - if($_GET["flush"] == "true") - { - exec("sudo pihole -f"); - } + exec("sudo pihole -f"); } require "footer.php"; diff --git a/js/pihole/help.js b/js/pihole/help.js index 8264b88c..086759a0 100644 --- a/js/pihole/help.js +++ b/js/pihole/help.js @@ -1,6 +1,6 @@ $( "#flush" ).click(function() { - if (confirm("Are you sure you want to flush the pi-hole log file?")) { - document.location.href="help.php?flush=true"; + if (confirm("Are you sure you want to flush the Pi-hole log file?")) { + document.location.href="help.php?flush"; } else { // Do nothing! } From 3b5c2f6ddc1628f40a3018e2bfbcd219572dd88c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 23 Nov 2016 12:00:59 +0100 Subject: [PATCH 36/39] codacy: Strings must use doublequote. --- js/pihole/queries.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/pihole/queries.js b/js/pihole/queries.js index ac11b3de..e8af78a8 100644 --- a/js/pihole/queries.js +++ b/js/pihole/queries.js @@ -2,9 +2,9 @@ var tableApi; function escapeRegex(text) { var map = { - '(': '\\(', - ')': '\\)', - '.': '\\.', + "(": "\\(", + ")": "\\)", + ".": "\\.", }; return text.replace(/[().]/g, function(m) { return map[m]; }); } From cfc76cc9346867c7e1099b27dd7247ac33924aa6 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 23 Nov 2016 12:02:18 +0100 Subject: [PATCH 37/39] codacy: Strings must use doublequote. --- js/pihole/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/pihole/index.js b/js/pihole/index.js index 92a11fad..03845dc3 100644 --- a/js/pihole/index.js +++ b/js/pihole/index.js @@ -223,11 +223,11 @@ function updateQueryTypes() { // Credit: http://stackoverflow.com/questions/1787322/htmlspecialchars-equivalent-in-javascript/4835406#4835406 function escapeHtml(text) { var map = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''' + "&": "&", + "<": "<", + ">": ">", + "\"": """, + "\'": "'" }; return text.replace(/[&<>"']/g, function(m) { return map[m]; }); From 623ae2c56e5009cd5d67216de29eba1f9298f036 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 23 Nov 2016 12:02:48 +0100 Subject: [PATCH 38/39] Moved definition of var domain outside of the for-in loop --- js/pihole/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/pihole/index.js b/js/pihole/index.js index 03845dc3..5d22efdd 100644 --- a/js/pihole/index.js +++ b/js/pihole/index.js @@ -236,7 +236,8 @@ function escapeHtml(text) { function updateTopClientsChart() { $.getJSON("api.php?summaryRaw&getQuerySources", function(data) { var clienttable = $('#client-frequency').find('tbody:last'); - for (var domain in data.top_sources) { + var domain; + for (domain in data.top_sources) { // Sanitize domain domain = escapeHtml(domain); var url = ""+domain+""; From 5b15755014d398f9f4ec6365758b964852db25a7 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 23 Nov 2016 12:18:27 +0100 Subject: [PATCH 39/39] Added new check for validity of domain name --- php/queryads.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/php/queryads.php b/php/queryads.php index 9faac669..eedb4a22 100644 --- a/php/queryads.php +++ b/php/queryads.php @@ -9,13 +9,20 @@ function echoEvent($datatext) { echo "data: ".implode("\ndata: ", explode("\n", $datatext))."\n\n"; } +// Credit: http://stackoverflow.com/a/4694816/2087442 +function is_valid_domain_name($domain_name) +{ + return (preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $domain_name) //valid chars check + && preg_match("/^.{1,253}$/", $domain_name) //overall length check + && preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name) ); //length of each label +} + // Test if domain is set if(isset($_GET["domain"])) { - // Remove illegal characters - $url = filter_var($_GET["domain"], FILTER_SANITIZE_URL); // Is this a valid domain? - if(!filter_var(gethostbyname($url), FILTER_VALIDATE_IP)) + $url = $_GET["domain"]; + if(!is_valid_domain_name($url)) { echoEvent("Invalid domain!"); die();