1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-11-18 06:08:21 +00:00

Add (optional) date_modified field and use vw_whitelist view in vw_blacklist

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2019-04-28 14:42:52 +02:00
parent b4ae142149
commit 126f7101ff
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD
2 changed files with 11 additions and 12 deletions

View File

@ -186,9 +186,9 @@ Displaylist() {
num_pipes="$(grep -c "^" <<< "$(grep -o "|" <<< "${line}")")" num_pipes="$(grep -c "^" <<< "$(grep -o "|" <<< "${line}")")"
# Extract domain and enabled status based on the obtained number of pipe characters # Extract domain and enabled status based on the obtained number of pipe characters
domain="$(cut -d'|' -f"-$((num_pipes-2))" <<< "${line}")" domain="$(cut -d'|' -f"-$((num_pipes-3))" <<< "${line}")"
enabled="$(cut -d'|' -f"$((num_pipes-1))" <<< "${line}")" enabled="$(cut -d'|' -f"$((num_pipes-2))" <<< "${line}")"
dateadded="$(cut -d'|' -f"$((num_pipes))" <<< "${line}")" dateadded="$(cut -d'|' -f"$((num_pipes-1))" <<< "${line}")"
# Translate boolean status into human readable string # Translate boolean status into human readable string
if [[ "${enabled}" -eq 1 ]]; then if [[ "${enabled}" -eq 1 ]]; then

View File

@ -1,7 +1,7 @@
CREATE TABLE whitelist (domain TEXT UNIQUE NOT NULL, enabled BOOLEAN NOT NULL DEFAULT 1, date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)), comment TEXT); CREATE TABLE whitelist (domain TEXT UNIQUE NOT NULL, enabled BOOLEAN NOT NULL DEFAULT 1, date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)), date_modified INTEGER, comment TEXT);
CREATE TABLE blacklist (domain TEXT UNIQUE NOT NULL, enabled BOOLEAN NOT NULL DEFAULT 1, date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)), comment TEXT); CREATE TABLE blacklist (domain TEXT UNIQUE NOT NULL, enabled BOOLEAN NOT NULL DEFAULT 1, date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)), date_modified INTEGER, comment TEXT);
CREATE TABLE regex (domain TEXT UNIQUE NOT NULL, enabled BOOLEAN NOT NULL DEFAULT 1, date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)), comment TEXT); CREATE TABLE regex (domain TEXT UNIQUE NOT NULL, enabled BOOLEAN NOT NULL DEFAULT 1, date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)), date_modified INTEGER, comment TEXT);
CREATE TABLE adlists (address TEXT UNIQUE NOT NULL, enabled BOOLEAN NOT NULL DEFAULT 1, date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)), comment TEXT); CREATE TABLE adlists (address TEXT UNIQUE NOT NULL, enabled BOOLEAN NOT NULL DEFAULT 1, date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)), date_modified INTEGER, comment TEXT);
CREATE TABLE gravity (domain TEXT UNIQUE NOT NULL); CREATE TABLE gravity (domain TEXT UNIQUE NOT NULL);
CREATE TABLE info (property TEXT NOT NULL, value TEXT NOT NULL); CREATE TABLE info (property TEXT NOT NULL, value TEXT NOT NULL);
@ -11,15 +11,14 @@ CREATE VIEW vw_gravity AS SELECT DISTINCT a.domain
FROM gravity a FROM gravity a
WHERE a.domain NOT IN (SELECT domain from whitelist WHERE enabled == 1); WHERE a.domain NOT IN (SELECT domain from whitelist WHERE enabled == 1);
CREATE VIEW vw_blacklist AS SELECT DISTINCT a.domain
FROM blacklist a
WHERE a.enabled == 1 AND
a.domain NOT IN (SELECT domain from whitelist WHERE enabled == 1);
CREATE VIEW vw_whitelist AS SELECT DISTINCT a.domain CREATE VIEW vw_whitelist AS SELECT DISTINCT a.domain
FROM whitelist a FROM whitelist a
WHERE a.enabled == 1; WHERE a.enabled == 1;
CREATE VIEW vw_blacklist AS SELECT DISTINCT a.domain
FROM blacklist a
WHERE a.enabled == 1 AND a.domain NOT IN vw_whitelist;
CREATE VIEW vw_regex AS SELECT DISTINCT a.domain CREATE VIEW vw_regex AS SELECT DISTINCT a.domain
FROM regex a FROM regex a
WHERE a.enabled == 1; WHERE a.enabled == 1;