-
-
Notifications
You must be signed in to change notification settings - Fork 330
Description
I think I stumbled upon a race condition when trying to open a tunnel from a bad internet connection (Wi-Fi on german trains is really annoying 🙈). When the SSH connection drops immediatly after it is established, sish starts the forwarding anyway, blocking the alias name for further connections.
For a usual working tunnel I see the following in the sish log:
2025/04/04 - 16:00:34 | Accepted SSH connection for: 185.104.138.67:62632
2025/04/04 - 16:00:35 | Login attempt: 185.104.138.67:62632, user tim key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOX5V9bKQY0bn/BCusYQ4KuzIw8ZieKqYv7Uoc7S0iog
2025/04/04 - 16:00:35 | HTTP forwarding started: http://mytunnel.sish.myserver.de -> /tmp/185.104.138.67_62632_4431231408965 for client: 185.104.138.67:62632
2025/04/04 - 16:00:35 | HTTPS forwarding started: https://mytunnel.sish.myserver.de -> /tmp/185.104.138.67_62632_4431231408965 for client: 185.104.138.67:62632
2025/04/04 - 16:00:42 | Closed SSH connection for: 185.104.138.67:62632 user: tim
In the error case I see the following:
2025/04/04 - 16:01:02 | Accepted SSH connection for: 185.104.138.67:62686
2025/04/04 - 16:01:05 | Login attempt: 185.104.138.67:62686, user tim key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOX5V9bKQY0bn/BCusYQ4KuzIw8ZieKqYv7Uoc7S0iog
2025/04/04 - 16:01:05 | Closed SSH connection for: 185.104.138.67:62686 user: tim
2025/04/04 - 16:01:06 | HTTP forwarding started: http://mytunnel.sish.myserver.de -> /tmp/185.104.138.67_62686_4431133630303 for client: 185.104.138.67:62686
2025/04/04 - 16:01:06 | HTTPS forwarding started: http://mytunnel.sish.myserver.de -> /tmp/185.104.138.67_62686_4431133630303 for client: 185.104.138.67:62686
2025/04/04 - 16:01:06 | Error replying to port forwarding request: EOF
I haven't looked into the code yet, but from what I see the connection is closed before the forwarding is started. Probably there is a check missing whether the connection is still active before actually starting the forwarding.
The tunnel does not work, of course, because the SSH connection is closed. The domain http://mytunnel.sish.myserver.de is blocked for subsequent requests, though.
I was able to reproduce this after seeing it for the first time on the same bad Wi-Fi connection. In both cases the sish docker container stopped a few minutes afterwards without any useful message in the log. I had to manually restart sish.
@antoniomika As I said, I haven't looked into the code, yet, but maybe you already have an idea why this is happening and how to prevent it?
And as a sidenote: I think it might be useful to have a message in the log as soon as a forwarding is stopped.