Skip to content

Commit 6edcf16

Browse files
committed
Fix #12 + update readme
1 parent baec988 commit 6edcf16

File tree

2 files changed

+13
-7
lines changed
  • root/etc/s6-overlay/s6-rc.d/svc-mod-gluetun-sync-port

2 files changed

+13
-7
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ The following env variables can be used to configure the mod (Only `GSP_GTN_API_
100100
| `GSP_SKIP_INIT_CHECKS` | `false` | Set to `true` to disable qbt config checks ("Bypass authentication on localhost", etc). Set to `warning`to see check results but continue anyway.|
101101
| `GSP_MINIMAL_LOGS` | `true` | Set to `false` to enable "Ports did not change." logs. |
102102
| `GSP_INIT_RETRY_WAIT` | `10` (=60s) | Number of retries to connect to qbittorrent's webUI at startup. Each retry takes 6 seconds. Increase to allow a longer wait at startup. |
103-
| `GSP_DEBUG` | `false` | Set to `true` to enable mod's `set -x`.<br>:warning: **FOR DEBUG ONLY.** |
103+
| `GSP_DEBUG` | `false` | Set to `true` to enable mod's `set -x`.<br>:warning: **FOR DEBUG ONLY.**<br>This will show your API key in the logs. |
104104

105105
I was planning on implementing the option to use Gluetun's port forwarding file but since it will be [deprecated in v4](https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/vpn-port-forwarding.md#native-integrations), I won't.
106106

@@ -243,10 +243,14 @@ and you should get this (with your port number) :
243243
```bash
244244
{"port":34981}
245245
```
246+
or something like this if you have multiple ports (you can use `GSP_GTN_PORT_INDEX`) :
247+
```bash
248+
{"ports":[10550,20550,30550]}
249+
```
246250

247251
> If you get `0` it means gluetun's port forwarding is misconfigured.
248252
249-
If you get anything else, then the issue is from your gluetun's configuration, you can get help [on the wiki](https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/vpn-port-forwarding.md) or [open an issue](https://github.com/qdm12/gluetun/issues).
253+
If you get `0` or an error, then the issue is from your gluetun's configuration, you can get help [on the wiki](https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/vpn-port-forwarding.md) or [open an issue](https://github.com/qdm12/gluetun/issues).
250254

251255
**Note :** even with `openvpn` in the URL, this is also valid for wireguard.
252256

root/etc/s6-overlay/s6-rc.d/svc-mod-gluetun-sync-port/run

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,15 @@ get_ports(){
133133
esac
134134
[ "${QBT}" ] && QBT_PORT=$(curl --silent --fail --show-error ${QBT_COOKIES} "${QBITTORRENT}/api/v2/app/preferences" | jq ".listen_port" 2>/dev/null)
135135
[ "${GTN}" ] && {
136-
GTN_PORTS=$(curl --silent --fail --show-error "${GTN_AUTH[@]}" "${GLUETUN}/v1/openvpn/portforwarded" | jq ".port" 2>/dev/null)
137-
if echo "${GTN_PORTS}" | grep -Fq '[' ; then # Handle the case of multiple ports - ex : [10550,20550,30550]
138-
GTN_PORT=$(echo "${GTN_PORTS}" | jq .[${GTN_PORT_INDEX}] 2>/dev/null)
139-
[ "${GTN_PORT}" = "null" ] && log "[ERROR] GSP_GTN_PORT_INDEX (${GSP_GTN_PORT_INDEX:-1}) > Nb of ports ($(( $(echo "${GTN_PORTS}" | grep -c ',') + 1 )))."\
136+
GTN_PORTS=$(curl --silent --fail --show-error "${GTN_AUTH[@]}" "${GLUETUN}/v1/openvpn/portforwarded")
137+
if echo "${GTN_PORTS}" | jq --exit-status 'has("ports")' > /dev/null; then # Handle the case of multiple ports - ex : [10550,20550,30550]
138+
GTN_PORT=$(echo "${GTN_PORTS}" | jq ".ports[${GTN_PORT_INDEX}]" 2>/dev/null)
139+
[ "${GTN_PORT}" = "null" ] && log "[ERROR] GSP_GTN_PORT_INDEX (${GSP_GTN_PORT_INDEX:-1}) > Nb of ports ($(echo "${GTN_PORTS}" | jq '.ports | length'))."\
140140
&& GTN_PORT=0
141+
elif echo "${GTN_PORTS}" | jq --exit-status 'has("port")' > /dev/null; then
142+
GTN_PORT=$(echo "${GTN_PORTS}" | jq '.port' 2>/dev/null)
141143
else
142-
GTN_PORT="${GTN_PORTS}"
144+
GTN_PORT=0
143145
fi
144146
}
145147
}

0 commit comments

Comments
 (0)