Compare commits

...

8 Commits

Author SHA1 Message Date
github-actions
51fd1a7404 GitHub bot: changelog 2025-11-24 21:21:15 +00:00
Alexandre
f93085cb8b Update qbittorrent version to 5.1.2-22 2025-11-24 22:15:57 +01:00
Alexandre
9aa8bf2664 Merge pull request #2234 from alexbelgium/codex/adapt-vpn-guard-for-openvpn_alt_mode
Handle VPN monitor interface binding
2025-11-24 22:12:16 +01:00
Alexandre
62669745e8 Fix condition for VPN interface binding 2025-11-24 22:12:00 +01:00
Alexandre
50388590cd Handle VPN monitor interface binding 2025-11-24 22:10:17 +01:00
Alexandre
c305cd34c7 Implement public IP fetching in vpn-monitor script
Added a function to fetch and validate public IP addresses from multiple sources.
2025-11-24 22:09:19 +01:00
Alexandre
49586fc243 Remove public IP fetching function from run script
Removed the _fetch_public_ip function and its usage in the run script.
2025-11-24 22:08:56 +01:00
Alexandre
8aa7ce13ce Update 95-vpn-monitor.sh 2025-11-24 22:07:34 +01:00
5 changed files with 48 additions and 45 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 \

View File

@@ -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