Skip to content

Commit

Permalink
Improve/cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
erwin-willems committed Apr 10, 2024
1 parent 7fa19e9 commit cf2ac27
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions adguard/rootfs/etc/s6-overlay/s6-rc.d/init-adguard/run
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ readonly CONFIG="/data/adguard/AdGuardHome.yaml"
declare schema_version
declare -a interfaces
declare -a hosts
declare -a hosts_v4
declare -a hosts_v6
declare part
declare fd
declare a2
Expand Down Expand Up @@ -54,13 +52,15 @@ fi
# Collect IP addresses from interfaces
interfaces+=($(bashio::network.interfaces))
for interface in "${interfaces[@]}"; do
hosts_v4+=($(bashio::network.ipv4_address "${interface}"))
hosts_v6+=($(bashio::network.ipv6_address "${interface}"))
# Remove the netmask (for example /24) from the address
for host in "${hosts_v4[@]}"; do

# IPv4 addresses on the interface
for host in $(bashio::network.ipv4_address "${interface}"); do
# Remove the netmask (for example /24) from the address
hosts+=("${host%/*}")
done
for host in "${hosts_v6[@]}"; do

# IPv6 addresses on the interface
for host in $(bashio::network.ipv6_address "${interface}"); do
part="${host%%:*}"
# The decimal values for 0xfd & 0xa2
fd=$(( (0x$part) / 256 ))
Expand All @@ -73,6 +73,7 @@ for interface in "${interfaces[@]}"; do
hosts+=("${host%/*}")
fi
done

done
# Bind to addon ip address
hosts+=($(bashio::addon.ip_address))
Expand Down

0 comments on commit cf2ac27

Please sign in to comment.