Skip to content

Commit

Permalink
Check for v6 and enable if it works (#1948)
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne authored Oct 5, 2024
1 parent 71fc634 commit d1f4fa2
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion ethd
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,37 @@ __lookup_cf_zone() { # Migrates traefik-cf setup to use Zone ID
}


__enable_v6() {
if [ "${__docker_major_version}" -lt 27 ]; then
return
fi

__var="IPV6"
IPV6=$(sed -n -e "s/^${__var}=\(.*\)/\1/p" "${__env_file}" || true)
if [ "${IPV6}" = "true" ]; then
return
fi

echo "Testing IPv6 host connectivity"
if ! ping -c1 2001:4860:4860::8888 >/dev/null; then
return
fi

echo "Testing IPv6 Docker connectivity"
__dodocker network create --ipv6 ip6net_ethd_test
__v6_works=$(__dodocker run --rm --network ip6net_ethd_test busybox sh -c \
"if ping -c1 -6 2001:4860:4860::8888 >/dev/null; then echo true; else echo false; fi")
__dodocker network rm ip6net_ethd_test

if [ "${__v6_works}" = "true" ]; then
echo "Enabling IPv4/6 dual-stack for your Eth Docker setup"
IPV6="true"
__set_value_in_env
__enabled_v6=1
fi
}


__env_migrate() {
if [ ! -f "${__env_file}" ]; then
return 0
Expand Down Expand Up @@ -1055,6 +1086,7 @@ __env_migrate() {
else
echo "Migrating ${__env_file} to version ${__target_ver}"
fi

${__as_owner} cp "${__env_file}" "${__env_file}".source
__during_migrate=1
__migrated=1
Expand All @@ -1076,6 +1108,12 @@ __env_migrate() {
if [ "${__var}" = "COMPOSE_FILE" ]; then
__migrate_compose_file
fi
if [[ "${__source_ver}" -lt "17" && "${__var}" = "IPV6" ]]; then # One-time attempt; remove after Pectra
__enable_v6
if [ "${__enabled_v6}" -eq 1 ]; then
__value="true"
fi
fi
if [ "${__var}" = "CL_QUIC_PORT" ]; then
__cl_port=$(sed -n -e "s/^CL_P2P_PORT=\(.*\)/\1/p" "${__env_file}.source" || true)
if [ -n "${__cl_port}" ] && [ "${__cl_port}" = "${__value}" ]; then
Expand Down Expand Up @@ -1245,6 +1283,7 @@ __pull_and_build() {
# shellcheck disable=SC2120
update() {
__during_update=1
__enabled_v6=0 # Remove after Pectra

if [[ $(${__as_owner} git status --porcelain) ]]; then
__dirty=1
Expand Down Expand Up @@ -1378,7 +1417,12 @@ reset to defaults."
fi
echo
if [ -z "${GITEXITCODE+x}" ] || [ "${GITEXITCODE}" -eq 0 ]; then
echo "An \"$__me up\" command will start using the new images and configuration."
if [ "${__enabled_v6}" -eq 0 ]; then # Remove after Pectra
echo "An \"$__me up\" command will start using the new images and configuration."
else
echo "IPv4/6 dual-stack support has been enabled."
echo "An \"$__me restart\" command will start using the new images and configuration."
fi
else
echo "WARNING"
echo
Expand Down Expand Up @@ -3696,6 +3740,8 @@ config() {
__set_value_in_env
fi

__enable_v6

${__as_owner} rm .env.original

__pull_and_build
Expand Down

0 comments on commit d1f4fa2

Please sign in to comment.