diff --git a/.codespellignore b/.codespellignore new file mode 100644 index 000000000..60e61ec68 --- /dev/null +++ b/.codespellignore @@ -0,0 +1,2 @@ +ede +EDE \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..a53bf58c6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,28 @@ +# EditorConfig is awesome: https://editorconfig.org/ + +# top-most EditorConfig file +root = true + +# A newline ending every file +[*] +insert_final_newline = true +indent_style = space +indent_size = 4 +charset = utf-8 +trim_trailing_whitespace = true + +[*.css] +indent_style = space +indent_size = 2 + +[scripts/**.js] +indent_style = space +indent_size = 2 + +[package.json] +indent_style = space +indent_size = 2 + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f693cda2f..000000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,32 +0,0 @@ -**By submitting this pull request, I confirm the following:** `{please fill any appropriate checkboxes, e.g: [X]}` - -`{Please ensure that your pull request is for the 'devel' branch!}` - -- [ ] I have read and understood the [contributors guide](https://github.com/pi-hole/AdminLTE/blob/master/CONTRIBUTING.md), as well as this entire template. -- [ ] I have made only one major change in my proposed changes. -- [ ] I have commented my proposed changes within the code. -- [ ] I have tested my proposed changes. -- [ ] I am willing to help maintain this change if there are issues with it later. -- [ ] I give this submission freely and claim no ownership. -- [ ] It is compatible with the [EUPL 1.2 license](https://opensource.org/licenses/EUPL-1.1) -- [ ] I have squashed any insignificant commits. ([`git rebase`](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)) -- [ ] I have Signed Off all commits. ([`git commit --signoff`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---signoff)) - ---- - -**What does this PR aim to accomplish?:** - -`{A detailed description, screenshots (if necessary), as well as links to any relevant GitHub issues}` - -**How does this PR accomplish the above?:** - -`{A detailed description (such as a changelog) and screenshots (if necessary) of the implemented fix}` - -**What documentation changes (if any) are needed to support this PR?:** - -`{A detailed list of any necessary changes}` - -> - `{Please delete this quoted section when opening your pull request}` -> - You must follow the template instructions. Failure to do so will result in your issue being closed. -> - Please respect that Pi-hole is developed by volunteers, who can only reply in their spare time. -> - Detail helps us understand an issue quicker, but please ensure it's relevant. diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 90827660f..d9341eea9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -21,3 +21,15 @@ updates: versions: - 10.2.3 - 10.2.4 + reviewers: + - "pi-hole/web-maintainers" +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + day: saturday + time: "10:00" + open-pull-requests-limit: 10 + target-branch: devel + reviewers: + - "pi-hole/web-maintainers" diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 000000000..4bcf9c3d2 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,20 @@ +name: Codespell + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + spell-check: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + steps: + - + name: Checkout repository + uses: actions/checkout@v3 + - + name: Spell-Checking + uses: codespell-project/actions-codespell@master + with: + ignore_words_file: .codespellignore + skip: ./scripts/vendor,./style/vendor diff --git a/.github/workflows/editorconfig-checker b/.github/workflows/editorconfig-checker new file mode 100644 index 000000000..37b20ba3f --- /dev/null +++ b/.github/workflows/editorconfig-checker @@ -0,0 +1,14 @@ +name: editorconfig-checker + +on: + pull_request: + push: + +jobs: + build: + name: editorconfig-checker + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - uses: editorconfig-checker/action-editorconfig-checker@main + - run: editorconfig-checker diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index d6171c185..72c8548fa 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -2,7 +2,7 @@ name: Mark stale issues on: schedule: - - cron: '0 * * * *' + - cron: '0 8 * * *' workflow_dispatch: jobs: @@ -13,7 +13,7 @@ jobs: issues: write steps: - - uses: actions/stale@v4 + - uses: actions/stale@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} days-before-stale: 30 @@ -23,3 +23,4 @@ jobs: exempt-issue-labels: 'internal, Fixed In Next Release, Bug' exempt-all-issue-assignees: true operations-per-run: 300 + close-issue-reason: 'not_planned' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 39b3cf93a..c196aede9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: "14.x" + node-version: "16.x" cache: npm - name: Install npm dependencies diff --git a/.stickler.yml b/.stickler.yml new file mode 100644 index 000000000..92beabd94 --- /dev/null +++ b/.stickler.yml @@ -0,0 +1,9 @@ +--- +linters: + yamllint: + config: ./.yamllint.conf + remarklint: +files: + ignore: + - 'scripts/vendor/*' + - 'style/vendor/*' diff --git a/.yamllint.conf b/.yamllint.conf new file mode 100644 index 000000000..d1b0953bd --- /dev/null +++ b/.yamllint.conf @@ -0,0 +1,3 @@ +rules: + line-length: disable + document-start: disable diff --git a/api_FTL.php b/api_FTL.php index 98b2ee7b2..cb0a8574b 100644 --- a/api_FTL.php +++ b/api_FTL.php @@ -64,7 +64,7 @@ } if (isset($_GET["getMaxlogage"]) && $auth) { - $return = callFTLAPI("stats"); + $return = callFTLAPI("maxlogage"); if (array_key_exists("FTLnotrunning", $return)) { $data = array("FTLnotrunning" => true); } else { @@ -306,6 +306,9 @@ if (array_key_exists("FTLnotrunning", $return)) { $data = array("FTLnotrunning" => true); } else { + // Set the header + header('Content-type: application/json'); + // Start the JSON string echo '{"data":['; $first = true; diff --git a/api_db.php b/api_db.php index a10212a72..15f580471 100644 --- a/api_db.php +++ b/api_db.php @@ -64,7 +64,20 @@ { $from = intval($_GET["from"]); $until = intval($_GET["until"]); - $dbquery = "SELECT timestamp, type, domain, client, status, forward FROM queries WHERE timestamp >= :from AND timestamp <= :until "; + + // Use table "query_storage" + // - replace domain ID with domain + // - replace client ID with client name + // - replace forward ID with forward destination + $dbquery = "SELECT timestamp, type,"; + $dbquery .= " CASE typeof(domain) WHEN 'integer' THEN (SELECT domain FROM domain_by_id d WHERE d.id = q.domain) ELSE domain END domain,"; + $dbquery .= " CASE typeof(client) WHEN 'integer' THEN ("; + $dbquery .= " SELECT CASE TRIM(name) WHEN '' THEN c.ip ELSE c.name END name FROM client_by_id c WHERE c.id = q.client"; + $dbquery .= " ) ELSE client END client,"; + $dbquery .= " CASE typeof(forward) WHEN 'integer' THEN (SELECT forward FROM forward_by_id f WHERE f.id = q.forward) ELSE forward END forward,"; + $dbquery .= " status, reply_type, reply_time, dnssec"; + $dbquery .= " FROM query_storage q"; + $dbquery .= " WHERE timestamp >= :from AND timestamp <= :until "; if(isset($_GET["types"])) { $types = $_GET["types"]; @@ -93,7 +106,7 @@ if (!is_bool($results)) { $first = true; - while ($row = $results->fetchArray()) { + while ($row = $results->fetchArray(SQLITE3_ASSOC)) { // Insert a comma before the next record (except on the first one) if (!$first) { echo ","; @@ -101,14 +114,20 @@ $first = false; } - // Convert query type ID to name, encode domain, encode destination - $query_type = getQueryTypeStr($row[1]); - $domain = utf8_encode(str_replace("~"," ",$row[2])); - $destination = utf8_encode($row[5]); + // Format, encode, transform each field (if necessary). + $time = $row["timestamp"]; + $query_type = getQueryTypeStr($row["type"]); // Convert query type ID to name + $domain = utf8_encode(str_replace("~"," ",$row["domain"])); + $client = $row["client"]; + $status = $row["status"]; + $destination = utf8_encode($row["forward"]); + $reply_type = $row["reply_type"]; + $reply_time = $row["reply_time"]; + $dnssec = $row["dnssec"]; + $client_id = $row["client_id"]; // Insert into array and output it in JSON format - // array: time type domain client status upstream destination - echo json_encode([$row[0], $query_type, $domain, $row[3], $row[4], $destination]); + echo json_encode([$time, $query_type, $domain, $client, $status, $destination, $reply_type, $reply_time, $dnssec]); } } @@ -139,7 +158,11 @@ { $limit = "WHERE timestamp <= :until"; } - $stmt = $db->prepare('SELECT client,count(client) FROM queries '.$limit.' GROUP by client order by count(client) desc limit 20'); + $dbquery = "SELECT CASE typeof(client) WHEN 'integer' THEN ("; + $dbquery .= " SELECT CASE TRIM(name) WHEN '' THEN c.ip ELSE c.name END name FROM client_by_id c WHERE c.id = q.client)"; + $dbquery .= " ELSE client END client, count(client) FROM query_storage q ".$limit." GROUP BY client ORDER BY count(client) DESC LIMIT 20"; + + $stmt = $db->prepare($dbquery); $stmt->bindValue(":from", intval($_GET['from']), SQLITE3_INTEGER); $stmt->bindValue(":until", intval($_GET['until']), SQLITE3_INTEGER); $results = $stmt->execute(); @@ -384,7 +407,7 @@ function parseDBData($results, $interval, $from, $until) { $data = array_merge($data, $result); } -if (isset($_GET['status'])) +if (isset($_GET['status']) && $auth) { $extra = ";"; if(isset($_GET["ignore"]) && $_GET["ignore"] === 'DNSMASQ_WARN') diff --git a/cname_records.php b/cname_records.php index a6a89ab1d..17b51b69f 100644 --- a/cname_records.php +++ b/cname_records.php @@ -1,12 +1,13 @@ - @@ -50,23 +51,6 @@ - - - - -
diff --git a/db_queries.php b/db_queries.php index 8ce45f10d..8d6ccaa99 100644 --- a/db_queries.php +++ b/db_queries.php @@ -56,6 +56,7 @@

+

@@ -179,6 +180,7 @@ Domain Client Status + Reply Action @@ -189,6 +191,7 @@ Domain Client Status + Reply Action diff --git a/debug.php b/debug.php index 9c316905e..6b9a01da2 100644 --- a/debug.php +++ b/debug.php @@ -13,7 +13,7 @@
- +

Once you click this button a debug log will be generated and can automatically be uploaded if we detect a working internet connection.

diff --git a/dns_records.php b/dns_records.php index 1782d1463..dcf9cf25e 100644 --- a/dns_records.php +++ b/dns_records.php @@ -1,12 +1,13 @@ - @@ -54,23 +55,6 @@
- - - - -
diff --git a/groups-adlists.php b/groups-adlists.php index 5a4688e55..b905d520d 100644 --- a/groups-adlists.php +++ b/groups-adlists.php @@ -63,6 +63,7 @@ ID + Address Status Comment diff --git a/groups-clients.php b/groups-clients.php index 2257b0ded..c48c85854 100644 --- a/groups-clients.php +++ b/groups-clients.php @@ -70,6 +70,7 @@ ID + Client Comment Group assignment diff --git a/groups-domains.php b/groups-domains.php index 3877c89a9..cad112549 100644 --- a/groups-domains.php +++ b/groups-domains.php @@ -48,7 +48,8 @@
- + +
@@ -88,6 +89,16 @@
+
+

Note:
+ The domain or regex filter will be automatically assigned to the Default Group.
+ Other groups can optionally be assigned + + within Group Management > Domains. + + in the list below (using Group assignment). +

+