Merge pull request #689 from jparenas/cache_size
Add CACHE_SIZE environment variable to the available options
This commit is contained in:
commit
99de0dce83
|
@ -109,6 +109,7 @@ There are other environment variables if you want to customize various things in
|
|||
| `INTERFACE: <NIC>`<br/> *Advanced/Optional* | The default works fine with our basic example docker run commands. If you're trying to use DHCP with `--net host` mode then you may have to customize this or DNSMASQ_LISTENING.
|
||||
| `DNSMASQ_LISTENING: <local\|all\|single>`<br/> *Advanced/Optional* | `local` listens on all local subnets, `all` permits listening on internet origin subnets in addition to local, `single` listens only on the interface specified.
|
||||
| `WEB_PORT: <PORT>`<br/> *Advanced/Optional* | **This will break the 'webpage blocked' functionality of Pi-hole** however it may help advanced setups like those running synology or `--net=host` docker argument. This guide explains how to restore webpage blocked functionality using a linux router DNAT rule: [Alternative Synology installation method](https://discourse.pi-hole.net/t/alternative-synology-installation-method/5454?u=diginc)
|
||||
| `CUSTOM_CACHE_SIZE: <size>`<br/> *Advanced/Optional: Default: '10000'* | Set the cache size for dnsmasq. Useful for increasing the default cache size or to set it to 0. Note that when `DNSSEC` is "true", then this setting is ignored.
|
||||
| `DNSMASQ_USER: <pihole\|root>`<br/> *Experimental Default: root* | Allows running FTLDNS as non-root.
|
||||
| `TEMPERATUREUNIT`: <c\|k\|f><br/>*Optional Default: c* | Set preferred temperature unit to `c`: Celsius, `k`: Kelvin, or `f` Fahrenheit units.
|
||||
| `WEBUIBOXEDLAYOUT: <boxed\|traditional>`<br/>*Optional Default: boxed* | Use boxed layout (helpful when working on large screens)
|
||||
|
|
|
@ -103,6 +103,7 @@ setup_dnsmasq() {
|
|||
setup_dnsmasq_interface "$interface"
|
||||
setup_dnsmasq_listening_behaviour "$dnsmasq_listening_behaviour"
|
||||
setup_dnsmasq_user "${DNSMASQ_USER}"
|
||||
setup_cache_size "${CUSTOM_CACHE_SIZE}"
|
||||
ProcessDNSSettings
|
||||
}
|
||||
|
||||
|
@ -157,6 +158,32 @@ setup_dnsmasq_hostnames() {
|
|||
fi
|
||||
}
|
||||
|
||||
setup_cache_size() {
|
||||
local warning="WARNING: CUSTOM_CACHE_SIZE not used"
|
||||
local dnsmasq_pihole_01_location="/etc/dnsmasq.d/01-pihole.conf"
|
||||
# Quietly exit early for empty or default
|
||||
if [[ -z "${1}" || "${1}" == '10000' ]] ; then return ; fi
|
||||
|
||||
if [[ "${DNSSEC}" == "true" ]] ; then
|
||||
echo "$warning - Cannot change cache size if DNSSEC is enabled"
|
||||
return
|
||||
fi
|
||||
|
||||
if ! echo $1 | grep -q '^[0-9]*$' ; then
|
||||
echo "$warning - $1 is not an integer"
|
||||
return
|
||||
fi
|
||||
|
||||
local -i custom_cache_size="$1"
|
||||
if (( $custom_cache_size < 0 )); then
|
||||
echo "$warning - $custom_cache_size is not a positive integer or zero"
|
||||
return
|
||||
fi
|
||||
echo "Custom CUSTOM_CACHE_SIZE set to $custom_cache_size"
|
||||
|
||||
sed -i "s/^cache-size=\s*[0-9]*/cache-size=$custom_cache_size/" ${dnsmasq_pihole_01_location}
|
||||
}
|
||||
|
||||
setup_lighttpd_bind() {
|
||||
local serverip="$1"
|
||||
# if using '--net=host' only bind lighttpd on $ServerIP and localhost
|
||||
|
|
1
start.sh
1
start.sh
|
@ -38,6 +38,7 @@ export DHCP_LEASETIME
|
|||
export PIHOLE_DOMAIN
|
||||
export DHCP_IPv6
|
||||
export DHCP_rapid_commit
|
||||
export CUSTOM_CACHE_SIZE
|
||||
|
||||
export adlistFile='/etc/pihole/adlists.list'
|
||||
|
||||
|
|
|
@ -48,6 +48,39 @@ def test_bad_input_to_WEB_PORT(Docker, test_args, expected_error):
|
|||
assert expected_error in function.stdout
|
||||
|
||||
|
||||
@pytest.mark.parametrize('test_args,cache_size', [('-e CUSTOM_CACHE_SIZE="0"', '0'), ('-e CUSTOM_CACHE_SIZE="20000"', '20000')])
|
||||
def test_overrides_default_CUSTOM_CACHE_SIZE(Docker, Slow, test_args, cache_size):
|
||||
''' Changes the cache_size setting to increase or decrease the cache size for dnsmasq'''
|
||||
CONFIG_LINE = r'cache-size\s*=\s*{}'.format(cache_size)
|
||||
DNSMASQ_CONFIG = '/etc/dnsmasq.d/01-pihole.conf'
|
||||
|
||||
function = Docker.run('echo ${CUSTOM_CACHE_SIZE};. ./bash_functions.sh; echo ${CUSTOM_CACHE_SIZE}; eval `grep setup_dnsmasq /start.sh`')
|
||||
assert "Custom CUSTOM_CACHE_SIZE set to {}".format(cache_size) in function.stdout
|
||||
Slow(lambda: re.search(CONFIG_LINE, Docker.run('cat {}'.format(DNSMASQ_CONFIG)).stdout) != None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('test_args', [
|
||||
'-e CUSTOM_CACHE_SIZE="-1"',
|
||||
'-e CUSTOM_CACHE_SIZE="1,000"',
|
||||
])
|
||||
def test_bad_input_to_CUSTOM_CACHE_SIZE(Docker, Slow, test_args):
|
||||
CONFIG_LINE = r'cache-size\s*=\s*10000'
|
||||
DNSMASQ_CONFIG = '/etc/dnsmasq.d/01-pihole.conf'
|
||||
|
||||
Docker.run('. ./bash_functions.sh; eval `grep setup_dnsmasq /start.sh`')
|
||||
Slow(lambda: re.search(CONFIG_LINE, Docker.run('cat {}'.format(DNSMASQ_CONFIG)).stdout) != None)
|
||||
|
||||
@pytest.mark.parametrize('test_args', [
|
||||
'-e DNSSEC="true" -e CUSTOM_CACHE_SIZE="0"',
|
||||
])
|
||||
def test_dnssec_enabled_with_CUSTOM_CACHE_SIZE(Docker, Slow, test_args):
|
||||
CONFIG_LINE = r'cache-size\s*=\s*10000'
|
||||
DNSMASQ_CONFIG = '/etc/dnsmasq.d/01-pihole.conf'
|
||||
|
||||
Docker.run('. ./bash_functions.sh; eval `grep setup_dnsmasq /start.sh`')
|
||||
Slow(lambda: re.search(CONFIG_LINE, Docker.run('cat {}'.format(DNSMASQ_CONFIG)).stdout) != None)
|
||||
|
||||
|
||||
# DNS Environment Variable behavior in combinations of modified pihole LTE settings
|
||||
@pytest.mark.skip('broke, needs investigation in v5.0 beta')
|
||||
@pytest.mark.parametrize('args_env, expected_stdout, dns1, dns2', [
|
||||
|
|
Loading…
Reference in New Issue