chrome.terminalPrivate source

357 views
Skip to first unread message

Randall Underwood

unread,
Oct 9, 2012, 6:31:07 PM10/9/12
to chromiu...@chromium.org
Hi there,

  I was playing with making hterm work on a webpage instead of as a chrome extension. It looks like chosh.html is a reasonable starting point -- is the source to chrome.terminalPrivate still available somewhere? (If not then I'm sure I can get something going, but it'd obviously be easier with the reference ;) ).

Thanks!
 Randall

Robert Ginda

unread,
Oct 9, 2012, 6:38:22 PM10/9/12
to Randall Underwood, chromium-hterm
chrome.terminalPrivate exists, but it's native code only available to the Secure Shell chrome extension, and only on Chrome OS.  I don't think it'd be much help in your case.  It just opens a process to "/usr/bin/crosh" and provides a way to stream stdin/stdout over the C++ to JS boundary.

You may get more benefit from nassh_stream.js, nassh_stream_google_relay.js and nassh_google_relay.js.  These work together to marshal the ssh connection over traditional web transports.  There is an implementation that works over HTTP using XHR, and one using WebSockets.

The easiest way to get things working in a web page may be to write a server that works like the google relay server.  See this part of the FAQ:

  86 > But, what if I *want* to ssh over HTTP?
  87 
  88   Secure Shell also knows how to connect to an HTTP-to-ssh relay that was
  89   built inside Google.  Unfortunately that relay isn't open source, and Google
  90   doesn't maintain a public pool of relays.
  91 
  92   However, you're free to build one that works the same way.  There should be
  93   enough documentation in nassh_google_relay.js to reverse engineer a
  94   compatible relay.
  95 
  96   If you're interested in writing an alternative relay library, please mention
  97   it on the mailing list.


Rob.

Jeff Bailey

unread,
Oct 9, 2012, 6:39:53 PM10/9/12
to Randall Underwood, chromiu...@chromium.org
Do you need the actual SSH part of it?  If not, chrome.terminalPrivate isn't needed at all.  You can see how I used hterm for a NaCl-based port of Nethack at https://github.com/kaladron/nethack-nacl/blob/master/win/nacl/index.html
Jeff Bailey | Software Engineer | jeffb...@google.com | Google




On Tue, Oct 9, 2012 at 3:31 PM, Randall Underwood <randa...@gmail.com> wrote:

Jeff Bailey

unread,
Oct 9, 2012, 6:41:38 PM10/9/12
to Robert Ginda, Randall Underwood, chromium-hterm
Isn't it also using that for the sockets?  If it's just stdin/stdout, you could do that use jspipemount from nacl-mounts without anything special (that's how I'm doing it for Nethack and how Brad implemented NaclForth)

Jeff Bailey | Software Engineer | jeffb...@google.com | Google




Robert Ginda

unread,
Oct 9, 2012, 6:44:32 PM10/9/12
to Jeff Bailey, Randall Underwood, chromium-hterm
It's only using it for stdin/out.  Crosh (the troubleshooting shell you get on Chrome OS when you hit Ctrl-Alt-T) has nothing at all to do with NaCl.  The point is to run "/usr/bin/crosh" to open a shell on the actual device, and NaCl very explicitly doesn't help with that.


Rob.

Jeff Bailey

unread,
Oct 9, 2012, 6:48:38 PM10/9/12
to Robert Ginda, Randall Underwood, chromium-hterm
Makes sense.  I'd forgotten that even existed. =)

Jeff Bailey | Software Engineer | jeffb...@google.com | Google




Randall Underwood

unread,
Oct 9, 2012, 6:55:37 PM10/9/12
to chromiu...@chromium.org, Robert Ginda, Randall Underwood
No, I was planning on wrapping a pty in node or similar, and exposing it to hterm via XHR (and not doing SSH). I did a little terminal on Android before and probably the code is similar, but I didn't detect the pty requesting a resize (which it looks like terminalPrivate does do), so the c++ code would be handy; sorry for not being clearer :).

Randall

Robert Ginda

unread,
Oct 9, 2012, 6:58:30 PM10/9/12
to Randall Underwood, chromium-hterm
Message has been deleted

Robert Ginda

unread,
Oct 9, 2012, 7:09:20 PM10/9/12
to Randall Underwood, chromium-hterm
FWIW, the NaCl ssh command also creates a ptty and deals with size changes and some additional tty state that crosh doesn't do.  The code for that is here: http://git.chromium.org/gitweb/?p=chromiumos/platform/assets.git;a=tree;f=chromeapps/ssh_client


Rob.
Reply all
Reply to author
Forward
0 new messages