Working on ipv6 + ipv4

This commit is contained in:
Tommy Huff 2016-10-19 15:10:33 -04:00
parent 3d7d7b80f0
commit acfd56a7b9
3 changed files with 13 additions and 4 deletions

View file

@ -201,7 +201,7 @@ fi
if [[ -n "${IPv6_address}" ]] ; then if [[ -n "${IPv6_address}" ]] ; then
IPv6_address=$(echo "${IPv6_address}" | cut -f1 -d"/") IPv6_address=$(echo "${IPv6_address}" | cut -f1 -d"/")
fi fi
if [[ -n "${IPv6_address}" ]] ; then if [[ -n "${IPv4_address}" ]] ; then
IPv4_address=$(echo "${IPv4_address}" | cut -f1 -d"/") IPv4_address=$(echo "${IPv4_address}" | cut -f1 -d"/")
fi fi

View file

@ -213,7 +213,7 @@ fi
if [[ -n "${IPv6_address}" ]] ; then if [[ -n "${IPv6_address}" ]] ; then
IPv6_address=$(echo "${IPv6_address}" | cut -f1 -d"/") IPv6_address=$(echo "${IPv6_address}" | cut -f1 -d"/")
fi fi
if [[ -n "${IPv6_address}" ]] ; then if [[ -n "${IPv4_address}" ]] ; then
IPv4_address=$(echo "${IPv4_address}" | cut -f1 -d"/") IPv4_address=$(echo "${IPv4_address}" | cut -f1 -d"/")
fi fi

View file

@ -215,11 +215,11 @@ gravity_hostFormat() {
fi fi
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin) # Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
if [[ -n "${IPv6_address}" ]] ; then if [[ -n "${IPv6_address}" ]] ; then
echo -e "${IPv6_address} $hostname\n${IPv6_address} pi.hole" > ${piholeDir}/${accretionDisc} echo -e "${IPv6_address} $hostname\n${IPv6_address} pi.hole" >> ${piholeDir}/${accretionDisc}
cat ${piholeDir}/${eventHorizon} | awk -v ipv6addr="${IPv6_address}" '{sub(/\r$/,""); print ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc} cat ${piholeDir}/${eventHorizon} | awk -v ipv6addr="${IPv6_address}" '{sub(/\r$/,""); print ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
fi fi
if [[ -n "${IPv4_address}" ]] ; then if [[ -n "${IPv4_address}" ]] ; then
echo -e "${IPv4_address} $hostname\n${IPv4_address} pi.hole" > ${piholeDir}/${accretionDisc} echo -e "${IPv4_address} $hostname\n${IPv4_address} pi.hole" >> ${piholeDir}/${accretionDisc}
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="${IPv4_address}" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc} cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="${IPv4_address}" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
fi fi
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
@ -323,6 +323,15 @@ if [[ -r ${piholeDir}/pihole.conf ]];then
echo "::: pihole.conf file no longer supported. Over-rides in this file are ignored." echo "::: pihole.conf file no longer supported. Over-rides in this file are ignored."
fi fi
#remove CIDR from IPs
if [[ -n "${IPv6_address}" ]] ; then
IPv6_address=$(echo "${IPv6_address}" | cut -f1 -d"/")
fi
if [[ -n "${IPv4_address}" ]] ; then
IPv4_address=$(echo "${IPv4_address}" | cut -f1 -d"/")
fi
if [[ ${forceGrav} == true ]]; then if [[ ${forceGrav} == true ]]; then
echo -n "::: Deleting exising list cache..." echo -n "::: Deleting exising list cache..."
for f in ${piholeDir}/list.* ; do for f in ${piholeDir}/list.* ; do