Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for v6 and enable if it works #1948

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion ethd
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,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 @@ -1053,6 +1084,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 @@ -1074,6 +1106,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 @@ -1243,6 +1281,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 @@ -1376,7 +1415,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 @@ -3694,6 +3738,8 @@ config() {
__set_value_in_env
fi

__enable_v6

${__as_owner} rm .env.original

__pull_and_build
Expand Down