mirror of
https://github.com/pi-hole/pi-hole
synced 2024-11-15 12:38:56 +00:00
commit
f7f2895eec
@ -49,11 +49,11 @@ The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashb
|
|||||||
If you want to use your own variables for the gravity script (i.e. storing the files in a different location) and don't want to have to change them every time there is an update to the script, create a file called `/etc/pihole/pihole.conf`. In it, you should add your own variables in a similar fashion as shown below:
|
If you want to use your own variables for the gravity script (i.e. storing the files in a different location) and don't want to have to change them every time there is an update to the script, create a file called `/etc/pihole/pihole.conf`. In it, you should add your own variables in a similar fashion as shown below:
|
||||||
|
|
||||||
```
|
```
|
||||||
origin=/var/run/pihole
|
piholeDir=/var/run/pihole
|
||||||
adList=/etc/dnsmasq.d/adList
|
adList=/etc/dnsmasq.d/adList
|
||||||
```
|
```
|
||||||
|
|
||||||
See [this PR](https://github.com/jacobsalmela/pi-hole/pull/20) for more details.
|
See the [Wiki](https://github.com/jacobsalmela/pi-hole/wiki/Customization) entry for more details.
|
||||||
|
|
||||||
### How It Works
|
### How It Works
|
||||||
A technical and detailed description can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0)!
|
A technical and detailed description can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0)!
|
||||||
|
@ -1,12 +1,47 @@
|
|||||||
|
# If you want dnsmasq to read another file, as well as /etc/hosts, use
|
||||||
|
# this.
|
||||||
addn-hosts=/etc/pihole/gravity.list
|
addn-hosts=/etc/pihole/gravity.list
|
||||||
|
|
||||||
|
# The following two options make you a better netizen, since they
|
||||||
|
# tell dnsmasq to filter out queries which the public DNS cannot
|
||||||
|
# answer, and which load the servers (especially the root servers)
|
||||||
|
# unnecessarily. If you have a dial-on-demand link they also stop
|
||||||
|
# these requests from bringing up the link unnecessarily.
|
||||||
|
|
||||||
|
# Never forward plain names (without a dot or domain part)
|
||||||
domain-needed
|
domain-needed
|
||||||
|
# Never forward addresses in the non-routed address spaces.
|
||||||
bogus-priv
|
bogus-priv
|
||||||
|
|
||||||
|
# If you don't want dnsmasq to read /etc/resolv.conf or any other
|
||||||
|
# file, getting its servers from this file instead (see below), then
|
||||||
|
# uncomment this.
|
||||||
no-resolv
|
no-resolv
|
||||||
|
|
||||||
|
# Add other name servers here, with domain specs if they are for
|
||||||
|
# non-public domains.
|
||||||
server=8.8.8.8
|
server=8.8.8.8
|
||||||
server=8.8.4.4
|
server=8.8.4.4
|
||||||
|
|
||||||
|
# If you want dnsmasq to listen for DHCP and DNS requests only on
|
||||||
|
# specified interfaces (and the loopback) give the name of the
|
||||||
|
# interface (eg eth0) here.
|
||||||
interface=eth0
|
interface=eth0
|
||||||
|
# Or which to listen on by address (remember to include 127.0.0.1 if
|
||||||
|
# you use this.)
|
||||||
listen-address=127.0.0.1
|
listen-address=127.0.0.1
|
||||||
|
|
||||||
|
# Set the cachesize here.
|
||||||
cache-size=10000
|
cache-size=10000
|
||||||
|
|
||||||
|
# For debugging purposes, log each DNS query as it passes through
|
||||||
|
# dnsmasq.
|
||||||
log-queries
|
log-queries
|
||||||
log-facility=/var/log/pihole.log
|
log-facility=/var/log/pihole.log
|
||||||
|
|
||||||
|
# Normally responses which come from /etc/hosts and the DHCP lease
|
||||||
|
# file have Time-To-Live set as zero, which conventionally means
|
||||||
|
# do not cache further. If you are happy to trade lower load on the
|
||||||
|
# server for potentially stale date, you can set a time-to-live (in
|
||||||
|
# seconds) here.
|
||||||
local-ttl=300
|
local-ttl=300
|
||||||
|
22
gravity.sh
22
gravity.sh
@ -14,7 +14,7 @@ else
|
|||||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{print $5}')
|
IPv4dev=$(ip route get 8.8.8.8 | awk '{print $5}')
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}')
|
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}')
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
piholeIP=${piholeIPCIDR%/*}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ad-list sources--one per line in single quotes
|
# Ad-list sources--one per line in single quotes
|
||||||
@ -89,7 +89,7 @@ function gravity_transport() {
|
|||||||
url=$1
|
url=$1
|
||||||
cmd_ext=$2
|
cmd_ext=$2
|
||||||
agent=$3
|
agent=$3
|
||||||
|
|
||||||
# tmp file, so we don't have to store the (long!) lists in RAM
|
# tmp file, so we don't have to store the (long!) lists in RAM
|
||||||
patternBuffer=$(mktemp)
|
patternBuffer=$(mktemp)
|
||||||
heisenbergCompensator=""
|
heisenbergCompensator=""
|
||||||
@ -140,7 +140,7 @@ function gravity_spinup() {
|
|||||||
# Default is a simple request
|
# Default is a simple request
|
||||||
*) cmd_ext=""
|
*) cmd_ext=""
|
||||||
esac
|
esac
|
||||||
gravity_transport $url $cmd_ext $agent
|
gravity_transport $url $cmd_ext $agent
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,14 +151,14 @@ function gravity_Schwarzchild() {
|
|||||||
echo "** Aggregating list of domains..."
|
echo "** Aggregating list of domains..."
|
||||||
truncate -s 0 $piholeDir/$matter
|
truncate -s 0 $piholeDir/$matter
|
||||||
for i in "${activeDomains[@]}"
|
for i in "${activeDomains[@]}"
|
||||||
do
|
do
|
||||||
cat $i |tr -d '\r' >> $piholeDir/$matter
|
cat $i |tr -d '\r' >> $piholeDir/$matter
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pulsar - White/blacklist application
|
# Pulsar - White/blacklist application
|
||||||
function gravity_pulsar() {
|
function gravity_pulsar() {
|
||||||
|
|
||||||
# Append blacklist entries if they exist
|
# Append blacklist entries if they exist
|
||||||
if [[ -r $blacklist ]];then
|
if [[ -r $blacklist ]];then
|
||||||
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l)
|
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l)
|
||||||
@ -178,11 +178,11 @@ function gravity_pulsar() {
|
|||||||
# regexp so it can be parsed out with grep -x
|
# regexp so it can be parsed out with grep -x
|
||||||
awk -F '[# \t]' 'NF>0&&$1!="" {print "^"$1"$"}' $whitelist | sed 's/\./\\./g' > $latentWhitelist
|
awk -F '[# \t]' 'NF>0&&$1!="" {print "^"$1"$"}' $whitelist | sed 's/\./\\./g' > $latentWhitelist
|
||||||
else
|
else
|
||||||
rm $latentWhitelist
|
rm $latentWhitelist >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prevent our sources from being pulled into the hole
|
# Prevent our sources from being pulled into the hole
|
||||||
plural=; [[ "${#sources[@]}" != "1" ]] && plural=s
|
plural=; [[ "${#sources[@]}" != "1" ]] && plural=s
|
||||||
echo "** Whitelisting ${#sources[@]} ad list source${plural}..."
|
echo "** Whitelisting ${#sources[@]} ad list source${plural}..."
|
||||||
for url in ${sources[@]}
|
for url in ${sources[@]}
|
||||||
do
|
do
|
||||||
@ -210,7 +210,7 @@ function gravity_hostFormat() {
|
|||||||
|
|
||||||
# blackbody - remove any remnant files from script processes
|
# blackbody - remove any remnant files from script processes
|
||||||
function gravity_blackbody() {
|
function gravity_blackbody() {
|
||||||
# Loop through list files
|
# Loop through list files
|
||||||
for file in $piholeDir/*.$justDomainsExtension
|
for file in $piholeDir/*.$justDomainsExtension
|
||||||
do
|
do
|
||||||
# If list is in active array then leave it (noop) else rm the list
|
# If list is in active array then leave it (noop) else rm the list
|
||||||
@ -234,14 +234,14 @@ function gravity_advanced() {
|
|||||||
echo "** $numberOf domains being pulled in by gravity..."
|
echo "** $numberOf domains being pulled in by gravity..."
|
||||||
|
|
||||||
gravity_unique
|
gravity_unique
|
||||||
|
|
||||||
sudo kill -HUP $(pidof dnsmasq)
|
sudo kill -s -HUP $(pidof dnsmasq)
|
||||||
}
|
}
|
||||||
|
|
||||||
gravity_collapse
|
gravity_collapse
|
||||||
gravity_spinup
|
gravity_spinup
|
||||||
gravity_Schwarzchild
|
gravity_Schwarzchild
|
||||||
gravity_pulsar
|
gravity_pulsar
|
||||||
gravity_hostFormat
|
|
||||||
gravity_advanced
|
gravity_advanced
|
||||||
|
gravity_hostFormat
|
||||||
gravity_blackbody
|
gravity_blackbody
|
||||||
|
Loading…
Reference in New Issue
Block a user