atsign-foundation / noports

Connect to any device with no external listening ports open
https://noports.com
BSD 3-Clause "New" or "Revised" License
271 stars 15 forks source link

sshnp/npt automatic retry and persistence #979

Closed cconstab closed 4 months ago

cconstab commented 6 months ago

Is your feature request related to a problem? Please describe.

sometimes TCP connections fail and that means sshnp/npt have to be re run. It would be great to have a flag to automatically retry if a connection fails. This would work well with client applications that auto retry as well for example RDP and OpenVPN, less so ssh

Describe the solution you'd like

--retry if connection drops re establish it This would likely require a -l to also be in place so client applications "know" how to reconnect

Describe alternatives you've considered

Having a --listen option A port would listen for a connection and establish it on demand. This would prevent constant retry and no connection locally being established and the npt/sshnp constantly connecting and disconnecting as no client app connected to the listening socket. So perhaps a max number of consecutive timeouts being a configurable limit ?

I like this solution too, but perhaps a combination is worth thinking about.

Additional context

No response

cconstab commented 6 months ago

To emulate this in production I have used a simple shell loop.. Which is VERY ugly

cconstab commented 6 months ago

@gkc I took a run through the code and I think I like the idea of exposing the scoket_connector defaultTimeout which currently is a static const.

Then enabling srv to set the timeout of the listening socket and add that option to npt and perhaps sshnp.

Thoughts welcome.

@cconstab

gkc commented 5 months ago

Have started work on this

gkc commented 5 months ago

Experimented with several different ways on this. Have concluded that for now the best aka simplest approach is to add a keepalive loop in the npt client. Keeping at 3SP for implementation in PR88

gkc commented 5 months ago

Implemented in PR #1110 and tagged @cconstab as reviewer ... hopefully not much more to do here, the impl works fine for all of my test scenarios and shows no backwards compatibility issues in the e2e tests. Reducing to 0 SP for this sprint