Skip to content

Commit ffcccd1

Browse files
authored
Fix IPv6 access
1 parent 53aea84 commit ffcccd1

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

addons/coturn/detect_external_ip.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# limitations under the License.
2323

2424
if [ -z "${TURN_EXTERNAL_IP}" ]; then
25-
export TURN_EXTERNAL_IP="$(dig TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z "$output" ] || echo "$output" | grep -q '^;;'; then exit 1; else echo "$(echo $output | sed 's,\",,g')"; fi } || dig -6 TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z "$output" ] || echo "$output" | grep -q '^;;'; then exit 1; else echo "$(echo $output | sed 's,\",,g')"; fi } || hostname -I 2>/dev/null | awk '{print $1; exit}' || echo '127.0.0.1')"
25+
export TURN_EXTERNAL_IP="$(dig -4 TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z "$output" ] || echo "$output" | grep -q '^;;'; then exit 1; else echo "$(echo $output | sed 's,\",,g')"; fi } || dig -6 TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z "$output" ] || echo "$output" | grep -q '^;;'; then exit 1; else echo "[$(echo $output | sed 's,\",,g')]"; fi } || hostname -I 2>/dev/null | awk '{print $1; exit}' || echo '127.0.0.1')"
2626
fi
2727
2828
echo "${TURN_EXTERNAL_IP}"

addons/coturn/entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ turnserver \
3737
--aux-server="0.0.0.0:${TURN_ALT_PORT:-8443}" \
3838
--aux-server="[::]:${TURN_ALT_PORT:-8443}" \
3939
--realm="${TURN_REALM:-example.com}" \
40-
--external-ip="${TURN_EXTERNAL_IP:-$(dig TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z "$output" ] || echo "$output" | grep -q '^;;'; then exit 1; else echo "$(echo $output | sed 's,\",,g')"; fi } || dig -6 TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z "$output" ] || echo "$output" | grep -q '^;;'; then exit 1; else echo "$(echo $output | sed 's,\",,g')"; fi } || hostname -I 2>/dev/null | awk '{print $1; exit}' || echo '127.0.0.1')}" \
40+
--external-ip="${TURN_EXTERNAL_IP:-$(dig -4 TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z "$output" ] || echo "$output" | grep -q '^;;'; then exit 1; else echo "$(echo $output | sed 's,\",,g')"; fi } || dig -6 TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z "$output" ] || echo "$output" | grep -q '^;;'; then exit 1; else echo "[$(echo $output | sed 's,\",,g')]"; fi } || hostname -I 2>/dev/null | awk '{print $1; exit}' || echo '127.0.0.1')}" \
4141
--min-port="${TURN_MIN_PORT:-49152}" \
4242
--max-port="${TURN_MAX_PORT:-65535}" \
4343
--channel-lifetime="${TURN_CHANNEL_LIFETIME:--1}" \

addons/example/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ turnserver \
277277
--listening-ip=\"::\" \
278278
--listening-port=\"\${SELKIES_TURN_PORT:-3478}\" \
279279
--realm=\"\${TURN_REALM:-example.com}\" \
280-
--external-ip=\"\${TURN_EXTERNAL_IP:-\$(dig TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z \"\$output\" ] || echo \"\$output\" | grep -q '^;;'; then exit 1; else echo \"\$(echo \$output | sed 's,\\\",,g')\"; fi } || dig -6 TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z \"\$output\" ] || echo \"\$output\" | grep -q '^;;'; then exit 1; else echo \"\$(echo \$output | sed 's,\\\",,g')\"; fi } || hostname -I 2>/dev/null | awk '{print \$1; exit}' || echo '127.0.0.1')}\" \
280+
--external-ip=\"\${TURN_EXTERNAL_IP:-\$(dig -4 TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z \"\$output\" ] || echo \"\$output\" | grep -q '^;;'; then exit 1; else echo \"\$(echo \$output | sed 's,\\\",,g')\"; fi } || dig -6 TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z \"\$output\" ] || echo \"\$output\" | grep -q '^;;'; then exit 1; else echo \"[\$(echo \$output | sed 's,\\\",,g')]\"; fi } || hostname -I 2>/dev/null | awk '{print \$1; exit}' || echo '127.0.0.1')}\" \
281281
--min-port=\"\${TURN_MIN_PORT:-49152}\" \
282282
--max-port=\"\${TURN_MAX_PORT:-65535}\" \
283283
--channel-lifetime=\"\${TURN_CHANNEL_LIFETIME:--1}\" \

addons/example/selkies-gstreamer-entrypoint.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export SELKIES_ENCODER="${SELKIES_ENCODER:-x264enc}"
3434
export SELKIES_ENABLE_RESIZE="${SELKIES_ENABLE_RESIZE:-false}"
3535
if [ -z "${SELKIES_TURN_REST_URI}" ] && { { [ -z "${SELKIES_TURN_USERNAME}" ] || [ -z "${SELKIES_TURN_PASSWORD}" ]; } && [ -z "${SELKIES_TURN_SHARED_SECRET}" ] || [ -z "${SELKIES_TURN_HOST}" ] || [ -z "${SELKIES_TURN_PORT}" ]; }; then
3636
export TURN_RANDOM_PASSWORD="$(tr -dc 'A-Za-z0-9' < /dev/urandom 2>/dev/null | head -c 24)"
37-
export SELKIES_TURN_HOST="${SELKIES_TURN_HOST:-$(dig TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z "$output" ] || echo "$output" | grep -q '^;;'; then exit 1; else echo "$(echo $output | sed 's,\",,g')"; fi } || dig -6 TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z "$output" ] || echo "$output" | grep -q '^;;'; then exit 1; else echo "$(echo $output | sed 's,\",,g')"; fi } || hostname -I 2>/dev/null | awk '{print $1; exit}' || echo '127.0.0.1')}"
38-
export TURN_EXTERNAL_IP="${TURN_EXTERNAL_IP:-$(getent ahosts ${SELKIES_TURN_HOST} | awk '{print $1; exit}')}"
37+
export SELKIES_TURN_HOST="${SELKIES_TURN_HOST:-$(dig -4 TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z "$output" ] || echo "$output" | grep -q '^;;'; then exit 1; else echo "$(echo $output | sed 's,\",,g')"; fi } || dig -6 TXT +short @ns1.google.com o-o.myaddr.l.google.com 2>/dev/null | { read output; if [ -z "$output" ] || echo "$output" | grep -q '^;;'; then exit 1; else echo "[$(echo $output | sed 's,\",,g')]"; fi } || hostname -I 2>/dev/null | awk '{print $1; exit}' || echo '127.0.0.1')}"
38+
export TURN_EXTERNAL_IP="${TURN_EXTERNAL_IP:-$(getent ahostsv4 $(echo ${SELKIES_TURN_HOST} | tr -d '[]') 2>/dev/null | awk '{print $1; exit}' || getent ahostsv6 $(echo ${SELKIES_TURN_HOST} | tr -d '[]') 2>/dev/null | awk '{print "[" $1 "]"; exit}')}"
3939
export SELKIES_TURN_PORT="${SELKIES_TURN_PORT:-3478}"
4040
export SELKIES_TURN_USERNAME="selkies"
4141
export SELKIES_TURN_PASSWORD="${TURN_RANDOM_PASSWORD}"

docs/component.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Port 3478 and 65534-65535 (change the ports accordingly) are the ports for the i
229229

230230
If UDP cannot be used, at the cost of higher latency and lower performance, omit the ports containing `/udp` and use the environment variable `-e SELKIES_TURN_PROTOCOL=tcp`.
231231

232-
All these ports must be exposed to the internet if you need access over the internet. If you need use TURN within a local network, add `-e SELKIES_TURN_HOST=[YOUR_INTERNAL_IP]` with `YOUR_INTERNAL_IP` to the internal hostname or IP of the local network.
232+
All these ports must be exposed to the internet if you need access over the internet. If you need use TURN within a local network, add `-e SELKIES_TURN_HOST={YOUR_INTERNAL_IP}` with `{YOUR_INTERNAL_IP}` to the internal hostname or IP of the local network. IPv6 addresses must be enclosed with square brackets such as `[::1]`.
233233

234234
Otherwise, to enable host networking, add `--network=host` to the Docker® command to enable host networking and work around this requirement if your server is not behind a firewall. Note that running multiple desktop containers in one host under this configuration may be problematic and is not recommended. You must also pass a new `DISPLAY` environment variable such as `-e DISPLAY=:22` into the container, that is not used with any other X11 server or container in the same host.
235235

docs/faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Also check if the WebRTC video codec is supported in the web browser, as the ser
1515

1616
Moreover, if using HTTP but not HTTPS on a remote host that is not `localhost`, use port forwarding to `localhost` as much as possible. Many browsers do not support WebRTC or relevant features including pointer and keyboard lock in HTTP outside localhost.
1717

18-
If you created the TURN server or the example container inside a VPN-enabled environment or virtual machine and the WebRTC connection fails, then you may need to add the `SELKIES_TURN_HOST` environment variable to the private VPN IP of the TURN server host, such as `192.168.0.2`.
18+
If you created the TURN server or the example container inside a VPN-enabled environment or virtual machine and the WebRTC connection fails, then you may need to add the `SELKIES_TURN_HOST` environment variable to the private VPN IP of the TURN server host, such as `192.168.0.2` (IPv4) or `[fe80::2]` (IPv6, including the square brackets).
1919

2020
Make sure to also check that you enabled automatic login with your display manager, as the remote desktop cannot access the initial login screen after boot without login.
2121

src/selkies_gstreamer/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def main():
369369
parser.add_argument('--turn_host',
370370
default=os.environ.get(
371371
'SELKIES_TURN_HOST', 'staticauth.openrelay.metered.ca'),
372-
help='TURN host when generating RTC config from shared secret or using long-term credentials')
372+
help='TURN host when generating RTC config from shared secret or using long-term credentials, IPv6 addresses must be enclosed with square brackets such as [::1]')
373373
parser.add_argument('--turn_port',
374374
default=os.environ.get(
375375
'SELKIES_TURN_PORT', '443'),

0 commit comments

Comments
 (0)