mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-09 09:21:03 +01:00
Invert openvpn_alt_mode binding behavior
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
## 5.1.2-24 (30-11-2025)
|
||||
- Reverse `openvpn_alt_mode`: enabled now binds only qBittorrent to the VPN interface; default keeps container-wide binding for OpenVPN and WireGuard.
|
||||
|
||||
## 5.1.2-23 (29-11-2025)
|
||||
- Default VPN container binding for OpenVPN and WireGuard with optional qBittorrent-only interface binding.
|
||||
|
||||
|
||||
@@ -77,14 +77,14 @@ Network disk is mounted to `/mnt/<share_name>`. You need to map the exposed port
|
||||
| `openvpn_config` | str | | OpenVPN config file name (in `/config/openvpn/`) |
|
||||
| `openvpn_username` | str | | OpenVPN username |
|
||||
| `openvpn_password` | str | | OpenVPN password |
|
||||
| `openvpn_alt_mode` | bool | `true` | Container binding for VPN traffic (disable to bind qBittorrent only) |
|
||||
| `openvpn_alt_mode` | bool | `false` | Bind only qBittorrent to the VPN interface (leave disabled for container-wide binding) |
|
||||
| `wireguard_enabled` | bool | `false` | Enable WireGuard tunnel |
|
||||
| `wireguard_config` | str | _(empty)_ | WireGuard config file name (in `/config/wireguard/`) |
|
||||
| `qbit_manage` | bool | `false` | Enable qBit Manage integration |
|
||||
| `run_duration` | str | | Run duration (e.g., `12h`, `5d`) |
|
||||
| `silent` | bool | `false` | Suppress debug messages |
|
||||
|
||||
By default, VPN traffic is container-bound (OpenVPN and WireGuard). Disable `openvpn_alt_mode` only if you prefer binding qBittorrent itself to the VPN interface while exposing the rest of the container on the host network.
|
||||
By default, VPN traffic is container-bound (OpenVPN and WireGuard). Enable `openvpn_alt_mode` only if you prefer binding qBittorrent itself to the VPN interface while exposing the rest of the container on the host network.
|
||||
|
||||
### WireGuard Setup
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ options:
|
||||
certfile: fullchain.pem
|
||||
customUI: vuetorrent
|
||||
keyfile: privkey.pem
|
||||
openvpn_alt_mode: true
|
||||
openvpn_alt_mode: false
|
||||
openvpn_config: ""
|
||||
openvpn_enabled: false
|
||||
openvpn_password: ""
|
||||
@@ -150,4 +150,4 @@ schema:
|
||||
slug: qbittorrent
|
||||
udev: true
|
||||
url: https://github.com/alexbelgium/hassio-addons
|
||||
version: 5.1.2-23
|
||||
version: 5.1.2-24
|
||||
|
||||
@@ -197,58 +197,58 @@ if bashio::config.true 'openvpn_enabled'; then
|
||||
# CONFIGURE QBITTORRENT #
|
||||
#########################
|
||||
|
||||
# WITH CONTAINER BINDING
|
||||
# WITH INTERFACE BINDING
|
||||
#########################
|
||||
# If alternative mode enabled, bind container
|
||||
# If alternative mode enabled, bind only the app
|
||||
if bashio::config.true 'openvpn_alt_mode'; then
|
||||
echo "Using container binding"
|
||||
echo "Using interface binding in the qBittorrent app"
|
||||
|
||||
# Remove interface
|
||||
echo "... deleting previous interface settings"
|
||||
sed -i '/Interface/d' "$QBT_CONFIG_FILE"
|
||||
# Define preferences line
|
||||
cd /config/qBittorrent/ || exit 1
|
||||
|
||||
# If qBittorrent.conf exists
|
||||
if [ -f "$QBT_CONFIG_FILE" ]; then
|
||||
# Remove previous line and bind tun0
|
||||
echo "... deleting previous interface settings"
|
||||
sed -i '/Interface/d' "$QBT_CONFIG_FILE"
|
||||
|
||||
# Bind tun0
|
||||
echo "... binding tun0 interface in qBittorrent configuration"
|
||||
sed -i "/\[Preferences\]/ i\Connection\\\Interface=tun0" "$QBT_CONFIG_FILE"
|
||||
sed -i "/\[Preferences\]/ i\Connection\\\InterfaceName=tun0" "$QBT_CONFIG_FILE"
|
||||
|
||||
# Add to ongoing session
|
||||
sed -i "/\[BitTorrent\]/a \Session\\\Interface=tun0" "$QBT_CONFIG_FILE"
|
||||
sed -i "/\[BitTorrent\]/a \Session\\\InterfaceName=tun0" "$QBT_CONFIG_FILE"
|
||||
|
||||
else
|
||||
bashio::log.error "qBittorrent config file doesn't exist, openvpn must be added manually to qbittorrent options "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Modify ovpn config
|
||||
if grep -q route-nopull /config/openvpn/"$openvpn_config"; then
|
||||
echo "... removing route-nopull from your config.ovpn"
|
||||
sed -i '/route-nopull/d' /config/openvpn/"$openvpn_config"
|
||||
if ! grep -q route-nopull /config/openvpn/"$openvpn_config"; then
|
||||
echo "... adding route-nopull to your config.ovpn"
|
||||
sed -i "1a route-nopull" /config/openvpn/"$openvpn_config"
|
||||
fi
|
||||
|
||||
# Exit
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# WITH INTERFACE BINDING
|
||||
# WITH CONTAINER BINDING
|
||||
#########################
|
||||
# Connection with interface binding
|
||||
echo "Using interface binding in the qBittorrent app"
|
||||
# Default: bind whole container
|
||||
echo "Using container binding"
|
||||
|
||||
# Define preferences line
|
||||
cd /config/qBittorrent/ || exit 1
|
||||
|
||||
# If qBittorrent.conf exists
|
||||
if [ -f "$QBT_CONFIG_FILE" ]; then
|
||||
# Remove previous line and bind tun0
|
||||
echo "... deleting previous interface settings"
|
||||
sed -i '/Interface/d' "$QBT_CONFIG_FILE"
|
||||
|
||||
# Bind tun0
|
||||
echo "... binding tun0 interface in qBittorrent configuration"
|
||||
sed -i "/\[Preferences\]/ i\Connection\\\Interface=tun0" "$QBT_CONFIG_FILE"
|
||||
sed -i "/\[Preferences\]/ i\Connection\\\InterfaceName=tun0" "$QBT_CONFIG_FILE"
|
||||
|
||||
# Add to ongoing session
|
||||
sed -i "/\[BitTorrent\]/a \Session\\\Interface=tun0" "$QBT_CONFIG_FILE"
|
||||
sed -i "/\[BitTorrent\]/a \Session\\\InterfaceName=tun0" "$QBT_CONFIG_FILE"
|
||||
|
||||
else
|
||||
bashio::log.error "qBittorrent config file doesn't exist, openvpn must be added manually to qbittorrent options "
|
||||
exit 1
|
||||
fi
|
||||
# Remove interface
|
||||
echo "... deleting previous interface settings"
|
||||
sed -i '/Interface/d' "$QBT_CONFIG_FILE"
|
||||
|
||||
# Modify ovpn config
|
||||
if ! grep -q route-nopull /config/openvpn/"$openvpn_config"; then
|
||||
echo "... adding route-nopull to your config.ovpn"
|
||||
sed -i "1a route-nopull" /config/openvpn/"$openvpn_config"
|
||||
if grep -q route-nopull /config/openvpn/"$openvpn_config"; then
|
||||
echo "... removing route-nopull from your config.ovpn"
|
||||
sed -i '/route-nopull/d' /config/openvpn/"$openvpn_config"
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
@@ -63,24 +63,23 @@ echo "${wireguard_runtime_config}" > "${WIREGUARD_STATE_DIR}/config"
|
||||
echo "${interface_name}" > "${WIREGUARD_STATE_DIR}/interface"
|
||||
|
||||
if bashio::config.true 'openvpn_alt_mode'; then
|
||||
bashio::log.info 'Using qBittorrent interface binding for WireGuard.'
|
||||
if bashio::fs.file_exists "${QBT_CONFIG_FILE}"; then
|
||||
sed -i '/Interface/d' "${QBT_CONFIG_FILE}"
|
||||
sed -i "/\\[Preferences\\]/ i\\Connection\\\\Interface=${interface_name}" "${QBT_CONFIG_FILE}"
|
||||
sed -i "/\\[Preferences\\]/ i\\Connection\\\\InterfaceName=${interface_name}" "${QBT_CONFIG_FILE}"
|
||||
sed -i "/\\[BitTorrent\\]/a \\Session\\\\Interface=${interface_name}" "${QBT_CONFIG_FILE}"
|
||||
sed -i "/\\[BitTorrent\\]/a \\Session\\\\InterfaceName=${interface_name}" "${QBT_CONFIG_FILE}"
|
||||
else
|
||||
bashio::log.warning "qBittorrent config file not found. Bind the client manually to interface ${interface_name}."
|
||||
fi
|
||||
else
|
||||
bashio::log.info 'Using container-wide WireGuard binding (default).'
|
||||
if bashio::fs.file_exists "${QBT_CONFIG_FILE}"; then
|
||||
sed -i '/Interface/d' "${QBT_CONFIG_FILE}"
|
||||
else
|
||||
bashio::log.warning 'qBittorrent config file not found. Unable to remove interface binding entries.'
|
||||
fi
|
||||
bashio::log.info "WireGuard prepared with interface ${interface_name} using configuration ${wireguard_config##*/}."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if bashio::fs.file_exists "${QBT_CONFIG_FILE}"; then
|
||||
sed -i '/Interface/d' "${QBT_CONFIG_FILE}"
|
||||
sed -i "/\\[Preferences\\]/ i\\Connection\\\\Interface=${interface_name}" "${QBT_CONFIG_FILE}"
|
||||
sed -i "/\\[Preferences\\]/ i\\Connection\\\\InterfaceName=${interface_name}" "${QBT_CONFIG_FILE}"
|
||||
sed -i "/\\[BitTorrent\\]/a \\Session\\\\Interface=${interface_name}" "${QBT_CONFIG_FILE}"
|
||||
sed -i "/\\[BitTorrent\\]/a \\Session\\\\InterfaceName=${interface_name}" "${QBT_CONFIG_FILE}"
|
||||
else
|
||||
bashio::log.warning "qBittorrent config file not found. Bind the client manually to interface ${interface_name}."
|
||||
fi
|
||||
|
||||
bashio::log.info "WireGuard prepared with interface ${interface_name} using configuration ${wireguard_config##*/}."
|
||||
|
||||
@@ -133,7 +133,7 @@ if bashio::config.true 'wireguard_enabled'; then
|
||||
vpn_wireguard=true
|
||||
fi
|
||||
|
||||
if ! bashio::config.true 'openvpn_alt_mode'; then
|
||||
if bashio::config.true 'openvpn_alt_mode'; then
|
||||
if [[ "${vpn_openvpn}" == true ]]; then
|
||||
VPN_INTERFACE="tun0"
|
||||
bashio::log.info "VPN monitor set to query external IP through interface ${VPN_INTERFACE} (interface binding)."
|
||||
|
||||
Reference in New Issue
Block a user