From f115ac4a272a8e0dbb40041cd0d362217ac16728 Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 8 Nov 2024 13:11:34 +0000 Subject: [PATCH 01/20] fix: fix issues seen in "multi" mode when a large number of sockets are created concurrently - added a missing trim() in srv_impl - take up v2.3.0 of socket_connector which ensures that `serverToSocket` introduces no delay in completing the tcp handshake --- apps/admin/admin_api/pubspec.lock | 38 +++++++++---------- .../noports_core/lib/src/srv/srv_impl.dart | 1 + packages/dart/noports_core/pubspec.yaml | 4 ++ packages/dart/sshnoports/pubspec.lock | 11 +++--- packages/dart/sshnoports/pubspec.yaml | 4 ++ 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/apps/admin/admin_api/pubspec.lock b/apps/admin/admin_api/pubspec.lock index afdb8893a..1646e8a2b 100644 --- a/apps/admin/admin_api/pubspec.lock +++ b/apps/admin/admin_api/pubspec.lock @@ -67,10 +67,10 @@ packages: dependency: transitive description: name: at_auth - sha256: "28f72f0fc26ec7f5f58d28fd29f964c9b2b35ecdc8dd4805ed7174851da2cbcc" + sha256: f4fec32e2a1ca8827604b5e54a7611ddad092c6ba607c138675c1cba5215b038 url: "https://pub.dev" source: hosted - version: "2.0.5" + version: "2.0.7" at_base2e15: dependency: transitive description: @@ -83,10 +83,10 @@ packages: dependency: transitive description: name: at_chops - sha256: "825171a3132b3756119bd16b6fd1fa6257f74a64babaf13cae2d82d53b8c6be1" + sha256: "7660aa2722fe5612e12e666bff2f19165f41ae8f90dd4b9c59dfd03365fb998e" url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.1.0" at_cli_commons: dependency: "direct main" description: @@ -99,18 +99,18 @@ packages: dependency: "direct main" description: name: at_client - sha256: "2e98fe0c0c520b8e7ad6dfd0ad53ecb97f1ceb33c9b117dda69417b72a067c60" + sha256: "50c7e5988fde978f41c4c3a12cc367f92b235193e9bc1567551765dc453b5f91" url: "https://pub.dev" source: hosted - version: "3.2.0" + version: "3.3.0" at_commons: dependency: transitive description: name: at_commons - sha256: "2d0490a0c5bcd43c6a37911d85b71c133767aec47abc65bd8ecb20c8caaddeab" + sha256: bf3ad3e13075833c47783b19b53f01f23b6c329e6fc050aa8ede249fffd18768 url: "https://pub.dev" source: hosted - version: "4.0.11" + version: "5.0.1" at_demo_data: dependency: transitive description: @@ -123,26 +123,26 @@ packages: dependency: transitive description: name: at_lookup - sha256: e989099d5f2cd6415097c8e4353340bd2048c9ee1bc82665f2b4f7c4615ad055 + sha256: "2fa727fbdd6d3e5a79132786a74cbf03776833e1671f8cb471d21585f8448f95" url: "https://pub.dev" source: hosted - version: "3.0.47" + version: "3.0.49" at_onboarding_cli: dependency: transitive description: name: at_onboarding_cli - sha256: fca7f5d96e83adf50057bccc6ebde3ec6562adfff99031894c781badf6daf623 + sha256: "9797347880162490efd47f06df8b26f667bff9e00d31d6ea176660c9b9ced06e" url: "https://pub.dev" source: hosted - version: "1.6.2" + version: "1.6.4" at_persistence_secondary_server: dependency: transitive description: name: at_persistence_secondary_server - sha256: "1ec73b56e61b8aee94104ad4610c17cf07e366239337bedd43fa80c7765a391d" + sha256: f312dc1827648bbdeb55f8e9867c232ef38f0dde64025ff5b3d339050483c5ea url: "https://pub.dev" source: hosted - version: "3.0.63" + version: "3.0.65" at_persistence_spec: dependency: transitive description: @@ -155,10 +155,10 @@ packages: dependency: transitive description: name: at_server_status - sha256: "316c3e6717592677207d4f0a836b013271ca0f729e8b575c9195d19cfc57e71b" + sha256: "2773fa7c4377802b671f6854863214aabe8ee8cd49be87226352dd14562a5d6b" url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "1.0.5" at_utf7: dependency: transitive description: @@ -171,10 +171,10 @@ packages: dependency: transitive description: name: at_utils - sha256: ec28600e4eec321ee5e22be051109fa7b2e94590dc51d9f957730c2540beb681 + sha256: b4461b0743f323429d57c387e91186537df8a6aeb4608bbeb6c2adf01d9f08f9 url: "https://pub.dev" source: hosted - version: "3.0.16" + version: "3.0.19" boolean_selector: dependency: transitive description: @@ -613,7 +613,7 @@ packages: path: "../../../packages/dart/noports_core" relative: true source: path - version: "6.1.0" + version: "6.2.0" openssh_ed25519: dependency: transitive description: diff --git a/packages/dart/noports_core/lib/src/srv/srv_impl.dart b/packages/dart/noports_core/lib/src/srv/srv_impl.dart index ff7ef7340..0bfa16325 100644 --- a/packages/dart/noports_core/lib/src/srv/srv_impl.dart +++ b/packages/dart/noports_core/lib/src/srv/srv_impl.dart @@ -635,6 +635,7 @@ class SrvImplDart implements Srv { List hosts, String request, ) async { + request = request.trim(); List args = request.split(":"); switch (args.first) { case 'connect': diff --git a/packages/dart/noports_core/pubspec.yaml b/packages/dart/noports_core/pubspec.yaml index 3c62e45e6..d7b897ff6 100644 --- a/packages/dart/noports_core/pubspec.yaml +++ b/packages/dart/noports_core/pubspec.yaml @@ -27,6 +27,10 @@ dependencies: json_annotation: ^4.9.0 dependency_overrides: + socket_connector: + git: + url: https://github.com/atsign-foundation/socket_connector + ref: gkc/2.3.0 dartssh2: git: url: https://github.com/atsign-foundation/dartssh2 diff --git a/packages/dart/sshnoports/pubspec.lock b/packages/dart/sshnoports/pubspec.lock index 3779d0d4e..595ee38fc 100644 --- a/packages/dart/sshnoports/pubspec.lock +++ b/packages/dart/sshnoports/pubspec.lock @@ -725,11 +725,12 @@ packages: socket_connector: dependency: "direct main" description: - name: socket_connector - sha256: "3c641546699aa58e9ab8be9841627a30af3c1ffcf4461ca5d00d7c56392ab63a" - url: "https://pub.dev" - source: hosted - version: "2.2.0" + path: "." + ref: "gkc/2.3.0" + resolved-ref: "193a5294ea0a1b36818797063142cee137e35967" + url: "https://github.com/atsign-foundation/socket_connector" + source: git + version: "2.3.0" source_map_stack_trace: dependency: transitive description: diff --git a/packages/dart/sshnoports/pubspec.yaml b/packages/dart/sshnoports/pubspec.yaml index 05989a329..b9c773560 100644 --- a/packages/dart/sshnoports/pubspec.yaml +++ b/packages/dart/sshnoports/pubspec.yaml @@ -23,6 +23,10 @@ dependencies: yaml: 3.1.2 dependency_overrides: + socket_connector: + git: + url: https://github.com/atsign-foundation/socket_connector + ref: gkc/2.3.0 dartssh2: git: url: https://github.com/atsign-foundation/dartssh2 From a3522523eec75f497c413e54ff7ba3becb38f64d Mon Sep 17 00:00:00 2001 From: gkc Date: Tue, 12 Nov 2024 15:40:57 +0000 Subject: [PATCH 02/20] build: take up socket_connector 2.3.1 fix: as good practice, added calls to `await socket.flush()` everywhere we're writing stuff to sockets in srv_impl.dart test: added a feature to sshnpd whereby if `INLINE_SRV` is in the environment and set to `true`, then we run the Srv inline rather than forking it in a separate process. This is super useful for debugging srv issues on the daemon side. --- .../noports_core/lib/src/srv/srv_impl.dart | 16 ++- ...nature_verifying_socket_authenticator.dart | 5 +- .../lib/src/srvd/socket_connector.dart | 18 +-- .../lib/src/sshnpd/sshnpd_impl.dart | 47 ++++--- packages/dart/noports_core/pubspec.yaml | 6 +- packages/dart/npt_flutter/pubspec.yaml | 2 +- packages/dart/sshnoports/pubspec.lock | 124 ++++++++++-------- packages/dart/sshnoports/pubspec.yaml | 6 +- packages/dart/sshnp_flutter/pubspec.yaml | 2 +- 9 files changed, 132 insertions(+), 94 deletions(-) diff --git a/packages/dart/noports_core/lib/src/srv/srv_impl.dart b/packages/dart/noports_core/lib/src/srv/srv_impl.dart index 0bfa16325..1befd1cc7 100644 --- a/packages/dart/noports_core/lib/src/srv/srv_impl.dart +++ b/packages/dart/noports_core/lib/src/srv/srv_impl.dart @@ -487,6 +487,7 @@ class SrvImplDart implements Srv { logger.info('_runClientSideSingle authenticating' ' new connection to rvd'); sideB.socket.writeln(rvdAuthString); + await sideB.socket.flush(); } }, ); @@ -507,6 +508,7 @@ class SrvImplDart implements Srv { logger.info('_runClientSideMulti authenticating' ' control socket connection to rvd'); sessionControlSocket.writeln(rvdAuthString); + await sessionControlSocket.flush(); } if (sessionAESKeyString != null && sessionIVString != null) { @@ -555,7 +557,7 @@ class SrvImplDart implements Srv { logger: ioSinkForLogger(logger), multi: multi, timeout: timeout, - beforeJoining: (Side sideA, Side sideB) { + beforeJoining: (Side sideA, Side sideB) async { logger.info('_runClientSideMulti Sending connect request'); sessionControlSocket .add(Uint8List.fromList('connect:no:encrypt\n'.codeUnits)); @@ -564,6 +566,7 @@ class SrvImplDart implements Srv { logger .info('_runClientSideMulti authenticating new connection to rvd'); sideB.socket.writeln(rvdAuthString); + await sideB.socket.flush(); } }, ); @@ -608,7 +611,8 @@ class SrvImplDart implements Srv { logger: ioSinkForLogger(logger), multi: multi, timeout: timeout, - beforeJoining: (Side sideA, Side sideB) { + // backlog: 4096, + beforeJoining: (Side sideA, Side sideB) async { logger.info('_runClientSideMulti Sending connect request'); String socketAESKey = @@ -622,6 +626,7 @@ class SrvImplDart implements Srv { logger .info('_runClientSideMulti authenticating new connection to rvd'); sideB.socket.writeln(rvdAuthString); + await sideB.socket.flush(); } sideA.transformer = createEncrypter(socketAESKey, socketIV); sideB.transformer = createDecrypter(socketAESKey, socketIV); @@ -655,6 +660,7 @@ class SrvImplDart implements Srv { logger.info('_runDaemonSideMulti authenticating' ' new socket connection to rvd'); sc.connections.last.sideB.socket.writeln(rvdAuthString); + await sc.connections.last.sideB.socket.flush(); } return; } else { @@ -681,6 +687,7 @@ class SrvImplDart implements Srv { logger.info('_runDaemonSideMulti authenticating' ' new socket connection to rvd'); sc.connections.last.sideB.socket.writeln(rvdAuthString); + await sc.connections.last.sideB.socket.flush(); } } break; @@ -705,6 +712,7 @@ class SrvImplDart implements Srv { logger.info('_runDaemonSideMulti authenticating' ' control socket connection to rvd'); sessionControlSocket.writeln(rvdAuthString); + await sessionControlSocket.flush(); } if (sessionAESKeyString != null && sessionIVString != null) { @@ -796,6 +804,9 @@ class SrvImplDart implements Srv { await _handleMultiConnectRequest(sc, hosts, 'connect:$request'); } } + } catch (e, st) { + logger.shout('Caught (will rethrow) error: $e\nStack Trace:\n$st'); + rethrow; } finally { controlStreamMutex.release(); } @@ -822,6 +833,7 @@ class SrvImplDart implements Srv { if (rvdAuthString != null) { logger.info('_runDaemonSideSingle authenticating socketB to rvd'); socketConnector.connections.first.sideB.socket.writeln(rvdAuthString); + await socketConnector.connections.first.sideB.socket.flush(); } return socketConnector; diff --git a/packages/dart/noports_core/lib/src/srvd/signature_verifying_socket_authenticator.dart b/packages/dart/noports_core/lib/src/srvd/signature_verifying_socket_authenticator.dart index 3eb650015..744a84df9 100644 --- a/packages/dart/noports_core/lib/src/srvd/signature_verifying_socket_authenticator.dart +++ b/packages/dart/noports_core/lib/src/srvd/signature_verifying_socket_authenticator.dart @@ -140,7 +140,10 @@ class SignatureAuthVerifier { } } } - }, onError: (error) => sc.addError(error), onDone: () => sc.close()); + }, onError: (Object error, StackTrace stackTrace) { + sc.addError(error); + sc.close(); + }, onDone: () => sc.close()); return completer.future; } } diff --git a/packages/dart/noports_core/lib/src/srvd/socket_connector.dart b/packages/dart/noports_core/lib/src/srvd/socket_connector.dart index f6fd155c9..101752b97 100644 --- a/packages/dart/noports_core/lib/src/srvd/socket_connector.dart +++ b/packages/dart/noports_core/lib/src/srvd/socket_connector.dart @@ -92,14 +92,16 @@ void socketConnector(ConnectorParams connectorParams) async { /// Create the socket connector SocketConnector connector = await SocketConnector.serverToServer( - addressA: InternetAddress.anyIPv4, - addressB: InternetAddress.anyIPv4, - portA: portA, - portB: portB, - verbose: verbose, - logTraffic: logTraffic, - socketAuthVerifierA: socketAuthVerifierA, - socketAuthVerifierB: socketAuthVerifierB); + addressA: InternetAddress.anyIPv4, + addressB: InternetAddress.anyIPv4, + portA: portA, + portB: portB, + verbose: verbose, + logTraffic: logTraffic, + socketAuthVerifierA: socketAuthVerifierA, + socketAuthVerifierB: socketAuthVerifierB, + // backlog: 20000, + ); /// Get the assigned ports from the socket connector portA = connector.sideAPort!; diff --git a/packages/dart/noports_core/lib/src/sshnpd/sshnpd_impl.dart b/packages/dart/noports_core/lib/src/sshnpd/sshnpd_impl.dart index bab5b8d9c..41506ebe1 100644 --- a/packages/dart/noports_core/lib/src/sshnpd/sshnpd_impl.dart +++ b/packages/dart/noports_core/lib/src/sshnpd/sshnpd_impl.dart @@ -16,6 +16,7 @@ import 'package:noports_core/sshnpd.dart'; import 'package:noports_core/npa.dart'; import 'package:noports_core/utils.dart'; import 'package:noports_core/src/version.dart'; +import 'package:socket_connector/socket_connector.dart'; import 'package:uuid/uuid.dart'; @protected @@ -596,21 +597,37 @@ class SshnpdImpl implements Sshnpd { 'No handling for ephemeralPKType ${req.clientEphemeralPKType}'); } } - // Connect to rendezvous point using background process. - // This program can then exit without causing an issue. - Process rv = await Srv.exec( - req.rvdHost, - req.rvdPort, - localPort: req.requestedPort, - bindLocalPort: false, - localHost: req.requestedHost, - rvdAuthString: rvdAuthString, - sessionAESKeyString: sessionAESKey, - sessionIVString: sessionIV, - multi: true, - timeout: req.timeout, - ).run(); - logger.info('Started rv - pid is ${rv.pid}'); + if (Platform.environment['INLINE_SRV'] == 'true') { + SocketConnector sc = await Srv.dart( + req.rvdHost, + req.rvdPort, + localPort: req.requestedPort, + bindLocalPort: false, + localHost: req.requestedHost, + rvdAuthString: rvdAuthString, + sessionAESKeyString: sessionAESKey, + sessionIVString: sessionIV, + multi: true, + timeout: req.timeout, + ).run(); + logger.info('Started rv INLINE - socket connector $sc'); + } else { + // Connect to rendezvous point using background process. + // This program can then exit without causing an issue. + Process rv = await Srv.exec( + req.rvdHost, + req.rvdPort, + localPort: req.requestedPort, + bindLocalPort: false, + localHost: req.requestedHost, + rvdAuthString: rvdAuthString, + sessionAESKeyString: sessionAESKey, + sessionIVString: sessionIV, + multi: true, + timeout: req.timeout, + ).run(); + logger.info('Started rv - pid is ${rv.pid}'); + } /// - Send response message to the sshnp client which includes the /// ephemeral private key diff --git a/packages/dart/noports_core/pubspec.yaml b/packages/dart/noports_core/pubspec.yaml index d7b897ff6..9d24c52d0 100644 --- a/packages/dart/noports_core/pubspec.yaml +++ b/packages/dart/noports_core/pubspec.yaml @@ -21,16 +21,12 @@ dependencies: openssh_ed25519: ^1.1.0 path: ^1.9.0 posix: ^6.0.1 - socket_connector: ^2.2.0 + socket_connector: ^2.3.1 uuid: ^3.0.7 mutex: ^3.1.0 json_annotation: ^4.9.0 dependency_overrides: - socket_connector: - git: - url: https://github.com/atsign-foundation/socket_connector - ref: gkc/2.3.0 dartssh2: git: url: https://github.com/atsign-foundation/dartssh2 diff --git a/packages/dart/npt_flutter/pubspec.yaml b/packages/dart/npt_flutter/pubspec.yaml index 7ba9c4d1a..409e029f6 100644 --- a/packages/dart/npt_flutter/pubspec.yaml +++ b/packages/dart/npt_flutter/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: path: ^1.9.0 path_provider: ^2.1.4 phosphor_flutter: ^2.1.0 - socket_connector: ^2.2.0 + socket_connector: ^2.3.1 toml: ^0.16.0 tray_manager: ^0.2.3 url_launcher: ^6.3.0 diff --git a/packages/dart/sshnoports/pubspec.lock b/packages/dart/sshnoports/pubspec.lock index 595ee38fc..b9e8e6c7e 100644 --- a/packages/dart/sshnoports/pubspec.lock +++ b/packages/dart/sshnoports/pubspec.lock @@ -5,18 +5,23 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" + sha256: "45cfa8471b89fb6643fe9bf51bd7931a76b8f5ec2d65de4fb176dba8d4f22c77" url: "https://pub.dev" source: hosted - version: "67.0.0" + version: "73.0.0" + _macros: + dependency: transitive + description: dart + source: sdk + version: "0.3.2" analyzer: dependency: transitive description: name: analyzer - sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" + sha256: "4959fec185fe70cce007c57e9ab6983101dbe593d2bf8bbfb4453aaec0cf470a" url: "https://pub.dev" source: hosted - version: "6.4.1" + version: "6.8.0" archive: dependency: transitive description: @@ -38,18 +43,18 @@ packages: dependency: transitive description: name: asn1lib - sha256: bf1a19d6ebea1b3b6151304936955d7d73e1f00b75e544c01a60fb2e832ffe1d + sha256: "4bae5ae63e6d6dd17c4aac8086f3dec26c0236f6a0f03416c6c19d830c367cf5" url: "https://pub.dev" source: hosted - version: "1.5.6" + version: "1.5.8" async: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.12.0" at_auth: dependency: transitive description: @@ -70,10 +75,10 @@ packages: dependency: transitive description: name: at_chops - sha256: "0b3d84b8bd2e5027946253d907ff23f967922105efe27432b15743beb74b31f8" + sha256: "7660aa2722fe5612e12e666bff2f19165f41ae8f90dd4b9c59dfd03365fb998e" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.0" at_cli_commons: dependency: "direct main" description: @@ -94,10 +99,10 @@ packages: dependency: transitive description: name: at_commons - sha256: "796eb7f49ab8894782010146368b4ae4f9ed716f2174c29c37d5c53b81281ff6" + sha256: bf3ad3e13075833c47783b19b53f01f23b6c329e6fc050aa8ede249fffd18768 url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.0.1" at_demo_data: dependency: transitive description: @@ -126,10 +131,10 @@ packages: dependency: transitive description: name: at_persistence_secondary_server - sha256: "387ff2853ee98a8c65526e1df9220fa58c4631b9b1cd6002e9a7372f1a491ed3" + sha256: f312dc1827648bbdeb55f8e9867c232ef38f0dde64025ff5b3d339050483c5ea url: "https://pub.dev" source: hosted - version: "3.0.64" + version: "3.0.65" at_persistence_spec: dependency: transitive description: @@ -166,10 +171,10 @@ packages: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" build: dependency: transitive description: @@ -270,42 +275,42 @@ packages: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" code_builder: dependency: transitive description: name: code_builder - sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37 + sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e" url: "https://pub.dev" source: hosted - version: "4.10.0" + version: "4.10.1" collection: dependency: transitive description: name: collection - sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.19.0" + version: "1.19.1" convert: dependency: transitive description: name: convert - sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.2" coverage: dependency: transitive description: name: coverage - sha256: c1fb2dce3c0085f39dc72668e85f8e0210ec7de05345821ff58530567df345a5 + sha256: "4b03e11f6d5b8f6e5bb5e9f7889a56fe6c5cbe942da5378ea4d4d7f73ef9dfe5" url: "https://pub.dev" source: hosted - version: "1.9.2" + version: "1.11.0" cron: dependency: transitive description: @@ -318,10 +323,10 @@ packages: dependency: transitive description: name: crypto - sha256: ec30d999af904f33454ba22ed9a86162b35e52b44ac4807d1d93c288041d7d27 + sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.6" cryptography: dependency: transitive description: @@ -342,18 +347,18 @@ packages: dependency: transitive description: name: dart_periphery - sha256: "03fef538e07124346ca89e214c34e505e6ff2d2766d7927cac099bae53601113" + sha256: "792a5350473c1632377dd4d542b7fa4716771658c08eda5afffc1fe55abd9bcf" url: "https://pub.dev" source: hosted - version: "0.9.6" + version: "0.9.8" dart_style: dependency: transitive description: name: dart_style - sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9" + sha256: "7856d364b589d1f08986e140938578ed36ed948581fbc3bc9aef1805039ac5ab" url: "https://pub.dev" source: hosted - version: "2.3.6" + version: "2.3.7" dartssh2: dependency: "direct main" description: @@ -415,10 +420,10 @@ packages: dependency: transitive description: name: fixnum - sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" frontend_server_client: dependency: transitive description: @@ -471,18 +476,18 @@ packages: dependency: transitive description: name: http_parser - sha256: "40f592dd352890c3b60fec1b68e786cefb9603e05ff303dbc4dda49b304ecdf4" + sha256: "76d306a1c3afb33fe82e2bbacad62a61f409b5634c915fceb0d799de1a913360" url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "4.1.1" image: dependency: transitive description: name: image - sha256: "2237616a36c0d69aef7549ab439b833fb7f9fb9fc861af2cc9ac3eedddd69ca8" + sha256: f31d52537dc417fdcde36088fdf11d191026fd5e4fae742491ebd40e5a8bea7d url: "https://pub.dev" source: hosted - version: "4.2.0" + version: "4.3.0" internet_connection_checker: dependency: transitive description: @@ -531,6 +536,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + macros: + dependency: transitive + description: + name: macros + sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" + url: "https://pub.dev" + source: hosted + version: "0.1.2-main.4" matcher: dependency: transitive description: @@ -614,10 +627,10 @@ packages: dependency: transitive description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" petitparser: dependency: transitive description: @@ -638,10 +651,10 @@ packages: dependency: transitive description: name: platform - sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65" + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" url: "https://pub.dev" source: hosted - version: "3.1.5" + version: "3.1.6" pointycastle: dependency: transitive description: @@ -670,10 +683,10 @@ packages: dependency: transitive description: name: process - sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32" + sha256: "107d8be718f120bbba9dcd1e95e3bd325b1b4a4f07db64154635ba03f2567a0d" url: "https://pub.dev" source: hosted - version: "5.0.2" + version: "5.0.3" pub_semver: dependency: transitive description: @@ -725,12 +738,11 @@ packages: socket_connector: dependency: "direct main" description: - path: "." - ref: "gkc/2.3.0" - resolved-ref: "193a5294ea0a1b36818797063142cee137e35967" - url: "https://github.com/atsign-foundation/socket_connector" - source: git - version: "2.3.0" + name: socket_connector + sha256: "95ce53f88b6c4d392ccec508dd08de09988307e6ce4dc0cfac3d5aa725a7320a" + url: "https://pub.dev" + source: hosted + version: "2.3.1" source_map_stack_trace: dependency: transitive description: @@ -783,10 +795,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" + sha256: "0bd04f5bb74fcd6ff0606a888a30e917af9bd52820b178eaa464beb11dca84b6" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.0" term_glyph: dependency: transitive description: @@ -831,10 +843,10 @@ packages: dependency: transitive description: name: typed_data - sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 url: "https://pub.dev" source: hosted - version: "1.3.2" + version: "1.4.0" uuid: dependency: transitive description: @@ -855,10 +867,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" url: "https://pub.dev" source: hosted - version: "14.3.0" + version: "14.3.1" watcher: dependency: transitive description: diff --git a/packages/dart/sshnoports/pubspec.yaml b/packages/dart/sshnoports/pubspec.yaml index b9c773560..f35e907e5 100644 --- a/packages/dart/sshnoports/pubspec.yaml +++ b/packages/dart/sshnoports/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: at_cli_commons: 1.2.1 at_client: 3.3.0 args: 2.5.0 - socket_connector: 2.2.0 + socket_connector: 2.3.1 dartssh2: 2.8.2 duration: 4.0.3 at_utils: 3.0.19 @@ -23,10 +23,6 @@ dependencies: yaml: 3.1.2 dependency_overrides: - socket_connector: - git: - url: https://github.com/atsign-foundation/socket_connector - ref: gkc/2.3.0 dartssh2: git: url: https://github.com/atsign-foundation/dartssh2 diff --git a/packages/dart/sshnp_flutter/pubspec.yaml b/packages/dart/sshnp_flutter/pubspec.yaml index 03b708317..5f9dbc51e 100644 --- a/packages/dart/sshnp_flutter/pubspec.yaml +++ b/packages/dart/sshnp_flutter/pubspec.yaml @@ -49,7 +49,7 @@ dependencies: path: ^1.8.3 path_provider: ^2.1.3 shared_preferences: ^2.2.2 - socket_connector: ^2.0.1 + socket_connector: ^2.3.1 url_launcher: ^6.1.14 uuid: ^3.0.7 window_manager: ^0.3.8 From cdb69630f9968ca0a7eeb3215bbc00c5d09aa608 Mon Sep 17 00:00:00 2001 From: gkc Date: Tue, 12 Nov 2024 15:47:50 +0000 Subject: [PATCH 03/20] chore: removed some commented-out code --- packages/dart/noports_core/lib/src/srv/srv_impl.dart | 1 - packages/dart/noports_core/lib/src/srvd/socket_connector.dart | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/dart/noports_core/lib/src/srv/srv_impl.dart b/packages/dart/noports_core/lib/src/srv/srv_impl.dart index 1befd1cc7..e44f1da48 100644 --- a/packages/dart/noports_core/lib/src/srv/srv_impl.dart +++ b/packages/dart/noports_core/lib/src/srv/srv_impl.dart @@ -611,7 +611,6 @@ class SrvImplDart implements Srv { logger: ioSinkForLogger(logger), multi: multi, timeout: timeout, - // backlog: 4096, beforeJoining: (Side sideA, Side sideB) async { logger.info('_runClientSideMulti Sending connect request'); diff --git a/packages/dart/noports_core/lib/src/srvd/socket_connector.dart b/packages/dart/noports_core/lib/src/srvd/socket_connector.dart index 101752b97..e24932d3d 100644 --- a/packages/dart/noports_core/lib/src/srvd/socket_connector.dart +++ b/packages/dart/noports_core/lib/src/srvd/socket_connector.dart @@ -100,7 +100,6 @@ void socketConnector(ConnectorParams connectorParams) async { logTraffic: logTraffic, socketAuthVerifierA: socketAuthVerifierA, socketAuthVerifierB: socketAuthVerifierB, - // backlog: 20000, ); /// Get the assigned ports from the socket connector From d56a176b2410ecf19c7a0434915f180155da7458 Mon Sep 17 00:00:00 2001 From: gkc Date: Tue, 12 Nov 2024 17:37:30 +0000 Subject: [PATCH 04/20] fix: fix race condition introduced by previous commits --- packages/dart/noports_core/lib/src/srv/srv_impl.dart | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/dart/noports_core/lib/src/srv/srv_impl.dart b/packages/dart/noports_core/lib/src/srv/srv_impl.dart index e44f1da48..b2d9545db 100644 --- a/packages/dart/noports_core/lib/src/srv/srv_impl.dart +++ b/packages/dart/noports_core/lib/src/srv/srv_impl.dart @@ -480,14 +480,13 @@ class SrvImplDart implements Srv { transformBtoA: decrypter, multi: multi, timeout: timeout, - beforeJoining: (Side sideA, Side sideB) async { + beforeJoining: (Side sideA, Side sideB) { logger.info('beforeJoining called'); // Authenticate the sideB socket (to the rvd) if (rvdAuthString != null) { logger.info('_runClientSideSingle authenticating' ' new connection to rvd'); sideB.socket.writeln(rvdAuthString); - await sideB.socket.flush(); } }, ); @@ -557,7 +556,7 @@ class SrvImplDart implements Srv { logger: ioSinkForLogger(logger), multi: multi, timeout: timeout, - beforeJoining: (Side sideA, Side sideB) async { + beforeJoining: (Side sideA, Side sideB) { logger.info('_runClientSideMulti Sending connect request'); sessionControlSocket .add(Uint8List.fromList('connect:no:encrypt\n'.codeUnits)); @@ -566,7 +565,6 @@ class SrvImplDart implements Srv { logger .info('_runClientSideMulti authenticating new connection to rvd'); sideB.socket.writeln(rvdAuthString); - await sideB.socket.flush(); } }, ); @@ -611,7 +609,7 @@ class SrvImplDart implements Srv { logger: ioSinkForLogger(logger), multi: multi, timeout: timeout, - beforeJoining: (Side sideA, Side sideB) async { + beforeJoining: (Side sideA, Side sideB) { logger.info('_runClientSideMulti Sending connect request'); String socketAESKey = @@ -625,7 +623,6 @@ class SrvImplDart implements Srv { logger .info('_runClientSideMulti authenticating new connection to rvd'); sideB.socket.writeln(rvdAuthString); - await sideB.socket.flush(); } sideA.transformer = createEncrypter(socketAESKey, socketIV); sideB.transformer = createDecrypter(socketAESKey, socketIV); From b37277da9e311ab44dd635ad41bf8876bd3553c7 Mon Sep 17 00:00:00 2001 From: gkc Date: Tue, 12 Nov 2024 17:59:27 +0000 Subject: [PATCH 05/20] fix: fix race condition introduced by previous commits --- packages/dart/noports_core/lib/src/srv/srv_impl.dart | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/dart/noports_core/lib/src/srv/srv_impl.dart b/packages/dart/noports_core/lib/src/srv/srv_impl.dart index b2d9545db..cbb1904c1 100644 --- a/packages/dart/noports_core/lib/src/srv/srv_impl.dart +++ b/packages/dart/noports_core/lib/src/srv/srv_impl.dart @@ -507,7 +507,6 @@ class SrvImplDart implements Srv { logger.info('_runClientSideMulti authenticating' ' control socket connection to rvd'); sessionControlSocket.writeln(rvdAuthString); - await sessionControlSocket.flush(); } if (sessionAESKeyString != null && sessionIVString != null) { @@ -656,7 +655,6 @@ class SrvImplDart implements Srv { logger.info('_runDaemonSideMulti authenticating' ' new socket connection to rvd'); sc.connections.last.sideB.socket.writeln(rvdAuthString); - await sc.connections.last.sideB.socket.flush(); } return; } else { @@ -683,7 +681,6 @@ class SrvImplDart implements Srv { logger.info('_runDaemonSideMulti authenticating' ' new socket connection to rvd'); sc.connections.last.sideB.socket.writeln(rvdAuthString); - await sc.connections.last.sideB.socket.flush(); } } break; @@ -708,7 +705,6 @@ class SrvImplDart implements Srv { logger.info('_runDaemonSideMulti authenticating' ' control socket connection to rvd'); sessionControlSocket.writeln(rvdAuthString); - await sessionControlSocket.flush(); } if (sessionAESKeyString != null && sessionIVString != null) { @@ -829,7 +825,6 @@ class SrvImplDart implements Srv { if (rvdAuthString != null) { logger.info('_runDaemonSideSingle authenticating socketB to rvd'); socketConnector.connections.first.sideB.socket.writeln(rvdAuthString); - await socketConnector.connections.first.sideB.socket.flush(); } return socketConnector; From c2314cc175b2748caaf4321866d2a733ca298c0d Mon Sep 17 00:00:00 2001 From: gkc Date: Tue, 12 Nov 2024 19:19:31 +0000 Subject: [PATCH 06/20] fix: take up socket_connector release candidate 2.3.2 --- packages/dart/sshnoports/pubspec.lock | 11 ++++++----- packages/dart/sshnoports/pubspec.yaml | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/dart/sshnoports/pubspec.lock b/packages/dart/sshnoports/pubspec.lock index b9e8e6c7e..73ca1fcc7 100644 --- a/packages/dart/sshnoports/pubspec.lock +++ b/packages/dart/sshnoports/pubspec.lock @@ -738,11 +738,12 @@ packages: socket_connector: dependency: "direct main" description: - name: socket_connector - sha256: "95ce53f88b6c4d392ccec508dd08de09988307e6ce4dc0cfac3d5aa725a7320a" - url: "https://pub.dev" - source: hosted - version: "2.3.1" + path: "." + ref: "fix-2.3.2" + resolved-ref: df601ce7b7b1e3ffab71a46e395f853abedb24b0 + url: "https://github.com/atsign-foundation/socket_connector" + source: git + version: "2.3.2" source_map_stack_trace: dependency: transitive description: diff --git a/packages/dart/sshnoports/pubspec.yaml b/packages/dart/sshnoports/pubspec.yaml index f35e907e5..37ccb70a3 100644 --- a/packages/dart/sshnoports/pubspec.yaml +++ b/packages/dart/sshnoports/pubspec.yaml @@ -23,6 +23,10 @@ dependencies: yaml: 3.1.2 dependency_overrides: + socket_connector: + git: + url: https://github.com/atsign-foundation/socket_connector + ref: fix-2.3.2 dartssh2: git: url: https://github.com/atsign-foundation/dartssh2 From fcc63faeaf54e0ba1e1914fe58531e405b7cddae Mon Sep 17 00:00:00 2001 From: gkc Date: Wed, 13 Nov 2024 13:20:26 +0000 Subject: [PATCH 07/20] build: take up socket_connector 2.3.2; nump noports_core package version --- packages/dart/noports_core/CHANGELOG.md | 2 ++ packages/dart/noports_core/pubspec.yaml | 4 ++-- packages/dart/npt_flutter/pubspec.yaml | 2 +- packages/dart/sshnoports/pubspec.yaml | 6 +----- packages/dart/sshnp_flutter/pubspec.yaml | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/dart/noports_core/CHANGELOG.md b/packages/dart/noports_core/CHANGELOG.md index a7eb27e78..3d6c3bb43 100644 --- a/packages/dart/noports_core/CHANGELOG.md +++ b/packages/dart/noports_core/CHANGELOG.md @@ -1,3 +1,5 @@ +# 6.2.1 +- fix: multiple enhancements for stability of `npt` under heavy concurrent load # 6.2.0 - feat: allow hyphens in device name # 6.1.1 diff --git a/packages/dart/noports_core/pubspec.yaml b/packages/dart/noports_core/pubspec.yaml index 9d24c52d0..a3616fa59 100644 --- a/packages/dart/noports_core/pubspec.yaml +++ b/packages/dart/noports_core/pubspec.yaml @@ -2,7 +2,7 @@ name: noports_core description: Core library code for sshnoports homepage: https://docs.atsign.com/ -version: 6.2.0 +version: 6.2.1 environment: sdk: ">=3.0.0 <4.0.0" @@ -21,7 +21,7 @@ dependencies: openssh_ed25519: ^1.1.0 path: ^1.9.0 posix: ^6.0.1 - socket_connector: ^2.3.1 + socket_connector: ^2.3.2 uuid: ^3.0.7 mutex: ^3.1.0 json_annotation: ^4.9.0 diff --git a/packages/dart/npt_flutter/pubspec.yaml b/packages/dart/npt_flutter/pubspec.yaml index 409e029f6..bcbde6a64 100644 --- a/packages/dart/npt_flutter/pubspec.yaml +++ b/packages/dart/npt_flutter/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: path: ^1.9.0 path_provider: ^2.1.4 phosphor_flutter: ^2.1.0 - socket_connector: ^2.3.1 + socket_connector: ^2.3.2 toml: ^0.16.0 tray_manager: ^0.2.3 url_launcher: ^6.3.0 diff --git a/packages/dart/sshnoports/pubspec.yaml b/packages/dart/sshnoports/pubspec.yaml index 37ccb70a3..ac7c8bfb5 100644 --- a/packages/dart/sshnoports/pubspec.yaml +++ b/packages/dart/sshnoports/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: at_cli_commons: 1.2.1 at_client: 3.3.0 args: 2.5.0 - socket_connector: 2.3.1 + socket_connector: 2.3.2 dartssh2: 2.8.2 duration: 4.0.3 at_utils: 3.0.19 @@ -23,10 +23,6 @@ dependencies: yaml: 3.1.2 dependency_overrides: - socket_connector: - git: - url: https://github.com/atsign-foundation/socket_connector - ref: fix-2.3.2 dartssh2: git: url: https://github.com/atsign-foundation/dartssh2 diff --git a/packages/dart/sshnp_flutter/pubspec.yaml b/packages/dart/sshnp_flutter/pubspec.yaml index 5f9dbc51e..380264ccd 100644 --- a/packages/dart/sshnp_flutter/pubspec.yaml +++ b/packages/dart/sshnp_flutter/pubspec.yaml @@ -49,7 +49,7 @@ dependencies: path: ^1.8.3 path_provider: ^2.1.3 shared_preferences: ^2.2.2 - socket_connector: ^2.3.1 + socket_connector: ^2.3.2 url_launcher: ^6.1.14 uuid: ^3.0.7 window_manager: ^0.3.8 From 0d6289192d569410848703eaf4096c5ec3a609ca Mon Sep 17 00:00:00 2001 From: gkc Date: Wed, 13 Nov 2024 14:03:44 +0000 Subject: [PATCH 08/20] build: bump noports_core version in sshnoports' pubspec --- packages/dart/sshnoports/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dart/sshnoports/pubspec.yaml b/packages/dart/sshnoports/pubspec.yaml index ac7c8bfb5..d893c2852 100644 --- a/packages/dart/sshnoports/pubspec.yaml +++ b/packages/dart/sshnoports/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: noports_core: path: "../noports_core" - version: 6.2.0 + version: 6.2.1 at_onboarding_cli: 1.7.0 at_cli_commons: 1.2.1 at_client: 3.3.0 From 719e9ecc1bd6a8138edd7c5d029b555e1a12ced8 Mon Sep 17 00:00:00 2001 From: gkc Date: Wed, 13 Nov 2024 20:18:25 +0000 Subject: [PATCH 09/20] build: bumping sshnoports version to 5.6.4 --- packages/dart/noports_core/lib/src/srv/srv_impl.dart | 2 +- packages/dart/noports_core/lib/src/version.dart | 2 +- packages/dart/sshnoports/lib/src/version.dart | 2 +- packages/dart/sshnoports/pubspec.lock | 11 +++++------ packages/dart/sshnoports/pubspec.yaml | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/dart/noports_core/lib/src/srv/srv_impl.dart b/packages/dart/noports_core/lib/src/srv/srv_impl.dart index cbb1904c1..f7afb2ff0 100644 --- a/packages/dart/noports_core/lib/src/srv/srv_impl.dart +++ b/packages/dart/noports_core/lib/src/srv/srv_impl.dart @@ -604,7 +604,7 @@ class SrvImplDart implements Srv { portA: localPort, addressB: hosts[0], portB: streamingPort, - verbose: false, + verbose: true, logger: ioSinkForLogger(logger), multi: multi, timeout: timeout, diff --git a/packages/dart/noports_core/lib/src/version.dart b/packages/dart/noports_core/lib/src/version.dart index 9a6891ccb..02b83466c 100644 --- a/packages/dart/noports_core/lib/src/version.dart +++ b/packages/dart/noports_core/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '6.2.0'; +const packageVersion = '6.2.1'; diff --git a/packages/dart/sshnoports/lib/src/version.dart b/packages/dart/sshnoports/lib/src/version.dart index eb03b5af9..297f7fdc6 100644 --- a/packages/dart/sshnoports/lib/src/version.dart +++ b/packages/dart/sshnoports/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '5.6.3'; +const packageVersion = '5.6.4'; diff --git a/packages/dart/sshnoports/pubspec.lock b/packages/dart/sshnoports/pubspec.lock index 73ca1fcc7..043196c5a 100644 --- a/packages/dart/sshnoports/pubspec.lock +++ b/packages/dart/sshnoports/pubspec.lock @@ -606,7 +606,7 @@ packages: path: "../noports_core" relative: true source: path - version: "6.2.0" + version: "6.2.1" openssh_ed25519: dependency: transitive description: @@ -738,11 +738,10 @@ packages: socket_connector: dependency: "direct main" description: - path: "." - ref: "fix-2.3.2" - resolved-ref: df601ce7b7b1e3ffab71a46e395f853abedb24b0 - url: "https://github.com/atsign-foundation/socket_connector" - source: git + name: socket_connector + sha256: ff14b1e5578c6ec677aed4f8dc30cbb59c7663c8118ab4e60bf302f4b6dd1dfc + url: "https://pub.dev" + source: hosted version: "2.3.2" source_map_stack_trace: dependency: transitive diff --git a/packages/dart/sshnoports/pubspec.yaml b/packages/dart/sshnoports/pubspec.yaml index d893c2852..405092324 100644 --- a/packages/dart/sshnoports/pubspec.yaml +++ b/packages/dart/sshnoports/pubspec.yaml @@ -1,7 +1,7 @@ name: sshnoports publish_to: none -version: 5.6.3 +version: 5.6.4 environment: sdk: ">=3.0.0 <4.0.0" From c18fe6cca86dabef16ab54f88e703ebf3f87439d Mon Sep 17 00:00:00 2001 From: gkc Date: Wed, 13 Nov 2024 20:34:43 +0000 Subject: [PATCH 10/20] build: use socket_connector 2.3.3 from git branch --- packages/dart/sshnoports/pubspec.lock | 11 ++++++----- packages/dart/sshnoports/pubspec.yaml | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/dart/sshnoports/pubspec.lock b/packages/dart/sshnoports/pubspec.lock index 043196c5a..39b161811 100644 --- a/packages/dart/sshnoports/pubspec.lock +++ b/packages/dart/sshnoports/pubspec.lock @@ -738,11 +738,12 @@ packages: socket_connector: dependency: "direct main" description: - name: socket_connector - sha256: ff14b1e5578c6ec677aed4f8dc30cbb59c7663c8118ab4e60bf302f4b6dd1dfc - url: "https://pub.dev" - source: hosted - version: "2.3.2" + path: "." + ref: "fix-2.3.3" + resolved-ref: "4a99b088b6232279e91613433cdbca8de446c1e8" + url: "https://github.com/atsign-foundation/socket_connector" + source: git + version: "2.3.3" source_map_stack_trace: dependency: transitive description: diff --git a/packages/dart/sshnoports/pubspec.yaml b/packages/dart/sshnoports/pubspec.yaml index 405092324..4b6479ca3 100644 --- a/packages/dart/sshnoports/pubspec.yaml +++ b/packages/dart/sshnoports/pubspec.yaml @@ -23,6 +23,10 @@ dependencies: yaml: 3.1.2 dependency_overrides: + socket_connector: + git: + url: https://github.com/atsign-foundation/socket_connector + ref: fix-2.3.3 dartssh2: git: url: https://github.com/atsign-foundation/dartssh2 From 3bf2fb7b838382a4fd06342449c77bde8d60edd6 Mon Sep 17 00:00:00 2001 From: gkc Date: Wed, 13 Nov 2024 20:37:59 +0000 Subject: [PATCH 11/20] feat: if "NP_TRACE" is in the environment as 'true' then set verbose:true when calling SocketConnector.serverToSocket --- packages/dart/noports_core/lib/src/srv/srv_impl.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dart/noports_core/lib/src/srv/srv_impl.dart b/packages/dart/noports_core/lib/src/srv/srv_impl.dart index f7afb2ff0..3dcd30ac8 100644 --- a/packages/dart/noports_core/lib/src/srv/srv_impl.dart +++ b/packages/dart/noports_core/lib/src/srv/srv_impl.dart @@ -604,7 +604,7 @@ class SrvImplDart implements Srv { portA: localPort, addressB: hosts[0], portB: streamingPort, - verbose: true, + verbose: Platform.environment['NP_TRACE'] == 'true', logger: ioSinkForLogger(logger), multi: multi, timeout: timeout, From c05b9e021a7ab536afce4aa7644c7c359d5a398e Mon Sep 17 00:00:00 2001 From: gkc Date: Thu, 14 Nov 2024 14:57:33 +0000 Subject: [PATCH 12/20] feat: stuff to help troubleshooting - if "SRV_TRACE" is in the environment as 'true' then set verbose:true when calling SocketConnector.serverToSocket - if "SRV_INLINE" is in the environment as 'true' then run the srv inside the sshnpd process rather than forking --- packages/dart/noports_core/lib/src/srv/srv_impl.dart | 12 ++++++------ .../noports_core/lib/src/sshnpd/sshnpd_impl.dart | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/dart/noports_core/lib/src/srv/srv_impl.dart b/packages/dart/noports_core/lib/src/srv/srv_impl.dart index 3dcd30ac8..c90646713 100644 --- a/packages/dart/noports_core/lib/src/srv/srv_impl.dart +++ b/packages/dart/noports_core/lib/src/srv/srv_impl.dart @@ -474,7 +474,7 @@ class SrvImplDart implements Srv { portA: localPort, addressB: hosts[0], portB: streamingPort, - verbose: false, + verbose: Platform.environment['SRV_TRACE'] == 'true', logger: ioSinkForLogger(logger), transformAtoB: encrypter, transformBtoA: decrypter, @@ -551,7 +551,7 @@ class SrvImplDart implements Srv { portA: localPort, addressB: hosts[0], portB: streamingPort, - verbose: false, + verbose: Platform.environment['SRV_TRACE'] == 'true', logger: ioSinkForLogger(logger), multi: multi, timeout: timeout, @@ -604,7 +604,7 @@ class SrvImplDart implements Srv { portA: localPort, addressB: hosts[0], portB: streamingPort, - verbose: Platform.environment['NP_TRACE'] == 'true', + verbose: Platform.environment['SRV_TRACE'] == 'true', logger: ioSinkForLogger(logger), multi: multi, timeout: timeout, @@ -649,7 +649,7 @@ class SrvImplDart implements Srv { portA: localPort, addressB: hosts[0], portB: streamingPort, - verbose: false, + verbose: Platform.environment['SRV_TRACE'] == 'true', logger: ioSinkForLogger(logger)); if (rvdAuthString != null) { logger.info('_runDaemonSideMulti authenticating' @@ -673,7 +673,7 @@ class SrvImplDart implements Srv { portA: localPort, addressB: hosts[0], portB: streamingPort, - verbose: false, + verbose: Platform.environment['SRV_TRACE'] == 'true', logger: ioSinkForLogger(logger), transformAtoB: createEncrypter(args[1], args[2]), transformBtoA: createDecrypter(args[1], args[2])); @@ -818,7 +818,7 @@ class SrvImplDart implements Srv { portA: localPort, addressB: hosts[0], portB: streamingPort, - verbose: false, + verbose: Platform.environment['SRV_TRACE'] == 'true', logger: ioSinkForLogger(logger), transformAtoB: encrypter, transformBtoA: decrypter); diff --git a/packages/dart/noports_core/lib/src/sshnpd/sshnpd_impl.dart b/packages/dart/noports_core/lib/src/sshnpd/sshnpd_impl.dart index 41506ebe1..c41be74d8 100644 --- a/packages/dart/noports_core/lib/src/sshnpd/sshnpd_impl.dart +++ b/packages/dart/noports_core/lib/src/sshnpd/sshnpd_impl.dart @@ -597,7 +597,7 @@ class SshnpdImpl implements Sshnpd { 'No handling for ephemeralPKType ${req.clientEphemeralPKType}'); } } - if (Platform.environment['INLINE_SRV'] == 'true') { + if (Platform.environment['SRV_INLINE'] == 'true') { SocketConnector sc = await Srv.dart( req.rvdHost, req.rvdPort, From cb6d209d9aa2351936c17c4c841dc139b97e6893 Mon Sep 17 00:00:00 2001 From: gkc Date: Thu, 14 Nov 2024 15:12:38 +0000 Subject: [PATCH 13/20] build: take up next candidate 2.3.3 socket_connector --- packages/dart/sshnoports/pubspec.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dart/sshnoports/pubspec.lock b/packages/dart/sshnoports/pubspec.lock index 39b161811..a233c39b2 100644 --- a/packages/dart/sshnoports/pubspec.lock +++ b/packages/dart/sshnoports/pubspec.lock @@ -740,7 +740,7 @@ packages: description: path: "." ref: "fix-2.3.3" - resolved-ref: "4a99b088b6232279e91613433cdbca8de446c1e8" + resolved-ref: "74f6a9affa1e43a4690b353ff140e699e918116f" url: "https://github.com/atsign-foundation/socket_connector" source: git version: "2.3.3" From 13c456851d107b952241122c4e36d343cd58e618 Mon Sep 17 00:00:00 2001 From: gkc Date: Thu, 14 Nov 2024 15:13:12 +0000 Subject: [PATCH 14/20] test: add a couple of simple programmes to help with testing where we want to shove lots of data around --- .../sshnoports/bin/demo_socket_client.dart | 32 +++++++++++++++++ .../sshnoports/bin/demo_socket_server.dart | 36 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 packages/dart/sshnoports/bin/demo_socket_client.dart create mode 100644 packages/dart/sshnoports/bin/demo_socket_server.dart diff --git a/packages/dart/sshnoports/bin/demo_socket_client.dart b/packages/dart/sshnoports/bin/demo_socket_client.dart new file mode 100644 index 000000000..af7c2be94 --- /dev/null +++ b/packages/dart/sshnoports/bin/demo_socket_client.dart @@ -0,0 +1,32 @@ +import 'dart:io'; + +/// - simple client which talks to a demo_socket_server +/// - sends a request for N kBytes of data to be sent to us +/// - listens for the data and writes a message at the end +/// saying how much it received vs expected +void main(List args) async { + // connect to socket on localhost, port args[0] + int port = int.parse(args[0]); + final socket = await Socket.connect('127.0.0.1', port); + + // send a request for N kBytes of data to be sent to us + int numKbsToRequest = int.parse(args[1]); + socket.writeln('$numKbsToRequest'); + + int expected = numKbsToRequest * 1024; + int received = 0; + socket.listen( + (data) { + received += data.length; + }, + onDone: () { + stdout.writeln('Received $received bytes ($expected expected)'); + exit(0); + }, + onError: (err) { + stdout.writeln('Error: $err'); + stdout.writeln('Received $received bytes ($expected expected)'); + exit(0); + }, + ); +} diff --git a/packages/dart/sshnoports/bin/demo_socket_server.dart b/packages/dart/sshnoports/bin/demo_socket_server.dart new file mode 100644 index 000000000..1269df94c --- /dev/null +++ b/packages/dart/sshnoports/bin/demo_socket_server.dart @@ -0,0 +1,36 @@ +import 'dart:io'; + +/// Simple server program which binds to port args[0] and then, +/// for each new socket connection +/// - listens for a request to send data (see demo_socket_client.dart) +/// - sends that much data +/// - closes the socket +/// +/// Sample usage: +/// - dart demo_socket_server.dart 12345 +/// - dart demo_socket_client.dart 12345 +void main(List args) async { + + int port = int.parse(args[0]); + final server = await ServerSocket.bind( + InternetAddress.loopbackIPv4, + port, + ); + + List kb = List.filled(1024, 65); + + server.listen((socket) { + stdout.writeln('New socket connection'); + socket.listen((bytes) async { + int numKbsToSend = int.parse(String.fromCharCodes(bytes)); + stdout.writeln('Received request to send $numKbsToSend kBytes'); + for (int i = 0; i < numKbsToSend; i++) { + socket.add(kb); + } + await socket.flush(); + stdout.writeln('Wrote $numKbsToSend kBytes'); + socket.destroy(); + stdout.writeln('Socket closed.\n'); + }); + }); +} \ No newline at end of file From 33de44920896ba4b48f4dfd57abca6b8d7efc994 Mon Sep 17 00:00:00 2001 From: gkc Date: Thu, 14 Nov 2024 15:19:27 +0000 Subject: [PATCH 15/20] test: add a couple of simple programmes to help with testing where we want to shove lots of data around --- packages/dart/sshnoports/bin/demo_socket_client.dart | 1 + packages/dart/sshnoports/bin/demo_socket_server.dart | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/dart/sshnoports/bin/demo_socket_client.dart b/packages/dart/sshnoports/bin/demo_socket_client.dart index af7c2be94..899d0128b 100644 --- a/packages/dart/sshnoports/bin/demo_socket_client.dart +++ b/packages/dart/sshnoports/bin/demo_socket_client.dart @@ -12,6 +12,7 @@ void main(List args) async { // send a request for N kBytes of data to be sent to us int numKbsToRequest = int.parse(args[1]); socket.writeln('$numKbsToRequest'); + await socket.flush(); int expected = numKbsToRequest * 1024; int received = 0; diff --git a/packages/dart/sshnoports/bin/demo_socket_server.dart b/packages/dart/sshnoports/bin/demo_socket_server.dart index 1269df94c..e3d0210cc 100644 --- a/packages/dart/sshnoports/bin/demo_socket_server.dart +++ b/packages/dart/sshnoports/bin/demo_socket_server.dart @@ -22,7 +22,11 @@ void main(List args) async { server.listen((socket) { stdout.writeln('New socket connection'); socket.listen((bytes) async { - int numKbsToSend = int.parse(String.fromCharCodes(bytes)); + String s = String.fromCharCodes(bytes); + if (s.trim().isEmpty) { + return; + } + int numKbsToSend = int.parse(s); stdout.writeln('Received request to send $numKbsToSend kBytes'); for (int i = 0; i < numKbsToSend; i++) { socket.add(kb); From 98467e6509786651612549a10a2a493bdfb75027 Mon Sep 17 00:00:00 2001 From: gkc Date: Thu, 14 Nov 2024 16:48:33 +0000 Subject: [PATCH 16/20] build: pubspec.lock update --- packages/dart/sshnoports/pubspec.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dart/sshnoports/pubspec.lock b/packages/dart/sshnoports/pubspec.lock index a233c39b2..5fd8d50ee 100644 --- a/packages/dart/sshnoports/pubspec.lock +++ b/packages/dart/sshnoports/pubspec.lock @@ -740,7 +740,7 @@ packages: description: path: "." ref: "fix-2.3.3" - resolved-ref: "74f6a9affa1e43a4690b353ff140e699e918116f" + resolved-ref: "10cb072d24f69a558289ffa6e397e6bda8e0f1f9" url: "https://github.com/atsign-foundation/socket_connector" source: git version: "2.3.3" From f6d176d6d67ecbc8582555c03f9a4795a82aa19f Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 15 Nov 2024 13:53:36 +0000 Subject: [PATCH 17/20] fix: npt: gracefully handle failures to connect to 'local' hosts / ports on the daemon side. Previously the entire npt session would end; now the client side just sees a socket closing immediately refactor: some refactoring for readability --- .../noports_core/lib/src/srv/srv_impl.dart | 205 ++++++++++++------ 1 file changed, 136 insertions(+), 69 deletions(-) diff --git a/packages/dart/noports_core/lib/src/srv/srv_impl.dart b/packages/dart/noports_core/lib/src/srv/srv_impl.dart index c90646713..c010c867d 100644 --- a/packages/dart/noports_core/lib/src/srv/srv_impl.dart +++ b/packages/dart/noports_core/lib/src/srv/srv_impl.dart @@ -406,7 +406,11 @@ class SrvImplDart implements Srv { @override Future run() async { try { - var hosts = await InternetAddress.lookup(streamingHost); + var relayAddresses = await InternetAddress.lookup(streamingHost); + if (relayAddresses.isEmpty) { + throw Exception('Cannot resolve relay host $streamingHost'); + } + InternetAddress relayAddress = relayAddresses[0]; late SocketConnector sc; // Determines whether the traffic in the socket is encrypted or transmitted in plain text. bool encryptRvdTraffic = @@ -418,9 +422,11 @@ class SrvImplDart implements Srv { (sessionAESKeyString == null || sessionIVString == null)) { throw ArgumentError('Symmetric session encryption key required'); } - sc = await _runClientSideMulti(hosts: hosts, timeout: timeout); + sc = await _runClientSideMulti( + relayAddress: relayAddress, timeout: timeout); } else { - sc = await _runClientSideSingle(hosts: hosts, timeout: timeout); + sc = await _runClientSideSingle( + relayAddress: relayAddress, timeout: timeout); } } else { // daemon side @@ -429,9 +435,10 @@ class SrvImplDart implements Srv { (sessionAESKeyString == null || sessionIVString == null)) { throw ArgumentError('Symmetric session encryption key required'); } - sc = await _runDaemonSideMulti(hosts: hosts, timeout: timeout); + sc = await _runDaemonSideMulti( + relayAddress: relayAddress, timeout: timeout); } else { - sc = await _runDaemonSideSingle(hosts: hosts); + sc = await _runDaemonSideSingle(relayAddress: relayAddress); } } @@ -460,7 +467,7 @@ class SrvImplDart implements Srv { } Future _runClientSideSingle({ - required List hosts, + required InternetAddress relayAddress, required Duration timeout, }) async { DataTransformer? encrypter; @@ -472,7 +479,7 @@ class SrvImplDart implements Srv { // client side SocketConnector sc = await SocketConnector.serverToSocket( portA: localPort, - addressB: hosts[0], + addressB: relayAddress, portB: streamingPort, verbose: Platform.environment['SRV_TRACE'] == 'true', logger: ioSinkForLogger(logger), @@ -494,7 +501,7 @@ class SrvImplDart implements Srv { } Future _runClientSideMulti({ - required List hosts, + required InternetAddress relayAddress, required Duration timeout, }) async { // client side @@ -513,12 +520,12 @@ class SrvImplDart implements Srv { logger .info('_runClientSideMulti: On the client-side traffic is encrypted'); socketConnector = await _clientSideEncryptedSocket( - sessionControlSocket, socketConnector, hosts, timeout); + sessionControlSocket, socketConnector, relayAddress, timeout); } else { logger.info( '_runClientSideMulti: On the client-side traffic is transmitted in plain text'); socketConnector = await _clientSidePlainSocket( - sessionControlSocket, socketConnector, hosts, timeout); + sessionControlSocket, socketConnector, relayAddress, timeout); } logger.info('_runClientSideMulti serverToSocket is ready'); @@ -534,7 +541,7 @@ class SrvImplDart implements Srv { Future _clientSidePlainSocket( Socket sessionControlSocket, SocketConnector? socketConnector, - List hosts, + InternetAddress relayAddress, Duration timeout) async { sessionControlSocket.listen((event) { String response = String.fromCharCodes(event).trim(); @@ -549,7 +556,7 @@ class SrvImplDart implements Srv { }); socketConnector = await SocketConnector.serverToSocket( portA: localPort, - addressB: hosts[0], + addressB: relayAddress, portB: streamingPort, verbose: Platform.environment['SRV_TRACE'] == 'true', logger: ioSinkForLogger(logger), @@ -574,7 +581,7 @@ class SrvImplDart implements Srv { Future _clientSideEncryptedSocket( Socket sessionControlSocket, SocketConnector? socketConnector, - List hosts, + InternetAddress relayAddress, Duration timeout) async { DataTransformer controlEncrypter = createEncrypter(sessionAESKeyString!, sessionIVString!); @@ -602,7 +609,7 @@ class SrvImplDart implements Srv { logger.info('_runClientSideMulti calling SocketConnector.serverToSocket'); socketConnector = await SocketConnector.serverToSocket( portA: localPort, - addressB: hosts[0], + addressB: relayAddress, portB: streamingPort, verbose: Platform.environment['SRV_TRACE'] == 'true', logger: ioSinkForLogger(logger), @@ -630,70 +637,111 @@ class SrvImplDart implements Srv { return socketConnector; } - Future _handleMultiConnectRequest( + Future _handleMultiConnectRequest( SocketConnector sc, - List hosts, + InternetAddress relayAddress, + DataTransformer? encrypter, + DataTransformer? decrypter, + ) async { + logger.info('_runDaemonSideMulti' + ' Control socket received connect request - ' + ' creating new socketToSocket connection'); + + InternetAddress localAddress = await resolveRequestedLocalHost(); + + // First, connect to the relay. + // If it fails, return, as we can't do anything more + late Socket sideBSocket; + late Side sideB; + logger.info( + 'socket_connector: Connecting side B (relay - $relayAddress:$streamingPort)'); + try { + sideBSocket = await Socket.connect(relayAddress, streamingPort); + sideB = Side(sideBSocket, false, transformer: decrypter); + unawaited(sideBSocket.done + .then((v) => logger.info('relay socket done')) + .catchError( + (err) => logger.warning('relay socket done with error $err'))); + if (rvdAuthString != null) { + logger.info('_runDaemonSideMulti authenticating' + ' new socket connection to relay'); + sideBSocket.writeln(rvdAuthString); + await sideBSocket.flush(); + } + } catch (e) { + logger.shout( + 'Failed to connect to relay ($relayAddress:$streamingPort) with error : $e'); + return; + } + + // Now, connect to the local host:port + // If it fails, we need to close the socket connection to the relay + late Socket sideASocket; + late Side sideA; + logger.info( + 'socket_connector: Connecting side A (local - $localAddress:$localPort)'); + + try { + sideASocket = await Socket.connect(localAddress, localPort); + sideA = Side(sideASocket, true, transformer: encrypter); + } catch (e) { + logger.shout( + 'Failed to connect locally ($localAddress:$localPort) with error : $e'); + logger.shout('Closing sideB (relay) socket connection'); + sideBSocket.destroy(); + + return; + } + + // Finally, let's have the socket connector join the sides together + unawaited(sc.handleSingleConnection(sideB).catchError((err) { + logger.severe( + 'ERROR $err from handleSingleConnection on sideB (relay - $relayAddress:$streamingPort)'); + })); + unawaited(sc.handleSingleConnection(sideA).catchError((err) { + logger.severe( + 'ERROR $err from handleSingleConnection on sideA (local - $localAddress:$localPort)'); + })); + + logger.info('socket_connector: started'); + } + + Future _handleControlRequest( + SocketConnector sc, + InternetAddress relayAddress, String request, ) async { request = request.trim(); List args = request.split(":"); + DataTransformer? encrypter; + DataTransformer? decrypter; switch (args.first) { case 'connect': - // Handles the request from the socket where data needs no encryption. - // When --no-encrypt-rvd-traffic flag is set to true. - if (request == 'connect:no:encrypt') { - await SocketConnector.socketToSocket( - connector: sc, - addressA: - (await InternetAddress.lookup(localHost ?? 'localhost'))[0], - portA: localPort, - addressB: hosts[0], - portB: streamingPort, - verbose: Platform.environment['SRV_TRACE'] == 'true', - logger: ioSinkForLogger(logger)); - if (rvdAuthString != null) { - logger.info('_runDaemonSideMulti authenticating' - ' new socket connection to rvd'); - sc.connections.last.sideB.socket.writeln(rvdAuthString); - } - return; - } else { - // In this case, the data in the socket is encrypted. + if (request != 'connect:no:encrypt') { if (args.length != 3) { logger.severe('Unknown request to control socket: [$request]'); return; } - logger.info('_runDaemonSideMulti' - ' Control socket received ${args.first} request - ' - ' creating new socketToSocket connection'); - await SocketConnector.socketToSocket( - connector: sc, - addressA: - (await InternetAddress.lookup(localHost ?? 'localhost'))[0], - portA: localPort, - addressB: hosts[0], - portB: streamingPort, - verbose: Platform.environment['SRV_TRACE'] == 'true', - logger: ioSinkForLogger(logger), - transformAtoB: createEncrypter(args[1], args[2]), - transformBtoA: createDecrypter(args[1], args[2])); - if (rvdAuthString != null) { - logger.info('_runDaemonSideMulti authenticating' - ' new socket connection to rvd'); - sc.connections.last.sideB.socket.writeln(rvdAuthString); - } + decrypter = createDecrypter(args[1], args[2]); + encrypter = createEncrypter(args[1], args[2]); } - break; + await _handleMultiConnectRequest( + sc, relayAddress, encrypter, decrypter); default: logger.severe('Unknown request to control socket: [$request]'); + return; } } Future _runDaemonSideMulti({ - required List hosts, + required InternetAddress relayAddress, required Duration timeout, }) async { - SocketConnector sc = SocketConnector(timeout: timeout); + SocketConnector sc = SocketConnector( + timeout: timeout, + verbose: Platform.environment['SRV_TRACE'] == 'true', + logger: ioSinkForLogger(logger), + ); // - create control socket and listen for requests // - for each request, create a socketToSocket connection @@ -710,11 +758,11 @@ class SrvImplDart implements Srv { if (sessionAESKeyString != null && sessionIVString != null) { logger .info('_runDaemonSideMulti: On the daemon side traffic is encrypted'); - _daemonSideEncryptedSocket(sessionControlSocket, sc, hosts); + _daemonSideEncryptedSocket(sessionControlSocket, sc, relayAddress); } else { logger.info( '_runDaemonSideMulti: On the daemon side traffic is transmitted in plain text'); - _daemonSidePlainSocket(sessionControlSocket, sc, hosts); + _daemonSidePlainSocket(sessionControlSocket, sc, relayAddress); } // upon socketConnector.done, destroy the control socket, and complete @@ -726,10 +774,11 @@ class SrvImplDart implements Srv { } void _daemonSidePlainSocket(Socket sessionControlSocket, SocketConnector sc, - List hosts) { + InternetAddress relayAddress) { Mutex controlStreamMutex = Mutex(); sessionControlSocket.listen((event) async { - await _sessionControlSocketListener(controlStreamMutex, event, sc, hosts); + await _sessionControlSocketListener( + controlStreamMutex, event, sc, relayAddress); }, onError: (e) { logger.severe('controlSocket error: $e'); sc.close(); @@ -740,7 +789,7 @@ class SrvImplDart implements Srv { } void _daemonSideEncryptedSocket(Socket sessionControlSocket, - SocketConnector sc, List hosts) { + SocketConnector sc, InternetAddress relayAddress) { DataTransformer controlEncrypter = createEncrypter(sessionAESKeyString!, sessionIVString!); DataTransformer controlDecrypter = @@ -755,7 +804,8 @@ class SrvImplDart implements Srv { Mutex controlStreamMutex = Mutex(); controlStream.listen((event) async { logger.info('Received event on control socket.'); - await _sessionControlSocketListener(controlStreamMutex, event, sc, hosts); + await _sessionControlSocketListener( + controlStreamMutex, event, sc, relayAddress); }, onError: (e) { logger.severe('controlSocket error: $e'); sc.close(); @@ -766,7 +816,7 @@ class SrvImplDart implements Srv { } Future _sessionControlSocketListener(Mutex controlStreamMutex, - List event, SocketConnector sc, List hosts) async { + List event, SocketConnector sc, InternetAddress relayAddress) async { try { await controlStreamMutex.acquire(); if (event.isEmpty) { @@ -793,7 +843,7 @@ class SrvImplDart implements Srv { List requests = eventStr.split('connect:'); for (String request in requests) { if (request.isNotEmpty) { - await _handleMultiConnectRequest(sc, hosts, 'connect:$request'); + await _handleControlRequest(sc, relayAddress, 'connect:$request'); } } } catch (e, st) { @@ -804,8 +854,23 @@ class SrvImplDart implements Srv { } } + Future resolveRequestedLocalHost() async { + String hostToLookup = localHost ?? 'localhost'; + List candidates = await InternetAddress.lookup( + hostToLookup, + type: InternetAddressType.IPv4); + if (candidates.isEmpty) { + candidates = await InternetAddress.lookup(hostToLookup, + type: InternetAddressType.IPv6); + } + if (candidates.isEmpty) { + throw Exception("Cannot resolve address for $hostToLookup"); + } + return candidates[0]; + } + Future _runDaemonSideSingle({ - required List hosts, + required InternetAddress relayAddress, }) async { DataTransformer? encrypter; DataTransformer? decrypter; @@ -813,10 +878,12 @@ class SrvImplDart implements Srv { encrypter = createEncrypter(sessionAESKeyString!, sessionIVString!); decrypter = createDecrypter(sessionAESKeyString!, sessionIVString!); } + InternetAddress localAddress = await resolveRequestedLocalHost(); + SocketConnector socketConnector = await SocketConnector.socketToSocket( - addressA: (await InternetAddress.lookup(localHost ?? 'localhost'))[0], + addressA: localAddress, portA: localPort, - addressB: hosts[0], + addressB: relayAddress, portB: streamingPort, verbose: Platform.environment['SRV_TRACE'] == 'true', logger: ioSinkForLogger(logger), From 682899a43ceed8785c13ea998f96d26df12f0988 Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 15 Nov 2024 13:54:06 +0000 Subject: [PATCH 18/20] chore: dart format --- packages/dart/sshnoports/bin/demo_socket_client.dart | 2 +- packages/dart/sshnoports/bin/demo_socket_server.dart | 3 +-- packages/dart/sshnoports/bin/npp_atserver.dart | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/dart/sshnoports/bin/demo_socket_client.dart b/packages/dart/sshnoports/bin/demo_socket_client.dart index 899d0128b..1fbee2f27 100644 --- a/packages/dart/sshnoports/bin/demo_socket_client.dart +++ b/packages/dart/sshnoports/bin/demo_socket_client.dart @@ -17,7 +17,7 @@ void main(List args) async { int expected = numKbsToRequest * 1024; int received = 0; socket.listen( - (data) { + (data) { received += data.length; }, onDone: () { diff --git a/packages/dart/sshnoports/bin/demo_socket_server.dart b/packages/dart/sshnoports/bin/demo_socket_server.dart index e3d0210cc..24f23969b 100644 --- a/packages/dart/sshnoports/bin/demo_socket_server.dart +++ b/packages/dart/sshnoports/bin/demo_socket_server.dart @@ -10,7 +10,6 @@ import 'dart:io'; /// - dart demo_socket_server.dart 12345 /// - dart demo_socket_client.dart 12345 void main(List args) async { - int port = int.parse(args[0]); final server = await ServerSocket.bind( InternetAddress.loopbackIPv4, @@ -37,4 +36,4 @@ void main(List args) async { stdout.writeln('Socket closed.\n'); }); }); -} \ No newline at end of file +} diff --git a/packages/dart/sshnoports/bin/npp_atserver.dart b/packages/dart/sshnoports/bin/npp_atserver.dart index d66d92225..862d95404 100644 --- a/packages/dart/sshnoports/bin/npp_atserver.dart +++ b/packages/dart/sshnoports/bin/npp_atserver.dart @@ -6,7 +6,8 @@ import 'package:at_utils/at_logger.dart'; import 'package:logging/logging.dart'; import 'package:noports_core/admin.dart'; import 'package:noports_core/npa.dart'; -import 'package:noports_core/sshnp_foundation.dart' hide standardAtClientStoragePath; +import 'package:noports_core/sshnp_foundation.dart' + hide standardAtClientStoragePath; import 'package:sshnoports/src/create_at_client_cli.dart'; late AtSignLogger logger; From ef7d5c9ca46bdf4abe394a41da051dd6e9efb6c5 Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 15 Nov 2024 13:56:24 +0000 Subject: [PATCH 19/20] build: update pubspecs to pull latest commit from socket_connector fix-2.3.3 branch --- packages/dart/noports_core/pubspec.yaml | 4 ++++ packages/dart/sshnoports/pubspec.lock | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/dart/noports_core/pubspec.yaml b/packages/dart/noports_core/pubspec.yaml index a3616fa59..b979ea8f1 100644 --- a/packages/dart/noports_core/pubspec.yaml +++ b/packages/dart/noports_core/pubspec.yaml @@ -27,6 +27,10 @@ dependencies: json_annotation: ^4.9.0 dependency_overrides: + socket_connector: + git: + url: https://github.com/atsign-foundation/socket_connector + ref: fix-2.3.3 dartssh2: git: url: https://github.com/atsign-foundation/dartssh2 diff --git a/packages/dart/sshnoports/pubspec.lock b/packages/dart/sshnoports/pubspec.lock index 5fd8d50ee..4d7fda6f4 100644 --- a/packages/dart/sshnoports/pubspec.lock +++ b/packages/dart/sshnoports/pubspec.lock @@ -740,7 +740,7 @@ packages: description: path: "." ref: "fix-2.3.3" - resolved-ref: "10cb072d24f69a558289ffa6e397e6bda8e0f1f9" + resolved-ref: "7f50e6f5ab10701044109fdd42160ef076b5b1c9" url: "https://github.com/atsign-foundation/socket_connector" source: git version: "2.3.3" From 1a062c33204a2d10ccc92d9f068e770452d39c48 Mon Sep 17 00:00:00 2001 From: gkc Date: Sat, 16 Nov 2024 11:28:43 +0000 Subject: [PATCH 20/20] build: update pubspecs to use socket_connector 2.3.3 --- apps/admin/admin_api/pubspec.lock | 6 +++--- packages/dart/noports_core/pubspec.yaml | 6 +----- packages/dart/npt_flutter/pubspec.yaml | 2 +- packages/dart/sshnoports/pubspec.lock | 9 ++++----- packages/dart/sshnoports/pubspec.yaml | 6 +----- packages/dart/sshnp_flutter/pubspec.yaml | 2 +- 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/apps/admin/admin_api/pubspec.lock b/apps/admin/admin_api/pubspec.lock index 1646e8a2b..2261a5aea 100644 --- a/apps/admin/admin_api/pubspec.lock +++ b/apps/admin/admin_api/pubspec.lock @@ -613,7 +613,7 @@ packages: path: "../../../packages/dart/noports_core" relative: true source: path - version: "6.2.0" + version: "6.2.1" openssh_ed25519: dependency: transitive description: @@ -754,10 +754,10 @@ packages: dependency: transitive description: name: socket_connector - sha256: "3c641546699aa58e9ab8be9841627a30af3c1ffcf4461ca5d00d7c56392ab63a" + sha256: ff14b1e5578c6ec677aed4f8dc30cbb59c7663c8118ab4e60bf302f4b6dd1dfc url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.3.2" source_gen: dependency: transitive description: diff --git a/packages/dart/noports_core/pubspec.yaml b/packages/dart/noports_core/pubspec.yaml index b979ea8f1..f4a950029 100644 --- a/packages/dart/noports_core/pubspec.yaml +++ b/packages/dart/noports_core/pubspec.yaml @@ -21,16 +21,12 @@ dependencies: openssh_ed25519: ^1.1.0 path: ^1.9.0 posix: ^6.0.1 - socket_connector: ^2.3.2 + socket_connector: ^2.3.3 uuid: ^3.0.7 mutex: ^3.1.0 json_annotation: ^4.9.0 dependency_overrides: - socket_connector: - git: - url: https://github.com/atsign-foundation/socket_connector - ref: fix-2.3.3 dartssh2: git: url: https://github.com/atsign-foundation/dartssh2 diff --git a/packages/dart/npt_flutter/pubspec.yaml b/packages/dart/npt_flutter/pubspec.yaml index bcbde6a64..1bef2600f 100644 --- a/packages/dart/npt_flutter/pubspec.yaml +++ b/packages/dart/npt_flutter/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: path: ^1.9.0 path_provider: ^2.1.4 phosphor_flutter: ^2.1.0 - socket_connector: ^2.3.2 + socket_connector: ^2.3.3 toml: ^0.16.0 tray_manager: ^0.2.3 url_launcher: ^6.3.0 diff --git a/packages/dart/sshnoports/pubspec.lock b/packages/dart/sshnoports/pubspec.lock index 4d7fda6f4..7f9cbec09 100644 --- a/packages/dart/sshnoports/pubspec.lock +++ b/packages/dart/sshnoports/pubspec.lock @@ -738,11 +738,10 @@ packages: socket_connector: dependency: "direct main" description: - path: "." - ref: "fix-2.3.3" - resolved-ref: "7f50e6f5ab10701044109fdd42160ef076b5b1c9" - url: "https://github.com/atsign-foundation/socket_connector" - source: git + name: socket_connector + sha256: "091c83fb214f6ff48dbf38f6e011e148d996cce05487303c5e8a0cd72369b0e2" + url: "https://pub.dev" + source: hosted version: "2.3.3" source_map_stack_trace: dependency: transitive diff --git a/packages/dart/sshnoports/pubspec.yaml b/packages/dart/sshnoports/pubspec.yaml index 4b6479ca3..6a1e46d16 100644 --- a/packages/dart/sshnoports/pubspec.yaml +++ b/packages/dart/sshnoports/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: at_cli_commons: 1.2.1 at_client: 3.3.0 args: 2.5.0 - socket_connector: 2.3.2 + socket_connector: 2.3.3 dartssh2: 2.8.2 duration: 4.0.3 at_utils: 3.0.19 @@ -23,10 +23,6 @@ dependencies: yaml: 3.1.2 dependency_overrides: - socket_connector: - git: - url: https://github.com/atsign-foundation/socket_connector - ref: fix-2.3.3 dartssh2: git: url: https://github.com/atsign-foundation/dartssh2 diff --git a/packages/dart/sshnp_flutter/pubspec.yaml b/packages/dart/sshnp_flutter/pubspec.yaml index 380264ccd..721d456fb 100644 --- a/packages/dart/sshnp_flutter/pubspec.yaml +++ b/packages/dart/sshnp_flutter/pubspec.yaml @@ -49,7 +49,7 @@ dependencies: path: ^1.8.3 path_provider: ^2.1.3 shared_preferences: ^2.2.2 - socket_connector: ^2.3.2 + socket_connector: ^2.3.3 url_launcher: ^6.1.14 uuid: ^3.0.7 window_manager: ^0.3.8