mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-10-19 14:30:11 +02:00
Compare commits
8 Commits
6e635c3a76
...
51fd1a7404
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51fd1a7404 | ||
|
|
f93085cb8b | ||
|
|
9aa8bf2664 | ||
|
|
62669745e8 | ||
|
|
50388590cd | ||
|
|
c305cd34c7 | ||
|
|
49586fc243 | ||
|
|
8aa7ce13ce |
@@ -1,3 +1,5 @@
|
||||
## 5.1.2-22 (24-11-2025)
|
||||
- Minor bugs fixed
|
||||
## 5.1.2-21 (24-11-2025)
|
||||
- Cycle through ip providers to avoid rate limiting api
|
||||
- Simplify vpn leakage verification script
|
||||
|
||||
@@ -145,4 +145,4 @@ schema:
|
||||
slug: qbittorrent
|
||||
udev: true
|
||||
url: https://github.com/alexbelgium/hassio-addons
|
||||
version: 5.1.2-21
|
||||
version: 5.1.2-22
|
||||
|
||||
@@ -2,18 +2,37 @@
|
||||
# shellcheck shell=bash
|
||||
set -euo pipefail
|
||||
|
||||
vpn_openvpn=false
|
||||
vpn_wireguard=false
|
||||
|
||||
if bashio::config.true 'openvpn_enabled'; then
|
||||
vpn_openvpn=true
|
||||
fi
|
||||
|
||||
if bashio::config.true 'wireguard_enabled'; then
|
||||
vpn_wireguard=true
|
||||
fi
|
||||
|
||||
if [[ "${vpn_openvpn}" != true && "${vpn_wireguard}" != true ]]; then
|
||||
if ! bashio::config.true 'openvpn_enabled' && ! bashio::config.true 'wireguard_enabled'; then
|
||||
# No VPN enabled: remove monitoring service to avoid unnecessary restarts
|
||||
rm -rf /etc/services.d/vpn-monitor
|
||||
exit 0
|
||||
fi
|
||||
|
||||
_fetch_public_ip() {
|
||||
local resp
|
||||
local url
|
||||
local urls=(
|
||||
"https://icanhazip.com"
|
||||
"https://ifconfig.me/ip"
|
||||
"https://api64.ipify.org"
|
||||
"https://checkip.amazonaws.com"
|
||||
"https://domains.google.com/checkip"
|
||||
"https://ipinfo.io/ip"
|
||||
)
|
||||
local shuffled_urls
|
||||
mapfile -t shuffled_urls < <(printf "%s\n" "${urls[@]}" | shuf)
|
||||
# Loop through the now-randomized list
|
||||
for url in "${shuffled_urls[@]}"; do
|
||||
resp=$(curl -fsS --max-time 5 "${url}" 2>/dev/null || true)
|
||||
resp="${resp//[[:space:]]/}"
|
||||
|
||||
# Validate IPv4 or IPv6
|
||||
if [[ "${resp}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || [[ "${resp}" =~ ^[0-9a-fA-F:]+$ ]]; then
|
||||
printf '%s\n' "${resp}"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "$(_fetch_public_ip || true)" > /currentip
|
||||
|
||||
@@ -10,35 +10,6 @@ if bashio::config.true 'silent'; then
|
||||
sed -i 's|/proc/1/fd/1 hassio;|off;|g' /etc/nginx/nginx.conf
|
||||
fi
|
||||
|
||||
# --- Helper Functions ---
|
||||
|
||||
_fetch_public_ip() {
|
||||
local resp
|
||||
local url
|
||||
local urls=(
|
||||
"https://icanhazip.com"
|
||||
"https://ifconfig.me/ip"
|
||||
"https://api64.ipify.org"
|
||||
"https://checkip.amazonaws.com"
|
||||
"https://domains.google.com/checkip"
|
||||
"https://ipinfo.io/ip"
|
||||
)
|
||||
local shuffled_urls
|
||||
mapfile -t shuffled_urls < <(printf "%s\n" "${urls[@]}" | shuf)
|
||||
# Loop through the now-randomized list
|
||||
for url in "${shuffled_urls[@]}"; do
|
||||
resp=$(curl -fsS --max-time 5 "${url}" 2>/dev/null || true)
|
||||
resp="${resp//[[:space:]]/}"
|
||||
|
||||
# Validate IPv4 or IPv6
|
||||
if [[ "${resp}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || [[ "${resp}" =~ ^[0-9a-fA-F:]+$ ]]; then
|
||||
printf '%s\n' "${resp}"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# --- WireGuard Specific Logic ---
|
||||
|
||||
_setup_wireguard() {
|
||||
@@ -165,8 +136,6 @@ if [[ "${openvpn_enabled}" == true && "${wireguard_enabled}" == true ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$(_fetch_public_ip || true)" > /currentip
|
||||
|
||||
if [[ "${openvpn_enabled}" == true ]]; then
|
||||
|
||||
exec /usr/sbin/openvpn \
|
||||
|
||||
@@ -15,6 +15,7 @@ VPN_INFO_URL="${VPN_INFO_URL:-https://ipinfo.io}"
|
||||
_fetch_public_ip() {
|
||||
local resp
|
||||
local url
|
||||
local curl_iface_opts=()
|
||||
local urls=(
|
||||
"https://icanhazip.com"
|
||||
"https://ifconfig.me/ip"
|
||||
@@ -24,10 +25,15 @@ _fetch_public_ip() {
|
||||
"https://ipinfo.io/ip"
|
||||
)
|
||||
local shuffled_urls
|
||||
|
||||
if [[ -n "${VPN_INTERFACE:-}" ]]; then
|
||||
curl_iface_opts+=(--interface "${VPN_INTERFACE}")
|
||||
fi
|
||||
|
||||
mapfile -t shuffled_urls < <(printf "%s\n" "${urls[@]}" | shuf)
|
||||
|
||||
for url in "${shuffled_urls[@]}"; do
|
||||
resp=$(curl -fsS --max-time 5 "${url}" 2>/dev/null || true)
|
||||
resp=$(curl -fsS --max-time 5 "${curl_iface_opts[@]}" "${url}" 2>/dev/null || true)
|
||||
resp="${resp//[[:space:]]/}"
|
||||
|
||||
if [[ "${resp}" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || [[ "${resp}" =~ ^[0-9a-fA-F:]+$ ]]; then
|
||||
@@ -123,6 +129,13 @@ if bashio::config.true 'openvpn_enabled'; then
|
||||
vpn_openvpn=true
|
||||
fi
|
||||
|
||||
if [[ "${vpn_openvpn}" == true ]] && ! bashio::config.true 'openvpn_alt_mode'; then
|
||||
VPN_INTERFACE="tun0"
|
||||
bashio::log.info "VPN monitor set to query external IP through interface ${VPN_INTERFACE} (interface binding)."
|
||||
else
|
||||
VPN_INTERFACE=""
|
||||
fi
|
||||
|
||||
if bashio::config.true 'wireguard_enabled'; then
|
||||
vpn_wireguard=true
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user