xtermjs / xterm.js

A terminal for the web
https://xtermjs.org/
MIT License
17.73k stars 1.64k forks source link

Support Zmodem(rz/sz) addon #4471

Open jooy2 opened 1 year ago

jooy2 commented 1 year ago

Thanks to the developers for creating an amazing terminal module and supporting it to this day.

image

It would be nice to have separate support for the Zmodem add-on to receive or send files to the terminal using lrzsz. Zmodem is still one of the solutions for file transfer supported by many terminal emulators.

I realize that there are already old closed issues about this. (#279) However, as explained in (#1128 (comment)), the Zmodem add-on has now been removed, so I felt the need to reopen these issues.

Similarly, I found the following third-party solution (ZmodemJS), but it doesn't seem to be maintained since 2020. https://github.com/FGasper/zmodemjs

Are there currently any other solutions for supporting Zmodem that I'm not aware of? If not, it would be awesome if Xterm.js supported Zmodem via an add-on.

Regards,

jerch commented 1 year ago

Well zmodem is tricky, as it actually competes with VT sequences on protocol level. Terminal emulators (TE) supporting it have to stop their terminal magic and spin up a zmodem parser. So technically not the VT TE supports zmodem, but some sort of a preparser doing the zmodem vs VT parser belly dance. And thats nothing to get done right easily, as zmodem relies on a magic introducer, which is also perfectly valid in terminal data, so you might end up with ambiguity (you gonna need some read ahead logic to decide, whether it is real zmodem data). Kinda every terminal with zmodem support suffer from this, and correct recovery from zmodem ambiguity is rather hard to impossible for some edge cases (yes you can render a terminal with zmodem support unusable by "carefully crafting" the data). This needed complexity outside of the real terminal logic made us stop supporting the old zmodem addon.

A much better way to get file transfers rolling is to shape things into its own dedicated terminal sequence without any ambiguity at the higher protocol level. There are some attempts into that direction, but none took broader adoption yet, an so has xterm.js nothing in this regard yet either.

jooy2 commented 1 year ago

Thanks for the detailed explanation. I just wanted to check what the status was on the implementation of this feature.

Hopefully the technical difficulties will be resolved in the near future and Zmodem will be implemented.

jerch commented 1 year ago

Well, feel free to contribute a solution. But as I wrote above, the "technical difficulties" cannot be fully resolved, as it is an inherent issue of a protocol clash.

zundaren commented 1 year ago

maybe trzszjs better

Tyriar commented 1 year ago

I never bothered to look into how zmodem works, I wasn't comfortable maintaining the old addon as I didn't use or understand it. Feels out of scope to me still.

jooy2 commented 1 year ago

Thanks for sharing information.

I recently found something like this: (Just thought I'd share it for reference.)

The following Xterm written in Dart seems to support Zmodem. I don't know what the structure of this is, but it might be a helpful reference for someone.

https://github.com/TerminalStudio/xterm.dart https://github.com/TerminalStudio/zmodem