diff --git a/qbittorrent/CHANGELOG.md b/qbittorrent/CHANGELOG.md index e8245d342..1e245990a 100644 --- a/qbittorrent/CHANGELOG.md +++ b/qbittorrent/CHANGELOG.md @@ -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. diff --git a/qbittorrent/README.md b/qbittorrent/README.md index 039f0aa1b..b81de6e57 100644 --- a/qbittorrent/README.md +++ b/qbittorrent/README.md @@ -77,14 +77,14 @@ Network disk is mounted to `/mnt/`. 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 diff --git a/qbittorrent/config.yaml b/qbittorrent/config.yaml index 8232aa34c..9461f367f 100644 --- a/qbittorrent/config.yaml +++ b/qbittorrent/config.yaml @@ -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 diff --git a/qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh b/qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh index d1dff3c77..67ff3f3cb 100755 --- a/qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh +++ b/qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh @@ -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 diff --git a/qbittorrent/rootfs/etc/cont-init.d/94-wireguard.sh b/qbittorrent/rootfs/etc/cont-init.d/94-wireguard.sh index 9a2016cb0..ded89fdf7 100755 --- a/qbittorrent/rootfs/etc/cont-init.d/94-wireguard.sh +++ b/qbittorrent/rootfs/etc/cont-init.d/94-wireguard.sh @@ -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##*/}." diff --git a/qbittorrent/rootfs/etc/services.d/vpn-monitor/run b/qbittorrent/rootfs/etc/services.d/vpn-monitor/run index fa7d7f00a..a93730adb 100755 --- a/qbittorrent/rootfs/etc/services.d/vpn-monitor/run +++ b/qbittorrent/rootfs/etc/services.d/vpn-monitor/run @@ -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)."