Review comments

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2019-07-09 11:41:44 +02:00
parent 3d3fc2947e
commit 5ff9052200
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD
3 changed files with 11 additions and 8 deletions

View file

@ -11,9 +11,12 @@
# Please see LICENSE file for your rights under this license. # Please see LICENSE file for your rights under this license.
upgrade_gravityDB(){ upgrade_gravityDB(){
local database auditFile version local database piholeDir auditFile version
database="${1}" database="${1}"
auditFile="${2}" piholeDir="${2}"
auditFile="${piholeDir}/auditlog.list"
# Get database version
version="$(sqlite3 "${database}" "SELECT \"value\" FROM \"info\" WHERE \"property\" = 'version';")" version="$(sqlite3 "${database}" "SELECT \"value\" FROM \"info\" WHERE \"property\" = 'version';")"
if [[ "$version" == "1" ]]; then if [[ "$version" == "1" ]]; then

View file

@ -560,8 +560,7 @@ addAudit()
domains="" domains=""
for domain in "$@" for domain in "$@"
do do
# Insert only the domain here. The date_added field will be # Check domain to be added. Only continue if it is valid
# filled with its default value (date_added = current timestamp)
validDomain="$(checkDomain "${domain}")" validDomain="$(checkDomain "${domain}")"
if [[ -n "${validDomain}" ]]; then if [[ -n "${validDomain}" ]]; then
# Put comma in between domains when there is # Put comma in between domains when there is
@ -574,6 +573,8 @@ addAudit()
domains="${domains}('${domain}')" domains="${domains}('${domain}')"
fi fi
done done
# Insert only the domain here. The date_added field will be
# filled with its default value (date_added = current timestamp)
sqlite3 "${gravityDBfile}" "INSERT INTO domain_audit (domain) VALUES ${domains};" sqlite3 "${gravityDBfile}" "INSERT INTO domain_audit (domain) VALUES ${domains};"
} }

View file

@ -30,7 +30,6 @@ whitelistFile="${piholeDir}/whitelist.txt"
blacklistFile="${piholeDir}/blacklist.txt" blacklistFile="${piholeDir}/blacklist.txt"
regexFile="${piholeDir}/regex.list" regexFile="${piholeDir}/regex.list"
adListFile="${piholeDir}/adlists.list" adListFile="${piholeDir}/adlists.list"
auditFile="${piholeDir}/auditlog.list"
localList="${piholeDir}/local.list" localList="${piholeDir}/local.list"
VPNList="/etc/openvpn/ipp.txt" VPNList="/etc/openvpn/ipp.txt"
@ -123,8 +122,8 @@ database_table_from_file() {
do do
# Only add non-empty lines # Only add non-empty lines
if [[ -n "${domain}" ]]; then if [[ -n "${domain}" ]]; then
if [[ "${table}" == "auditlist" ]]; then if [[ "${table}" == "domain_audit" ]]; then
# Auditlist table format # domain_audit table format (no enable or modified fields)
echo "${rowid},\"${domain}\",${timestamp}" >> "${tmpFile}" echo "${rowid},\"${domain}\",${timestamp}" >> "${tmpFile}"
else else
# White-, black-, and regexlist format # White-, black-, and regexlist format
@ -188,7 +187,7 @@ migrate_to_database() {
fi fi
# Check if gravity database needs to be updated # Check if gravity database needs to be updated
upgrade_gravityDB "${gravityDBfile}" "${auditFile}" upgrade_gravityDB "${gravityDBfile}" "${piholeDir}"
} }
# Determine if DNS resolution is available before proceeding # Determine if DNS resolution is available before proceeding