sshwifty icon indicating copy to clipboard operation
sshwifty copied to clipboard

Default automatic telnet connection feature request

Open CaliforniaLocal opened this issue 2 years ago • 2 comments

This is an awesome app, thanks very much for making it available. We're running a Django web server and would like to use sshwifty to enable our members to connect to a moo based chat server automatically without going through the connection menu.

We very much appreciate the ability to limit outbound connections to designated presets, but would like to avoid having our members need to go through the menus to connect to the chat server when there is only a single telnet preset in our use case. Further, we'd like to pass along the user's connection login and password to the moo server via sshwifty.

So as an implementation in the config.json file, the ability to designate the telnet server and port to automatically connect to without needing to go through the connection menu (and in fact not display the connection menu)

And as an implementation in the sshwifty http server, the ability to take a connection command via POST which is then sent to the telnet server automatically when connected which in our case (and in the case of most MUDs etc) would be a single line like: connect character-name password

We prefer sending the info via POST to avoid exposing it in the browser.

This would serve the general use case of web servers connecting to in-house muds or chat servers

Thanks for your consideration.

CaliforniaLocal avatar Jun 12 '22 16:06 CaliforniaLocal

Sorry, I've looked into the possibilities and unable to found a easy way to add such feature into Sshwifty in a generalized manner.

The difficult part is automatic user login, which require automatic interaction between Sshwifty and the target server (instead of just sending the login detail and hope for the best). For example, for a server that expect username and password, the manual login flow might look like this:

  1. Connection established
  2. Server sends Username:\n, and wait for user input their username, terminated with \n
  3. User types their username, and press Enter key
  4. The server checks the input, founds the \n character, so it knows that the username input process is completed
  5. The server send Password:\n, and wait for user to input their password, terminated with \n
  6. User types their password, and press Enter key
  7. The server checks the input again, founds the \n character, the password input process is completed

Of course, a program can simply just send <Username>\n<Password>\n down the TCP pipe and it might work for the specific case. However, it's quite irresponsible for me to implement it in this way, since it might not work in other cases.

In order to implement it responsibly, Sshwifty must check what exactly the server wants and response to it accordingly, so the login flow might look similar to this:

  1. Connection established, both the remote server and Sshwifty knows it
  2. Sshwifty is expecting Username:\n, and if received, Sshwifty will reply <Username>\n
  3. Server sends Welcome! You've connected to our server....\n
  4. Server sends MOTD: ......\n
  5. Sshwifty receives Welcome! ...\n, user configuration says it should be ignored
  6. Sshwifty receives MOTD: ...\n, user configuration says it should be ignored too
  7. Server sends Username:\n, Sshwifty replies <Username>\n
  8. Sshwifty now expecting Password:\n, and will reply <Password>\n once received it
  9. Server sends Hello <Username>
  10. Sshwifty receives Hello <Username>, user configuration says it should be ignored
  11. Server sends Password:\n
  12. Sshwifty receives Password:\n, and replies <Password>\n. Sshwifty now expects Login successful!\n and will stop the automatic login since received it
  13. Server sends Login successful!\n
  14. Sshwifty hand over the control to the user

As you can see, the situation gets complex really quickly, and the case above is just a simplified example. Think what if server sends Password for <Username>:\n instead of just Password? What if something went wrong during the login process?

To make it work in general cases, I'm afraid I have to invent a programming language (kind like expect script) to allow users to express the login logic, but that's too big for this project.

So, sorry again. But I don't think it can be implemented in Sshwifty.

However, since you control the both ends, you can of course modify the software in your own fork to make it work for your specific case.

Another thing is, if you just want Sshwifty to connect to a remote server after the page is loaded (without the need of autologin), there is a feature called Launch Link, which can be generated from the "Connected before" list on the "Known remotes" tab. The link is similar to this: https://sshwifty.herokuapp.com/#+Telnet:horizons.jpl.nasa.gov:6775%7Cutf-8. Of course, user will still have to manually type in their login details, but at least it would save them few clicks :)

nirui avatar Jun 13 '22 04:06 nirui

Thanks for your thoughtful reply, you make good points with regard to an "auto login" implementation. The launch link feature is a good start for what I'm looking for.
Thanks again for sshwifty.

CaliforniaLocal avatar Jun 13 '22 09:06 CaliforniaLocal