From 44e506b3b4c1c3356f3f8c84eafe6b4e41b265e7 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Thu, 24 Feb 2022 11:41:05 -0500 Subject: Successfully eliminated TCP port on both sides! This requires relying on xtigervncviewer on the remote side, since only tiger supports connecting to a unix socket file. This is for -r only. The regular connection still uses TCP :( --- dot/local/bin/xvnc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dot/local/bin/xvnc b/dot/local/bin/xvnc index 375d13a..7eba3f2 100755 --- a/dot/local/bin/xvnc +++ b/dot/local/bin/xvnc @@ -1,4 +1,6 @@ #!/bin/bash +set -e +set -o pipefail # x11vnc option '-noxrecord' added as workaround for crashing bug # See https://github.com/LibVNC/x11vnc/issues/61 @@ -44,25 +46,23 @@ share_display() port=5500 OUR_TMP=$(mktemp -d) || exit - socket_file=$OUR_TMP/x11vnc.socket + local_socket_file=$OUR_TMP/x11vnc.socket + ssh_control=$OUR_TMP/ssh.socket - # killall x11vnc - x11vnc -noxrecord -q -nopw -ncache -ncache_cr -display "${local_display}" -unixsock "$socket_file" & + x11vnc -noxrecord -q -nopw -ncache -ncache_cr -display "${local_display}" -unixsock "$local_socket_file" -rfbport 0 & X11VNC=$! trap atexit EXIT - # TODO: spin waiting for port 5500 - ssh -n \ - ${remote_port:+ -p "$remote_port" } \ - "$remote_host" \ - "fuser -vk $port/tcp && sleep 1" + rando=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c15) && [ "$rando" ] + remote_socket_file=/tmp/xtigervncviewer.$rando.socket + ssh -n \ -o ControlPath=none \ -o ExitOnForwardFailure=yes \ - -R "localhost:$port:$socket_file" \ + -R "$remote_socket_file:$local_socket_file" \ ${remote_port:+ -p "$remote_port" } \ "$remote_host" \ - "DISPLAY=${remote_display} xvncviewer localhost:$port" 2>&1 & + "${DEBUG:+ set -x; } trap 'rm -f $remote_socket_file' EXIT; DISPLAY=$remote_display xtigervncviewer $remote_socket_file" & SSH=$! wait -n } -- cgit v1.2.3