atsign-foundation / noports

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

Daemon shouldn't crash when asked to connect to an address that doesn't exist #7

Closed cpswan closed 2 years ago

cpswan commented 2 years ago

Describe the bug

Daemon crashes if asked to connect to a name that can't be found:

WARNING|2022-05-09 13:13:32.752313| sshnpd |ssh session started from: @cpswan session: e7a8f58b-3e99-4675-8aff-96b1533f8903

Unhandled exception:
SocketException: Failed host lookup: 'bad.name.net' (OS Error: Name or service not known, errno = -2)
#0      _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:682)
#1      _NativeSocket.connect (dart:io-patch/socket_patch.dart:948)
#2      _RawSocket.connect (dart:io-patch/socket_patch.dart:1805)
#3      RawSocket.connect (dart:io-patch/socket_patch.dart:21)
#4      Socket._connect (dart:io-patch/socket_patch.dart:2028)
#5      Socket.connect (dart:io/socket.dart:776)
#6      connectNativeSocket (package:dartssh2/src/socket/ssh_socket_io.dart:12)
#7      SSHSocket.connect (package:dartssh2/src/socket/ssh_socket.dart:13)
#8      sshCallback (file:///home/ubuntu/sshnoports/bin/sshnpd.dart:269)
<asynchronous suspension>

To Reproduce Steps to reproduce the behavior:

  1. First I made a typo in the host name I wanted to connect to ./sshnp/sshnp --from @cpswan --to @bareindoornetball --device demovm -h bad.name.net
  2. Then I realised that it should have been good.name.com
  3. But by then the daemon had crashed.

Expected behavior

Daemon catches the exception and stays up.

cconstab commented 2 years ago

Thanks for the bug report, will fix this for next release..

cconstab commented 2 years ago

FIxed, try block did not include the Socket.connect (doh).. Commited to trunk will be in next release