liftoff / GateOne

Gate One is an HTML5-powered terminal emulator and SSH client
http://liftoffsoftware.com/Products/GateOne
Other
6.28k stars 925 forks source link

Per-Bookmark Additional SSH Options #83

Open detain opened 12 years ago

detain commented 12 years ago

I added a new option to the Bookmarks plugin. It gives you an extra box to specify additional stuff to send over the SSH connection after your connected. For example if you wanted to create a bookmark that would type 'w' as soon as you logged in, you would just put the 'w' in the Additoinal SSH Options box.

Its probably not the cleanest of code, first time really playing around w/ python.

--- ./plugins/bookmarks/bookmarks.py    2012-01-21 08:03:29.000000000 -0500
+++ /opt/gateone/./plugins/bookmarks/bookmarks.py   2012-01-21 13:39:01.000000000 -0500
@@ -81,6 +81,7 @@
     icon = None
     name = ""
     notes = ""
+    options = ""
     for token in stream:
         if 'name' in token:
             if token['name'] == 'dl':
@@ -117,6 +118,7 @@
                         'name': name.strip(),
                         'tags': [a for a in tags if a], # Remove empty tags
                         'notes': "", # notes
+                        'options': "", # notes
                         'visits': 0, # visits
                         'updated': add_date, # updated
                         'created': add_date, # created
@@ -217,6 +219,7 @@
                             'name': child['title'].strip(),
                             'tags': tags,
                             'notes': notes,
+                            'options': options,
                             'visits': 0, # visits
                             'updated': child['lastModified'], # updated
                             'created': child['dateAdded'], # created
@@ -346,6 +349,7 @@
                         'name': "Deleted Bookmarks",
                         'tags': [],
                         'notes': [bookmark],
+           'options': '',
                         'visits': highest_USN + 1,
                         'updated': int(round(time.time() * 1000)),
                         'created': int(round(time.time() * 1000)),
--- ./plugins/bookmarks/static/bookmarks.js 2012-01-21 08:03:29.000000000 -0500
+++ /opt/gateone/./plugins/bookmarks/static/bookmarks.js    2012-01-21 15:15:39.000000000 -0500
@@ -461,6 +461,7 @@
                     'name': "You don't have any bookmarks yet!",
                     'tags': [],
                     'notes': 'A great way to get started is to import bookmarks or click Sync.',
+                    'options': '',
                     'visits': 0,
                     'updated': new Date().getTime(),
                     'created': new Date().getTime(),
@@ -472,6 +473,7 @@
                 'name': "A Quick Screencast Overview of Bookmarked",
                 'tags': ["Video", "Help"],
                 'notes': 'Want some help getting started?  Our short (3 minutes) overview screencast can be illuminating.',
+                'options': '',
                 'visits': 0,
                 'updated': new Date().getTime(),
                 'created': new Date().getTime(),
@@ -845,6 +847,7 @@
             bmLink.innerHTML = bookmark.name;
         }
         bmLink.onclick = function(e) {
+       //alert('JOE DID THIS 1');
             e.preventDefault();
             b.openBookmark(this.href);
         };
@@ -864,6 +867,7 @@
         // The Link Float div sits behind everything but on top of bmElement and allows us to click anywhere to open the bookmark without clobbering the onclick events of tags, edit/delete, etc
         bmElement.appendChild(bmContent);
         bmDesc.innerHTML = bookmark.notes;
+        //bmOptions.innerHTML = bookmark.options;
         bmContent.appendChild(bmDesc);
         if (!ad && b.bookmarks.length) {
             var bmDateTag = u.createElement('li', {'class': 'bm_autotag'}),
@@ -1156,12 +1160,19 @@
             b.incrementVisits(URL);
             go.Input.queue(URL+'\n');
             go.Net.sendChars();
+       go.Input.queue(bookmark.options+'\n');
+            go.Net.sendChars();
+       //alert('Options ' + bookmark.options);
+       //if (bookmark.options)
         } else {
             b.incrementVisits(URL);
             go.Terminal.newTerminal();
             setTimeout(function() {
                 go.Input.queue(URL+'\n');
                 go.Net.sendChars();
+           go.Input.queue(bookmark.options+'\n');
+                go.Net.sendChars();
+       //alert('Options2 ' + bookmark.options);
             }, 250);
         }
         go.Visual.togglePanel('#'+prefix+'panel_bookmarks');
@@ -1477,10 +1488,11 @@
             var bmName = bookmarks[index].name,
                 bmTags = bookmarks[index].tags,
                 bmNotes = bookmarks[index].notes;
-            bmForm.innerHTML = '<h2>Edit Bookmark</h2><label for="'+prefix+'bm_newurl">URL</label><input type="text" name="'+prefix+'bm_newurl" id="'+prefix+'bm_newurl" class="input-text-plain" value="' + URL + '"><label for="'+prefix+'bm_new_name">Name</label><input type="text" name="'+prefix+'bm_new_name" id="'+prefix+'bm_new_name" class="input-text-plain" value="' + bmName + '"><label for="'+prefix+'bm_newurl_tags">Tags</label><input type="text" name="'+prefix+'bm_newurl_tags" id="'+prefix+'bm_newurl_tags" class="input-text-plain" value="' + bmTags + '"><label for="'+prefix+'bm_new_notes">Notes</label><textarea id="'+prefix+'bm_new_notes" class="input-text-plain medium">' + bmNotes + '</textarea>';
+       bmOptions = bookmarks[index].options;
+            bmForm.innerHTML = '<h2>Edit Bookmark</h2><label for="'+prefix+'bm_newurl">URL</label><input type="text" name="'+prefix+'bm_newurl" id="'+prefix+'bm_newurl" class="input-text-plain" value="' + URL + '"><label for="'+prefix+'bm_new_name">Name</label><input type="text" name="'+prefix+'bm_new_name" id="'+prefix+'bm_new_name" class="input-text-plain" value="' + bmName + '"><label for="'+prefix+'bm_newurl_tags">Tags</label><input type="text" name="'+prefix+'bm_newurl_tags" id="'+prefix+'bm_newurl_tags" class="input-text-plain" value="' + bmTags + '"><label for="'+prefix+'bm_new_notes">Notes</label><textarea id="'+prefix+'bm_new_notes" class="input-text-plain medium">' + bmNotes + '</textarea><label for="'+prefix+'bm_new_options">Arguments To Pass to SSH</label><textarea id="'+prefix+'bm_new_options" class="input-text-plain medium">' + bmOptions + '</textarea>';
         } else {
             // Creating a new bookmark (blank form)
-            bmForm.innerHTML = '<h2>New Bookmark</h2><label for="'+prefix+'bm_newurl">URL</label><label for="'+prefix+'bm_newurl" class="inlined">ssh://user@host:22 or http://webhost/path</label><input type="text" name="'+prefix+'bm_newurl" id="'+prefix+'bm_newurl" class="input-text"><label for="'+prefix+'bm_new_name">Name</label><label for="'+prefix+'bm_new_name" class="inlined">Web App Server 1</label><input type="text" name="'+prefix+'bm_new_name" id="'+prefix+'bm_new_name" class="input-text"><label for="'+prefix+'bm_newurl_tags">Tags</label><label for="'+prefix+'bm_newurl_tags" class="inlined">Linux, New York, Production</label><input type="text" name="'+prefix+'bm_newurl_tags" id="'+prefix+'bm_newurl_tags" class="input-text"><label for="'+prefix+'bm_new_notes">Notes</label><label for="'+prefix+'bm_new_notes" class="inlined medium">Add some notes about this bookmark.</label><textarea id="'+prefix+'bm_new_notes" class="input-text medium"></textarea>';
+            bmForm.innerHTML = '<h2>New Bookmark</h2><label for="'+prefix+'bm_newurl">URL</label><label for="'+prefix+'bm_newurl" class="inlined">ssh://user@host:22 or http://webhost/path</label><input type="text" name="'+prefix+'bm_newurl" id="'+prefix+'bm_newurl" class="input-text"><label for="'+prefix+'bm_new_name">Name</label><label for="'+prefix+'bm_new_name" class="inlined">Web App Server 1</label><input type="text" name="'+prefix+'bm_new_name" id="'+prefix+'bm_new_name" class="input-text"><label for="'+prefix+'bm_newurl_tags">Tags</label><label for="'+prefix+'bm_newurl_tags" class="inlined">Linux, New York, Production</label><input type="text" name="'+prefix+'bm_newurl_tags" id="'+prefix+'bm_newurl_tags" class="input-text"><label for="'+prefix+'bm_new_notes">Notes</label><label for="'+prefix+'bm_new_notes" class="inlined medium">Add some notes about this bookmark.</label><textarea id="'+prefix+'bm_new_notes" class="input-text medium"></textarea><label for="'+prefix+'bm_new_options">Options</label><label for="'+prefix+'bm_new_options" class="inlined medium">SSH Arguments/Options.</label><textarea id="'+prefix+'bm_new_options" class="input-text medium"></textarea>';
         }
         bmCancel.onclick = function(e) {
             // Reset the inline labels in addition to the form
@@ -1543,6 +1555,7 @@
                 name = u.getNode('#'+prefix+'bm_new_name').value,
                 tags = u.getNode('#'+prefix+'bm_newurl_tags').value,
                 notes = u.getNode('#'+prefix+'bm_new_notes').value,
+                options = u.getNode('#'+prefix+'bm_new_options').value,
                 now = new Date();
             // Fix any missing trailing slashes in the URL
             if (url.slice(0,4) == "http" && url.indexOf('/', 7) == -1) {
@@ -1564,6 +1577,7 @@
                     'name': name,
                     'tags': tags,
                     'notes': notes,
+                    'options': options,
                     'visits': 0,
                     'updated': now.getTime(),
                     'created': now.getTime(),
@@ -1588,6 +1602,7 @@
                         b.bookmarks[i].url = url;
                         b.bookmarks[i].name = name;
                         b.bookmarks[i].notes = notes;
+                        b.bookmarks[i].options = options;
                         b.bookmarks[i].tags = tags;
                         b.bookmarks[i].updated = now.getTime();
                         b.bookmarks[i].updateSequenceNum = 0;
@@ -1801,6 +1816,7 @@
                     'name': "You should not see this",
                     'tags': [],
                     'notes': "This should never be visible.  If you see this, well, sigh.",
+                    'options': "",
                     'visits': 0,
                     'updated': new Date().getTime(),
                     'created': new Date().getTime(),
--- ./plugins/bookmarks/templates/bookmarks.html    2012-01-21 08:03:29.000000000 -0500
+++ /opt/gateone/./plugins/bookmarks/templates/bookmarks.html   2012-01-21 13:32:32.000000000 -0500
@@ -12,5 +12,8 @@
     {% if bookmark['notes'] %}
         <DD>{{escape(bookmark['notes'])}}
     {% end %}
+    {% if bookmark['options'] %}
+        <DD>{{escape(bookmark['options'])}}
+    {% end %}
 {% end %}
 </DL><p>
\ No newline at end of file
--- ./plugins/ssh/scripts/ssh_connect.py    2012-01-21 08:03:29.000000000 -0500
+++ /opt/gateone/./plugins/ssh/scripts/ssh_connect.py   2012-01-21 08:06:35.000000000 -0500
@@ -96,13 +96,13 @@
         "-F/dev/null", # No config dir (might change this is the future)
         # This is so people won't have to worry about user management when
         # running one-Gate One-per-server...
-        "-oNoHostAuthenticationForLocalhost=yes",
-        "-oPreferredAuthentications=keyboard-interactive,password",
+        #"-oNoHostAuthenticationForLocalhost=yes",
+        #"-oPreferredAuthentications=keyboard-interactive,password",
         "-p", port,
         "-l", user,
     ]
-    if sshfp:
-        args.insert(3, "-oVerifyHostKeyDNS=yes")
+    #if sshfp:
+    #    args.insert(3, "-oVerifyHostKeyDNS=yes")
     if socket:
         # Only set Master mode if we don't have a socket for this session.
         # This allows us to duplicate a session without having to code
liftoff commented 12 years ago

This is a great idea! I know it is because it is already in my TODO list for the next version of Gate One after 1.0 :)

I've actually been working on something similar that would let you execute commands after connecting to any given host but it wasn't quite the same thing as this. I'll definitely add the "execute a command immediately after connecting" feature soon and thanks for the patch!

For reference, my original plan was to have a separate interface for defining macros and then provide the capability to call a given macro (or macros) after a bookmark was connected. This would be in addition to the ability to assign macros to arbitrary keyboard shortcuts. I think it would be better than defining the commands/macros within bookmarks themselves since you might want to have bookmarks that execute a common sequence. What do you think?

Also, why did you disable SSHFP in your patch?

detain commented 12 years ago

ahh your way sounds better =)

didnt mean to disable the sshfp


From: Dan McDougall [reply@reply.github.com] Sent: Sunday, January 22, 2012 1:05 PM To: Joeseph Huss Subject: Re: [GateOne] Per-Bookmark Additional SSH Options (#83)

This is a great idea! I know it is because it is already in my TODO list for the next version of Gate One after 1.0 :)

I've actually been working on something similar that would let you execute commands after connecting to any given host but it wasn't quite the same thing as this. I'll definitely add the "execute a command immediately after connecting" feature soon and thanks for the patch!

For reference, my original plan was to have a separate interface for defining macros and then provide the capability to call a given macro (or macros) after a bookmark was connected. This would be in addition to the ability to assign macros to arbitrary keyboard shortcuts. I think it would be better than defining the commands/macros within bookmarks themselves since you might want to have bookmarks that execute a common sequence. What do you think?

Also, why did you disable SSHFP in your patch?


Reply to this email directly or view it on GitHub: https://github.com/liftoff/GateOne/issues/83#issuecomment-3604638