Skip to content

Add the -via arguments to config file and GUI for the viewer - #1517

Closed
dmcmahill wants to merge 2 commits into
TigerVNC:masterfrom
dmcmahill:add-via-to-viewer-gui
Closed

Add the -via arguments to config file and GUI for the viewer#1517
dmcmahill wants to merge 2 commits into
TigerVNC:masterfrom
dmcmahill:add-via-to-viewer-gui

Conversation

@dmcmahill

Copy link
Copy Markdown

vncviewer already includes a -via <ssh_host> command line option to
specify that an SSH tunnel to <ssh_host> should be established and
VNC traffic routed through the tunnel. However, that option was not
available either in the *.tigervnc setup files or via the GUI.

This adds UseSSH (boolean) and via (string) parameters to the config
file and exposes them to the VNC viewer GUI under the options dialog.

This shows where I added the option to the GUI:

tigervnc_via

This shows an example of how the option shows up in a .tigervnc file:

UseSSH=1
via=my.sshhost.com

@CendioOssman CendioOssman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This would make this feature more accessible to others. I have some small concerns, though. See the comments.

Comment thread vncviewer/OptionsDialog.cxx Outdated
Comment thread vncviewer/parameters.cxx Outdated
Comment thread vncviewer/OptionsDialog.cxx Outdated
@dmcmahill

Copy link
Copy Markdown
Author

I've reworked the code from this PR into a branch based on the work in #1529. Once that PR merges I'll rebase the branch and resubmit this PR using the new code. In the mean time, my new branch is at https://github.com/dmcmahill/tigervnc/commits/newoptions-via-to-gui

@CendioOssman

Copy link
Copy Markdown
Member

Sounds good. But please don't open a new PR. Simply rebase and force push an update to the PR here. That way we keep all history.

@dmcmahill
dmcmahill force-pushed the add-via-to-viewer-gui branch from 752eeb3 to e410f25 Compare October 18, 2022 16:12
@dmcmahill

Copy link
Copy Markdown
Author

Sounds good. But please don't open a new PR. Simply rebase and force push an update to the PR here. That way we keep all history.

Understood. I went ahead and force pushed the new code that is still rooted in your branch so I'll need to do one more rebase and force push once the other PR merges. But at least this PR now shows what the change will be.

Here is the options dialog with the new entry.

tigervnc_via_newoptions

@CendioOssman

Copy link
Copy Markdown
Member

One goal of the new layout is to avoid having to increase the size of the options dialog, and instead have scroll bars. My idea was something like this:

diff --git a/vncviewer/OptionsDialog.cxx b/vncviewer/OptionsDialog.cxx
index 5550ade7..dd295abe 100644
--- a/vncviewer/OptionsDialog.cxx
+++ b/vncviewer/OptionsDialog.cxx
@@ -53,6 +53,7 @@
 #include <FL/Fl_Round_Button.H>
 #include <FL/Fl_Int_Input.H>
 #include <FL/Fl_Choice.H>
+#include <FL/Fl_Scroll.H>
 
 using namespace std;
 using namespace rdr;
@@ -63,7 +64,7 @@ std::map<OptionsCallback*, void*> OptionsDialog::callbacks;
 static std::set<OptionsDialog *> instances;
 
 OptionsDialog::OptionsDialog()
-  : Fl_Window(580, 480, _("TigerVNC Options"))
+  : Fl_Window(580, 420, _("TigerVNC Options"))
 {
   int x, y;
   Fl_Button *button;
@@ -668,7 +669,9 @@ void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th)
 void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
 {
 #if defined(HAVE_GNUTLS) || defined(HAVE_NETTLE) || !defined(WIN32)
-  Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Security"));
+  Fl_Scroll *scroll = new Fl_Scroll(tx, ty, tw, th, _("Security"));
+  tw -= Fl::scrollbar_size();
+  Fl_Group *group = new Fl_Scroll(tx, ty, tw, 0);
 
   int orig_tx;
   int width;
@@ -828,10 +831,15 @@ void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
   tx = orig_tx;
   ty += INNER_MARGIN;
 
-
 #endif // !WIN32
 
+  /* Needed for resize to work sanely */
+  group->resizable(NULL);
+  ty += OUTER_MARGIN - INNER_MARGIN;
+  group->size(group->w(), ty - group->y());
+
   group->end();
+  scroll->end();
 
 #endif // defined(HAVE_GNUTLS) || defined(HAVE_NETTLE) || !defined(WIN32)
 }

@dmcmahill

Copy link
Copy Markdown
Author

Updated with scrollbars as suggested by @CendioOssman . Thanks!

@CendioOssman

Copy link
Copy Markdown
Member

Sorry about the delay. You are not forgotten, we're just a bit too busy at the moment. Please bear with us a bit more, and we will get this merged eventually.

@CendioOssman

Copy link
Copy Markdown
Member

The options dialog changes are now merged, so please have a look at rebasing this PR so we can focus on just your new additions.

vncviewer already includes a `-via <ssh_host>` command line option to
specify that an SSH tunnel to `<ssh_host>` should be established and
VNC traffic routed through the tunnel.  However, that option was not
available either in the `*.tigervnc` setup files or via the GUI.

This adds a `via` (string) parameter to the config file and exposes
it to the VNC viewer GUI under the options dialog.

In addition, when establishing a tunnel and even before deciding to
establish a tunnel, strip leading and trailing whitespace because
`ssh "    my.host.com   "` will indeed fail and if someone manages
to get a blank value (only whitespace) into the GUI or the config file
it can produce confusing results.
Apply the code suggested by Pierre Ossman to use a scrollbar in
the security section of the options dialog instead of growing the
size of the dialog.
@dmcmahill
dmcmahill force-pushed the add-via-to-viewer-gui branch from dfbed39 to 53473dd Compare December 22, 2022 14:21
@dmcmahill

Copy link
Copy Markdown
Author

The options dialog changes are now merged, so please have a look at rebasing this PR so we can focus on just your new additions.

rebased and force pushed

@CendioOssman CendioOssman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. I have some minor things that need adjusting, then we can go ahead and merge this.

/* Connection */
ty += GROUP_LABEL_OFFSET;
// height = GROUP_MARGIN * 2 + (INPUT_LABEL_OFFSET + INPUT_HEIGHT) * 1;
connectionGroup = new Fl_Group(tx, ty, width, 0, _("Connection"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Connection" is a bit general, so I think we need something more specific here. "Gateway" is what's used in the documentation, so something including that word would probably be best for consistency.

Comment thread vncviewer/OptionsDialog.h

static void handleX509(Fl_Widget *widget, void *data);
static void handleRSAAES(Fl_Widget *widget, void *data);
static void handleViaHost(Fl_Widget *widget, void *data);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be used?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this. It was there in the original version before your new options work and when I reworked the code I accidentally left this in. I'll remove it.

Comment thread vncviewer/parameters.cxx

#ifndef WIN32
StringParameter via("via", "Gateway to tunnel via", "");
StringParameter via("via", "SSH host for tunnel", "");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unrelated change, so it should be a separate commit.

The term "Gateway" is also used elsewhere, so everything would need to be adjusted so things are consistent.

Lastly, I'm uncertain if this is clearer. We're gaining the detail of it being SSH, but losing the gateway¹ aspect.

¹ Which is a less common description than "proxy"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove this particular change.

Comment thread vncviewer/vncviewer.cxx
while (*tmps2 != '\0' && !isspace(*tmps2)) tmps2++;
if (isspace (*tmps2)) *tmps2 = '\0';
vlog.info(_("Establish SSH tunnel to gatewayHost \"%s\"\n"), tmps);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are nice improvements, but unrelated to adding the GUI. So please have this as a separate commit.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure I understand before I do it, would you like to see me take the changes (plus your corrections) and break into the GUI part and the non GUI part, re-do the commits and force push to have a more clean history before the merge? I'm happy to do that but wanted to make sure I didn't misunderstand your request.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's precisely right. :)

Comment thread vncviewer/vncviewer.cxx
if (useSSH && mktunnel() != 0)
usage(argv[0]);
strFree(tmps);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


OptionsDialog::OptionsDialog()
: Fl_Window(580, 480, _("TigerVNC Options"))
: Fl_Window(580, 420, _("TigerVNC Options"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include this commit into the main one so we can avoid this back and forth.

@vejnar

vejnar commented Mar 25, 2023

Copy link
Copy Markdown

This would be a fantastic feature! Thanks for working on it. PR seems almost done. Any news @dmcmahill to push for the finish line?

Question: Would this option be available on Windows?

@CendioOssman

Copy link
Copy Markdown
Member

Unfortunately, it seems this PR is abandoned. :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants