MisterTea / EternalTerminal

Re-Connectable secure remote shell

Home Page:https://mistertea.github.io/EternalTerminal/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flow Control

bmaurer opened this issue · comments

I've noticed that ET struggles with Flow Control. If you run

cat /dev/zero | base64 -w 0

it is not possible to send a ^C to the server. Using SSH directly it works fine.

$ et --version
et version 6.2.1

ET has flow control but it's based on lines-per-second (currently set to 1024 lines-per-second):

https://github.com/MisterTea/EternalTerminal/blob/master/src/terminal/UserTerminalHandler.cpp#L110

In your example, there are no newlines so the flow control doesn't kick in. Feel free to change the logic to do roughly 80k characters per second and that would fix the example you posted.

@MisterTea This also repros if you just run cat /dev/zero | base64, which has plenty of newlines.

Oh, interesting! What happens if you compile with a much lower lines per second?

Haven't had a chance to try out an end to end compile. This python script might be helpful though:

from datetime import datetime
while True:
  print(( datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f') + "\n") * 1000)

When run through ET, you can see that the time that gets printed out starts lagging real time. This suggests that ET is not putting back pressure on the stdout of the underlying process. OTOH with SSH directly, everything is in real time.

Intuitively, if you have a rate limit (ideally this would not be necessary. 1024 lines / second is rather slow if you cat a long file) you also need to put backpressure on the remote end. If you allow buffering, you are always going to be seeing old output, which means that a control-C can't take effect instantly.