From 4b617ffefec93d1672d9f912a2d18a6fee2f8496 Mon Sep 17 00:00:00 2001 From: gkc Date: Wed, 27 Mar 2024 11:45:26 +0000 Subject: [PATCH 01/24] fix: Do not terminate the server if there is an uncaught SocketException; we only have uncaught SocketExceptions in weird edge cases --- .../lib/src/server/bootstrapper.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/at_secondary_server/lib/src/server/bootstrapper.dart b/packages/at_secondary_server/lib/src/server/bootstrapper.dart index 4cf30d6ef..2ac8040f4 100644 --- a/packages/at_secondary_server/lib/src/server/bootstrapper.dart +++ b/packages/at_secondary_server/lib/src/server/bootstrapper.dart @@ -51,12 +51,16 @@ class SecondaryServerBootStrapper { secondaryServerInstance.setExecutor(DefaultVerbExecutor()); //starting secondary in a zone - //prevents secondary from terminating due to uncaught non-fatal errors + //prevents secondary from terminating with uncaught non-fatal errors unawaited(runZonedGuarded(() async { await secondaryServerInstance.start(); }, (error, StackTrace stackTrace) { - logger.severe('Uncaught error: $error \n StackTrace: $stackTrace'); - handleTerminateSignal(ProcessSignal.sigstop); + logger.shout('Uncaught error: $error ; StackTrace follows: $stackTrace'); + if (error is SocketException) { + logger.shout('Will not terminate server for $error'); + } else { + handleTerminateSignal(ProcessSignal.sigstop); + } })); ProcessSignal.sigterm.watch().listen(handleTerminateSignal); ProcessSignal.sigint.watch().listen(handleTerminateSignal); From 20404b584d73efe4142bd67db9ba5a8707f377e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 00:14:19 +0000 Subject: [PATCH 02/24] build(deps): Bump dart from 3.3.1 to 3.3.3 in /packages/at_root_server Bumps dart from 3.3.1 to 3.3.3. --- updated-dependencies: - dependency-name: dart dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- packages/at_root_server/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/at_root_server/Dockerfile b/packages/at_root_server/Dockerfile index bedcb163c..bb72867e9 100644 --- a/packages/at_root_server/Dockerfile +++ b/packages/at_root_server/Dockerfile @@ -1,4 +1,4 @@ -FROM dart:3.3.1@sha256:7e0b4e5d3773c61b5d5b42908f48853fab04c33a080c6f73ee3a99bdd1f4536e AS buildimage +FROM dart:3.3.3@sha256:54685726fd2149932080c0c72d1934441bee9a96026f06920800177a2895107c AS buildimage ENV HOMEDIR=/atsign ENV BINARYDIR=/usr/local/at ENV USER_ID=1024 From a0baa58a8a9e3eaf1f29b42baff7a089cb293b76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 00:50:32 +0000 Subject: [PATCH 03/24] build(deps): Bump dart in /tools/build_virtual_environment/ve_base Bumps dart from 3.3.1 to 3.3.3. --- updated-dependencies: - dependency-name: dart dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- tools/build_virtual_environment/ve_base/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_virtual_environment/ve_base/Dockerfile b/tools/build_virtual_environment/ve_base/Dockerfile index 4f570cc9e..fe2a44c49 100644 --- a/tools/build_virtual_environment/ve_base/Dockerfile +++ b/tools/build_virtual_environment/ve_base/Dockerfile @@ -1,4 +1,4 @@ -FROM dart:3.3.1@sha256:7e0b4e5d3773c61b5d5b42908f48853fab04c33a080c6f73ee3a99bdd1f4536e AS buildimage +FROM dart:3.3.3@sha256:54685726fd2149932080c0c72d1934441bee9a96026f06920800177a2895107c AS buildimage ENV USER_ID=1024 ENV GROUP_ID=1024 WORKDIR /app From 1d872cd73e915c5b1ae775a2f34a6a7468f2e8f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 00:56:09 +0000 Subject: [PATCH 04/24] build(deps): Bump dart from 3.3.1 to 3.3.3 in /tools/build_secondary Bumps dart from 3.3.1 to 3.3.3. --- updated-dependencies: - dependency-name: dart dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- tools/build_secondary/Dockerfile | 2 +- tools/build_secondary/Dockerfile.observe | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/build_secondary/Dockerfile b/tools/build_secondary/Dockerfile index 1b253b72d..f8cb9dd58 100644 --- a/tools/build_secondary/Dockerfile +++ b/tools/build_secondary/Dockerfile @@ -1,4 +1,4 @@ -FROM dart:3.3.1@sha256:7e0b4e5d3773c61b5d5b42908f48853fab04c33a080c6f73ee3a99bdd1f4536e AS buildimage +FROM dart:3.3.3@sha256:54685726fd2149932080c0c72d1934441bee9a96026f06920800177a2895107c AS buildimage ENV HOMEDIR=/atsign ENV USER_ID=1024 ENV GROUP_ID=1024 diff --git a/tools/build_secondary/Dockerfile.observe b/tools/build_secondary/Dockerfile.observe index 22da214bb..024b64794 100644 --- a/tools/build_secondary/Dockerfile.observe +++ b/tools/build_secondary/Dockerfile.observe @@ -1,4 +1,4 @@ -FROM dart:3.3.1@sha256:7e0b4e5d3773c61b5d5b42908f48853fab04c33a080c6f73ee3a99bdd1f4536e AS buildimage +FROM dart:3.3.3@sha256:54685726fd2149932080c0c72d1934441bee9a96026f06920800177a2895107c AS buildimage ENV HOMEDIR=/atsign ENV USER_ID=1024 ENV GROUP_ID=1024 From 3bb41d73bc90b9d47c000c153c774dba7c513b58 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 01:00:17 +0000 Subject: [PATCH 05/24] build(deps): Bump dart in /tools/build_virtual_environment/ve Bumps dart from 3.3.1 to 3.3.3. --- updated-dependencies: - dependency-name: dart dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- tools/build_virtual_environment/ve/Dockerfile.vip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_virtual_environment/ve/Dockerfile.vip b/tools/build_virtual_environment/ve/Dockerfile.vip index b0800caf5..29f6d07e6 100644 --- a/tools/build_virtual_environment/ve/Dockerfile.vip +++ b/tools/build_virtual_environment/ve/Dockerfile.vip @@ -1,4 +1,4 @@ -FROM dart:3.3.1@sha256:7e0b4e5d3773c61b5d5b42908f48853fab04c33a080c6f73ee3a99bdd1f4536e AS buildimage +FROM dart:3.3.3@sha256:54685726fd2149932080c0c72d1934441bee9a96026f06920800177a2895107c AS buildimage ENV USER_ID=1024 ENV GROUP_ID=1024 WORKDIR /app From 395350363e68f402b40d60b394080b69f5bd4944 Mon Sep 17 00:00:00 2001 From: Chris Swan <478926+cpswan@users.noreply.github.com> Date: Thu, 28 Mar 2024 10:00:38 +0000 Subject: [PATCH 06/24] build(deps): Bump at_commons to 4.0.5 --- packages/at_root_server/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/at_root_server/pubspec.yaml b/packages/at_root_server/pubspec.yaml index 8549ae15a..7b6ab4203 100644 --- a/packages/at_root_server/pubspec.yaml +++ b/packages/at_root_server/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: args: 2.4.2 uuid: 3.0.7 yaml: 3.1.2 - at_commons: 4.0.3 + at_commons: 4.0.5 at_utils: 3.0.16 at_server_spec: 4.0.1 at_persistence_root_server: From 1d59505e44e4da9ac526fbed320983caff058387 Mon Sep 17 00:00:00 2001 From: gkc Date: Thu, 28 Mar 2024 12:15:08 +0000 Subject: [PATCH 07/24] chore: run dart format --- .../connection/inbound/inbound_message_listener.dart | 3 ++- .../outbound/outbound_message_listener.dart | 3 ++- .../lib/src/server/at_secondary_impl.dart | 3 +-- .../lib/src/server/bootstrapper.dart | 3 ++- .../at_secondary_server/test/enroll_verb_test.dart | 12 ++++++++---- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/at_secondary_server/lib/src/connection/inbound/inbound_message_listener.dart b/packages/at_secondary_server/lib/src/connection/inbound/inbound_message_listener.dart index 49eb6ca11..9f326f53d 100644 --- a/packages/at_secondary_server/lib/src/connection/inbound/inbound_message_listener.dart +++ b/packages/at_secondary_server/lib/src/connection/inbound/inbound_message_listener.dart @@ -26,7 +26,8 @@ class InboundMessageListener { void listen(callback, streamCallBack) { onStreamCallBack = streamCallBack; onBufferEndCallBack = callback; - logger.finest('Calling inbound underlying.listen within runZonedGuarded block'); + logger.finest( + 'Calling inbound underlying.listen within runZonedGuarded block'); runZonedGuarded(() { connection.underlying.listen(_messageHandler, diff --git a/packages/at_secondary_server/lib/src/connection/outbound/outbound_message_listener.dart b/packages/at_secondary_server/lib/src/connection/outbound/outbound_message_listener.dart index bcfd83553..62b0e996f 100644 --- a/packages/at_secondary_server/lib/src/connection/outbound/outbound_message_listener.dart +++ b/packages/at_secondary_server/lib/src/connection/outbound/outbound_message_listener.dart @@ -19,7 +19,8 @@ class OutboundMessageListener { /// Listens to the underlying connection's socket if the connection is created. /// @throws [AtConnectException] if the connection is not yet created void listen() async { - logger.finest('Calling outbound underlying.listen within runZonedGuarded block'); + logger.finest( + 'Calling outbound underlying.listen within runZonedGuarded block'); runZonedGuarded(() { outboundClient.outboundConnection?.underlying.listen(_messageHandler, diff --git a/packages/at_secondary_server/lib/src/server/at_secondary_impl.dart b/packages/at_secondary_server/lib/src/server/at_secondary_impl.dart index e3913d628..5a3bac1da 100644 --- a/packages/at_secondary_server/lib/src/server/at_secondary_impl.dart +++ b/packages/at_secondary_server/lib/src/server/at_secondary_impl.dart @@ -644,8 +644,7 @@ class AtSecondaryServerImpl implements AtSecondaryServer { final expiryRunRandomMins = (expiringRunFreqMins! - 2) + Random().nextInt(8); logger.finest('Scheduling key expiry job every $expiryRunRandomMins mins'); - manager.scheduleKeyExpireTask(3, - skipCommits: skipCommitsForExpiredKeys); + manager.scheduleKeyExpireTask(3, skipCommits: skipCommitsForExpiredKeys); var atData = AtData(); atData.data = serverContext!.sharedSecret; diff --git a/packages/at_secondary_server/lib/src/server/bootstrapper.dart b/packages/at_secondary_server/lib/src/server/bootstrapper.dart index 2ac8040f4..3e98d5d14 100644 --- a/packages/at_secondary_server/lib/src/server/bootstrapper.dart +++ b/packages/at_secondary_server/lib/src/server/bootstrapper.dart @@ -55,7 +55,8 @@ class SecondaryServerBootStrapper { unawaited(runZonedGuarded(() async { await secondaryServerInstance.start(); }, (error, StackTrace stackTrace) { - logger.shout('Uncaught error: $error ; StackTrace follows: $stackTrace'); + logger.shout('Uncaught error: $error ;' + ' StackTrace follows: $stackTrace'); if (error is SocketException) { logger.shout('Will not terminate server for $error'); } else { diff --git a/packages/at_secondary_server/test/enroll_verb_test.dart b/packages/at_secondary_server/test/enroll_verb_test.dart index b6953055f..eb485694b 100644 --- a/packages/at_secondary_server/test/enroll_verb_test.dart +++ b/packages/at_secondary_server/test/enroll_verb_test.dart @@ -264,7 +264,8 @@ void main() { EnrollmentStatus.denied.name, ]; - List enrollmentKeys = []; // will be used to store newly created enrollment keys + // will be used to store newly created enrollment keys + List enrollmentKeys = []; Map enrollmentData = {}; // create 10 random enrollments and store them into keystore for (int i = 0; i < 10; i++) { @@ -321,7 +322,7 @@ void main() { command = 'enroll:list'; // run enroll list without filter Response listAllResponse = - await enrollVerb.processInternal(command, inboundConnection); + await enrollVerb.processInternal(command, inboundConnection); fetchedEnrollments = jsonDecode(listAllResponse.data!); expect(fetchedEnrollments.length, 10); }); @@ -339,13 +340,16 @@ void main() { throwsA(predicate((e) => e is ArgumentError))); }); - test('verify verb params being populated with correct enrollmentStatusFilter', (){ + test( + 'verify verb params being populated with correct enrollmentStatusFilter', + () { inboundConnection.metadata.isAuthenticated = true; String approvalStatus = 'approved'; String command = 'enroll:list:{"enrollmentStatusFilter":["$approvalStatus"]}'; - Map verbParams = getVerbParam(VerbSyntax.enroll, command); + Map verbParams = + getVerbParam(VerbSyntax.enroll, command); var enrollParams = jsonDecode(verbParams['enrollParams']!); expect(enrollParams['enrollmentStatusFilter'], [approvalStatus]); }); From 9f2ef9bafdaaec3300d56815d2ed683aad90107a Mon Sep 17 00:00:00 2001 From: Srie Teja Date: Thu, 28 Mar 2024 18:00:08 +0530 Subject: [PATCH 08/24] fix: cached keys should not be considered protected keys --- .../lib/src/verb/handler/abstract_verb_handler.dart | 4 ++-- .../lib/src/verb/handler/delete_verb_handler.dart | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/at_secondary_server/lib/src/verb/handler/abstract_verb_handler.dart b/packages/at_secondary_server/lib/src/verb/handler/abstract_verb_handler.dart index d3d88d76d..83c85ed61 100644 --- a/packages/at_secondary_server/lib/src/verb/handler/abstract_verb_handler.dart +++ b/packages/at_secondary_server/lib/src/verb/handler/abstract_verb_handler.dart @@ -40,8 +40,8 @@ abstract class AbstractVerbHandler implements VerbHandler { @override Future process(String command, InboundConnection atConnection) async { var response = await processInternal(command, atConnection); - var handler = responseManager.getResponseHandler(getVerb()); - await handler.process(atConnection, response); + var responseHandler = responseManager.getResponseHandler(getVerb()); + await responseHandler.process(atConnection, response); } Future processInternal( diff --git a/packages/at_secondary_server/lib/src/verb/handler/delete_verb_handler.dart b/packages/at_secondary_server/lib/src/verb/handler/delete_verb_handler.dart index c5cc2a8e0..0c37c52bb 100644 --- a/packages/at_secondary_server/lib/src/verb/handler/delete_verb_handler.dart +++ b/packages/at_secondary_server/lib/src/verb/handler/delete_verb_handler.dart @@ -69,7 +69,7 @@ class DeleteVerbHandler extends ChangeVerbHandler { // fetch protected keys listed in config.yaml protectedKeys ??= _getProtectedKeys(atSign); // check to see if a key is protected. Cannot delete key if it's protected - if (_isProtectedKey(deleteKey!)) { + if (_isProtectedKey(deleteKey!, isCached: verbParams['isCached'])) { throw UnAuthorizedException( 'Cannot delete protected key: \'$deleteKey\''); } @@ -175,8 +175,9 @@ class DeleteVerbHandler extends ChangeVerbHandler { return protectedKeys; } - bool _isProtectedKey(String key) { - if (protectedKeys!.contains(key)) { + bool _isProtectedKey(String key, {String? isCached}) { + isCached ??= 'false'; + if (protectedKeys!.contains(key) && isCached == 'false') { logger.severe('Cannot delete key. \'$key\' is a protected key'); return true; } From cbe1c6d0e298e6ac9ddce6f0529855bc15e0bd16 Mon Sep 17 00:00:00 2001 From: Srie Teja Date: Thu, 28 Mar 2024 18:00:23 +0530 Subject: [PATCH 09/24] test: update tests w.r.t changes --- .../test/delete_verb_test.dart | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/packages/at_secondary_server/test/delete_verb_test.dart b/packages/at_secondary_server/test/delete_verb_test.dart index aae3dc35c..a3a8683b0 100644 --- a/packages/at_secondary_server/test/delete_verb_test.dart +++ b/packages/at_secondary_server/test/delete_verb_test.dart @@ -103,7 +103,7 @@ void main() { }); }); - // The following group of tests are to ensure that the protected keys cannot be deleted + // This group of tests verifies that the protected keys CANNOT be deleted group('verify deletion of protected keys', () { late DeleteVerbHandler handler; setUp(() async { @@ -112,44 +112,56 @@ void main() { secondaryKeyStore, StatsNotificationService.getInstance()); }); - test('verify deletion of signing public key', () { + test('verify deletion of signing public key throws exception', () { + inboundConnection.metadata.isAuthenticated = true; var command = 'delete:${AtConstants.atSigningPublicKey}@alice'; - var paramsMap = getVerbParam(Delete().syntax(), command); - expect( - () => handler.processVerb(Response(), paramsMap, inboundConnection), + () => handler.processInternal(command, inboundConnection), throwsA( predicate((exception) => exception is UnAuthorizedException))); }); - test('verify deletion of signing private key', () { + test('verify deletion of signing private key throws exception', () { + inboundConnection.metadata.isAuthenticated = true; var command = 'delete:@alice:${AtConstants.atSigningPrivateKey}@alice'; - var paramsMap = getVerbParam(Delete().syntax(), command); expect( - () => handler.processVerb(Response(), paramsMap, inboundConnection), + () => handler.processInternal(command, inboundConnection), throwsA( predicate((exception) => exception is UnAuthorizedException))); }); - test('verify deletion of encryption public key', () { + test('verify deletion of encryption public key throws exception', () { + inboundConnection.metadata.isAuthenticated = true; var command = 'delete:${AtConstants.atEncryptionPublicKey}@alice'; - var paramsMap = getVerbParam(Delete().syntax(), command); + expect( - () => handler.processVerb(Response(), paramsMap, inboundConnection), + () async => await handler.processInternal(command, inboundConnection), throwsA( predicate((exception) => exception is UnAuthorizedException))); }); // the following test throws a syntax exception since delete verb handler // expects a key to contain its atsign; but at_pkam_publickey does not - test('verify deletion of pkam public key', () { + test('verify deletion of pkam public key throws exception', () { + inboundConnection.metadata.isAuthenticated = true; var command = 'delete:${AtConstants.atPkamPublicKey}'; - try { - var paramsMap = getVerbParam(Delete().syntax(), command); - handler.processVerb(Response(), paramsMap, inboundConnection); - } on Exception catch (exception) { - assert(exception.toString().contains('Syntax Exception')); - } + + expect( + () => handler.processInternal(command, inboundConnection), + throwsA( + predicate((exception) => exception is InvalidSyntaxException))); + }); + + test('verify deletion of cached pkam public key', () async { + inboundConnection.metadata.isAuthenticated = true; + var command = 'delete:cached:${AtConstants.atEncryptionPublicKey}@alice'; + Response response = + await handler.processInternal(command, inboundConnection); + + // expected response.data is an integer + // parsing data without exception should indicate that response is an int + expect(int.parse(response.data!).runtimeType, int); + expect(response.isError, false); }); }); From 8682b8794a4037c037558fb235c21495fb8ef9c8 Mon Sep 17 00:00:00 2001 From: Srie Teja Date: Thu, 28 Mar 2024 18:11:06 +0530 Subject: [PATCH 10/24] test: more unit tests --- .../test/delete_verb_test.dart | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/packages/at_secondary_server/test/delete_verb_test.dart b/packages/at_secondary_server/test/delete_verb_test.dart index a3a8683b0..3e0ac5227 100644 --- a/packages/at_secondary_server/test/delete_verb_test.dart +++ b/packages/at_secondary_server/test/delete_verb_test.dart @@ -103,7 +103,6 @@ void main() { }); }); - // This group of tests verifies that the protected keys CANNOT be deleted group('verify deletion of protected keys', () { late DeleteVerbHandler handler; setUp(() async { @@ -133,7 +132,6 @@ void main() { test('verify deletion of encryption public key throws exception', () { inboundConnection.metadata.isAuthenticated = true; var command = 'delete:${AtConstants.atEncryptionPublicKey}@alice'; - expect( () async => await handler.processInternal(command, inboundConnection), throwsA( @@ -145,24 +143,40 @@ void main() { test('verify deletion of pkam public key throws exception', () { inboundConnection.metadata.isAuthenticated = true; var command = 'delete:${AtConstants.atPkamPublicKey}'; - expect( () => handler.processInternal(command, inboundConnection), throwsA( predicate((exception) => exception is InvalidSyntaxException))); }); - test('verify deletion of cached pkam public key', () async { + test('verify deletion of cached encryption public key', () async { inboundConnection.metadata.isAuthenticated = true; var command = 'delete:cached:${AtConstants.atEncryptionPublicKey}@alice'; Response response = await handler.processInternal(command, inboundConnection); - // expected response.data is an integer // parsing data without exception should indicate that response is an int expect(int.parse(response.data!).runtimeType, int); expect(response.isError, false); }); + + test('verify deletion of cached signing private key', () async { + inboundConnection.metadata.isAuthenticated = true; + var command = 'delete:cached:@alice:${AtConstants.atSigningPrivateKey}@alice'; + Response response = + await handler.processInternal(command, inboundConnection); + expect(int.parse(response.data!).runtimeType, int); + expect(response.isError, false); + }); + + test('verify deletion of signing public key', () async { + inboundConnection.metadata.isAuthenticated = true; + var command = 'delete:cached:${AtConstants.atSigningPublicKey}@alice'; + Response response = + await handler.processInternal(command, inboundConnection); + expect(int.parse(response.data!).runtimeType, int); + expect(response.isError, false); + }); }); group( From f57344b8015650adebf32f97bb50f5ae940aaaab Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 29 Mar 2024 13:21:49 +0000 Subject: [PATCH 11/24] - fix: BREAKING: Change signature of AtConnection.write from `void write(String data)` to `Future write(String data);` --- packages/at_server_spec/CHANGELOG.md | 5 +++++ .../at_server_spec/lib/src/connection/at_connection.dart | 7 ++++--- packages/at_server_spec/pubspec.yaml | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/at_server_spec/CHANGELOG.md b/packages/at_server_spec/CHANGELOG.md index 9c690b3f4..6a199f6ee 100644 --- a/packages/at_server_spec/CHANGELOG.md +++ b/packages/at_server_spec/CHANGELOG.md @@ -1,3 +1,8 @@ +## 5.0.0 + +- fix: BREAKING: Change signature of AtConnection.write + from `void write(String data)` to `Future write(String data);` + ## 4.0.1 - docs: updated CHANGELOG diff --git a/packages/at_server_spec/lib/src/connection/at_connection.dart b/packages/at_server_spec/lib/src/connection/at_connection.dart index f1dafabdd..f9939e61e 100644 --- a/packages/at_server_spec/lib/src/connection/at_connection.dart +++ b/packages/at_server_spec/lib/src/connection/at_connection.dart @@ -5,9 +5,10 @@ abstract class AtConnection { /// Gets the connection metadata AtConnectionMetaData get metaData; - /// Write some [data] to the [underlying] connection. - /// Throws [AtIOException] for any exception during the operation - void write(String data); + /// Write some [data] to the [underlying] connection, + /// and call underlying.flush or equivalent to ensure that + /// exceptions can be thrown directly to the calling code + Future write(String data); /// closes the underlying connection Future close(); diff --git a/packages/at_server_spec/pubspec.yaml b/packages/at_server_spec/pubspec.yaml index 7f2140167..f40a383a5 100644 --- a/packages/at_server_spec/pubspec.yaml +++ b/packages/at_server_spec/pubspec.yaml @@ -1,6 +1,6 @@ name: at_server_spec description: A Dart library containing abstract classes that defines what implementations of the root and secondary servers are responsible for. -version: 4.0.1 +version: 5.0.0 repository: https://github.com/atsign-foundation/at_server homepage: https://docs.atsign.com documentation: https://docs.atsign.com/atplatform/secondaryserver From e9fc74aae7ac89f489d189f495df6b3d41feacce Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 29 Mar 2024 13:52:13 +0000 Subject: [PATCH 12/24] fix: eliminate possibility of unhandled socket exceptions - take up at_server_spec 5.0.0 which changes return type of AtConnection.write from void to Future - change signature of `write` in all subclasses / implementers of AtConnection - BaseSocketConnection.write now calls `await socket.flush()` after calling `socket.write(...)` - ensure all code which calls .write uses `await connection.write(...)` - InboundConnectionImpl and OutboundConnectionImpl now call socket.done.onError(...) to ensure that all async errors are handled appropriately --- .../lib/src/connection/base_connection.dart | 3 ++- .../connection/inbound/dummy_inbound_connection.dart | 2 +- .../connection/inbound/inbound_connection_impl.dart | 9 +++++++-- .../lib/src/connection/outbound/outbound_client.dart | 10 +++++----- .../connection/outbound/outbound_connection_impl.dart | 9 +++++++-- .../lib/src/server/at_secondary_impl.dart | 8 ++++---- .../lib/src/verb/handler/monitor_verb_handler.dart | 4 ++-- .../verb/handler/response/base_response_handler.dart | 2 +- .../lib/src/verb/handler/stream_verb_handler.dart | 2 +- packages/at_secondary_server/pubspec.yaml | 7 +++++++ .../test/inbound_connection_pool_test.dart | 2 +- .../test/resource_manager_test.dart | 6 +++--- .../test/stats_notification_test.dart | 4 ++-- 13 files changed, 43 insertions(+), 25 deletions(-) diff --git a/packages/at_secondary_server/lib/src/connection/base_connection.dart b/packages/at_secondary_server/lib/src/connection/base_connection.dart index be09f45b1..fb1443661 100644 --- a/packages/at_secondary_server/lib/src/connection/base_connection.dart +++ b/packages/at_secondary_server/lib/src/connection/base_connection.dart @@ -37,12 +37,13 @@ abstract class BaseSocketConnection extends AtConnection { T get underlying => _socket; @override - void write(String data) { + Future write(String data) async { if (isInValid()) { throw ConnectionInvalidException('Connection is invalid'); } try { underlying.write(data); + await underlying.flush(); metaData.lastAccessed = DateTime.now().toUtc(); } on Exception catch (e) { metaData.isStale = true; diff --git a/packages/at_secondary_server/lib/src/connection/inbound/dummy_inbound_connection.dart b/packages/at_secondary_server/lib/src/connection/inbound/dummy_inbound_connection.dart index 8b94a14e6..6c243a80e 100644 --- a/packages/at_secondary_server/lib/src/connection/inbound/dummy_inbound_connection.dart +++ b/packages/at_secondary_server/lib/src/connection/inbound/dummy_inbound_connection.dart @@ -43,7 +43,7 @@ class DummyInboundConnection implements InboundConnection { String? lastWrittenData; @override - void write(String data) { + Future write(String data) async { lastWrittenData = data; } diff --git a/packages/at_secondary_server/lib/src/connection/inbound/inbound_connection_impl.dart b/packages/at_secondary_server/lib/src/connection/inbound/inbound_connection_impl.dart index f9fc16d65..1ec529550 100644 --- a/packages/at_secondary_server/lib/src/connection/inbound/inbound_connection_impl.dart +++ b/packages/at_secondary_server/lib/src/connection/inbound/inbound_connection_impl.dart @@ -86,6 +86,11 @@ class InboundConnectionImpl extends BaseSocketConnection maxRequestsPerTimeFrame = AtSecondaryConfig.maxEnrollRequestsAllowed; timeFrameInMillis = AtSecondaryConfig.timeFrameInMills; requestTimestampQueue = Queue(); + + socket.done.onError((error, stackTrace) { + logger.info('socket.done.onError called with $error. Calling this.close()'); + this.close(); + }); } /// Returns true if the underlying socket is not null and socket's remote address and port match. @@ -235,8 +240,8 @@ class InboundConnectionImpl extends BaseSocketConnection } @override - void write(String data) { - super.write(data); + Future write(String data) async { + await super.write(data); if (metaData is InboundConnectionMetadata) { logger.info(logger.getAtConnectionLogMessage( metaData, 'SENT: ${BaseSocketConnection.truncateForLogging(data)}')); diff --git a/packages/at_secondary_server/lib/src/connection/outbound/outbound_client.dart b/packages/at_secondary_server/lib/src/connection/outbound/outbound_client.dart index 36be14c17..36801c077 100644 --- a/packages/at_secondary_server/lib/src/connection/outbound/outbound_client.dart +++ b/packages/at_secondary_server/lib/src/connection/outbound/outbound_client.dart @@ -177,7 +177,7 @@ class OutboundClient { } try { //1. create from request - outboundConnection!.write(AtRequestFormatter.createFromRequest( + await outboundConnection!.write(AtRequestFormatter.createFromRequest( AtSecondaryServerImpl.getInstance().currentAtSign)); //2. Receive proof @@ -200,7 +200,7 @@ class OutboundClient { } //4. Create pol request - outboundConnection!.write(AtRequestFormatter.createPolRequest()); + await outboundConnection!.write(AtRequestFormatter.createPolRequest()); // 5. wait for handshake result - @@ var handShakeResult = await messageListener.read(); @@ -242,7 +242,7 @@ class OutboundClient { } var lookUpRequest = AtRequestFormatter.createLookUpRequest(key); try { - outboundConnection!.write(lookUpRequest); + await outboundConnection!.write(lookUpRequest); } on AtIOException catch (e) { await outboundConnection!.close(); throw LookupException( @@ -271,7 +271,7 @@ class OutboundClient { scanRequest = 'scan $regex\n'; } try { - outboundConnection!.write(scanRequest); + await outboundConnection!.write(scanRequest); } on AtIOException catch (e) { await outboundConnection!.close(); throw LookupException( @@ -326,7 +326,7 @@ class OutboundClient { } try { var notificationRequest = 'notify:$notifyCommandBody\n'; - outboundConnection!.write(notificationRequest); + await outboundConnection!.write(notificationRequest); } on AtIOException catch (e) { await outboundConnection!.close(); throw LookupException( diff --git a/packages/at_secondary_server/lib/src/connection/outbound/outbound_connection_impl.dart b/packages/at_secondary_server/lib/src/connection/outbound/outbound_connection_impl.dart index 611089919..f02a71335 100644 --- a/packages/at_secondary_server/lib/src/connection/outbound/outbound_connection_impl.dart +++ b/packages/at_secondary_server/lib/src/connection/outbound/outbound_connection_impl.dart @@ -17,6 +17,11 @@ class OutboundConnectionImpl ..toAtSign = toAtSign ..created = DateTime.now().toUtc() ..isCreated = true; + + socket.done.onError((error, stackTrace) { + logger.info('socket.done.onError called with $error. Calling this.close()'); + this.close(); + }); } int _getIdleTimeMillis() { @@ -60,8 +65,8 @@ class OutboundConnectionImpl } @override - void write(String data) { - super.write(data); + Future write(String data) async { + await super.write(data); logger.info(logger.getAtConnectionLogMessage( metaData, 'SENT: ${BaseSocketConnection.truncateForLogging(data)}')); } diff --git a/packages/at_secondary_server/lib/src/server/at_secondary_impl.dart b/packages/at_secondary_server/lib/src/server/at_secondary_impl.dart index 5a3bac1da..c0dc66d87 100644 --- a/packages/at_secondary_server/lib/src/server/at_secondary_impl.dart +++ b/packages/at_secondary_server/lib/src/server/at_secondary_impl.dart @@ -352,8 +352,8 @@ class AtSecondaryServerImpl implements AtSecondaryServer { Future initDynamicConfigListeners() async { //only works if testingMode is set to true if (AtSecondaryConfig.testingMode) { - logger.warning( - 'UNSAFE: testingMode in config.yaml is set to true. Please set to false if not required.'); + logger.warning('testingMode in config.yaml is set to true.' + ' Please set to false if not required.'); //subscriber for inbound_max_limit change logger.finest('Subscribing to dynamic changes made to inbound_max_limit'); @@ -459,8 +459,8 @@ class AtSecondaryServerImpl implements AtSecondaryServer { .handle(e, atConnection: connection, clientSocket: clientSocket); } }), onError: (error) { - // We've got no action to take here, let's just log a warning - logger.warning("ServerSocket.listen called onError with '$error'"); + // We've got no action to take here, let's just log a message + logger.info("ServerSocket.listen called onError with '$error'"); }); } diff --git a/packages/at_secondary_server/lib/src/verb/handler/monitor_verb_handler.dart b/packages/at_secondary_server/lib/src/verb/handler/monitor_verb_handler.dart index 59f8ee0cf..20c9241a3 100644 --- a/packages/at_secondary_server/lib/src/verb/handler/monitor_verb_handler.dart +++ b/packages/at_secondary_server/lib/src/verb/handler/monitor_verb_handler.dart @@ -177,8 +177,8 @@ class MonitorVerbHandler extends AbstractVerbHandler { (notification.notification!.contains(RegExp(regex)) || (notification.fromAtSign != null && notification.fromAtSign!.contains(RegExp(regex))))) { - atConnection - .write('notification: ${jsonEncode(notification.toJson())}\n'); + await atConnection.write('notification:' + ' ${jsonEncode(notification.toJson())}\n'); } } on FormatException { logger.severe('Invalid regular expression : $regex'); diff --git a/packages/at_secondary_server/lib/src/verb/handler/response/base_response_handler.dart b/packages/at_secondary_server/lib/src/verb/handler/response/base_response_handler.dart index cd65bf1b8..672c20b89 100644 --- a/packages/at_secondary_server/lib/src/verb/handler/response/base_response_handler.dart +++ b/packages/at_secondary_server/lib/src/verb/handler/response/base_response_handler.dart @@ -36,7 +36,7 @@ abstract class BaseResponseHandler implements ResponseHandler { } else { responseMessage = getResponseMessage(result, prompt)!; } - connection.write(responseMessage); + await connection.write(responseMessage); } on Exception catch (e, st) { logger.severe('exception in writing response to socket:${e.toString()}'); await GlobalExceptionHandler.getInstance() diff --git a/packages/at_secondary_server/lib/src/verb/handler/stream_verb_handler.dart b/packages/at_secondary_server/lib/src/verb/handler/stream_verb_handler.dart index dab3d018e..0f0467c9f 100644 --- a/packages/at_secondary_server/lib/src/verb/handler/stream_verb_handler.dart +++ b/packages/at_secondary_server/lib/src/verb/handler/stream_verb_handler.dart @@ -59,7 +59,7 @@ class StreamVerbHandler extends AbstractVerbHandler { logger.severe('sender connection is null for stream id:$streamId'); throw UnAuthenticatedException('Invalid stream id'); } - StreamManager.senderSocketMap[streamId]! + await StreamManager.senderSocketMap[streamId]! .write('stream:done $streamId\n'); _cleanUp(streamId); break; diff --git a/packages/at_secondary_server/pubspec.yaml b/packages/at_secondary_server/pubspec.yaml index c8f397c13..b04e3a26e 100644 --- a/packages/at_secondary_server/pubspec.yaml +++ b/packages/at_secondary_server/pubspec.yaml @@ -34,6 +34,13 @@ dependencies: yaml: 3.1.2 logging: 1.2.0 +dependency_overrides: + at_server_spec: + git: + url: https://github.com/atsign-foundation/at_server + ref: gkc/change-atConnection-write-signature + path: packages/at_server_spec + dev_dependencies: test: ^1.24.4 coverage: ^1.6.1 diff --git a/packages/at_secondary_server/test/inbound_connection_pool_test.dart b/packages/at_secondary_server/test/inbound_connection_pool_test.dart index e3c073be0..ee3cb3368 100644 --- a/packages/at_secondary_server/test/inbound_connection_pool_test.dart +++ b/packages/at_secondary_server/test/inbound_connection_pool_test.dart @@ -295,7 +295,7 @@ class MockInboundConnectionImpl extends InboundConnectionImpl { } @override - void write(String data) { + Future write(String data) async { metaData.lastAccessed = DateTime.now().toUtc(); } } diff --git a/packages/at_secondary_server/test/resource_manager_test.dart b/packages/at_secondary_server/test/resource_manager_test.dart index 6a59328e4..b54db9abd 100644 --- a/packages/at_secondary_server/test/resource_manager_test.dart +++ b/packages/at_secondary_server/test/resource_manager_test.dart @@ -76,11 +76,11 @@ void main() async { while (itr.moveNext()) { atNotificationList.add(itr.current); } - // Expecting that the atNotificationList[0] returned from the dequeue() is same as the notification we passed i.e., atNotificationid1.id + // Expecting that the atNotificationList[0] returned from the dequeue() is same as the notification id we passed expect(atNotificationList[0].id, '121'); - // Expecting that the atNotificationList[1] returned from the dequeue() is same as the notification we passed i.e., atNotificationid2.id + // Expecting that the atNotificationList[1] returned from the dequeue() is same as the notification id we passed expect(atNotificationList[1].id, '122'); - // Expecting that the atNotificationList[2] returned from the dequeue() is same as the notification we passed i.e., atNotificationid3.id + // Expecting that the atNotificationList[2] returned from the dequeue() is same as the notification id we passed expect(atNotificationList[2].id, '123'); }, timeout: Timeout(Duration(seconds: 10))); }); diff --git a/packages/at_secondary_server/test/stats_notification_test.dart b/packages/at_secondary_server/test/stats_notification_test.dart index 1f67cec36..5d2cd0022 100644 --- a/packages/at_secondary_server/test/stats_notification_test.dart +++ b/packages/at_secondary_server/test/stats_notification_test.dart @@ -44,13 +44,13 @@ void main() { .thenAnswer((_) => 4); when(() => mockInboundConnection1.write( - any(that: startsWith('notification:')))).thenAnswer((invocation) { + any(that: startsWith('notification:')))).thenAnswer((invocation) async { inboundConn1Written = true; }); when(() => mockInboundConnection2 .write(any(that: startsWith('notification:')))) - .thenAnswer((Invocation invocation) { + .thenAnswer((Invocation invocation) async { inboundConn2Written = true; }); From 16842fb254642be4b6947c7ecc9ff2ab3ecbc291 Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 29 Mar 2024 14:04:07 +0000 Subject: [PATCH 13/24] test: add `done` to MockSocket in unit tests test_utils.dart --- packages/at_secondary_server/test/test_utils.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/at_secondary_server/test/test_utils.dart b/packages/at_secondary_server/test/test_utils.dart index f30b96081..ba1c65fa9 100644 --- a/packages/at_secondary_server/test/test_utils.dart +++ b/packages/at_secondary_server/test/test_utils.dart @@ -40,7 +40,11 @@ class MockOutboundConnection extends Mock implements OutboundSocketConnection {} class MockSecureSocket extends Mock implements SecureSocket {} -class MockSocket extends Mock implements Socket {} +class MockSocket extends Mock implements Socket { + Completer completer = Completer(); + @override + Future get done => completer.future; +} class MockStreamSubscription extends Mock implements StreamSubscription {} From 7dd3da32417bc07c18c0cbeff4a55ff1930cabbd Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 29 Mar 2024 14:22:27 +0000 Subject: [PATCH 14/24] test: tweak enroll_verb_test.dart --- tests/at_functional_test/test/enroll_verb_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/at_functional_test/test/enroll_verb_test.dart b/tests/at_functional_test/test/enroll_verb_test.dart index 9bceb61e7..07d1548d2 100644 --- a/tests/at_functional_test/test/enroll_verb_test.dart +++ b/tests/at_functional_test/test/enroll_verb_test.dart @@ -460,7 +460,7 @@ void main() { 3. On sending a cram request, server returns "data:success" 4. On sending monitor request, server returns enrollment request */ - }, count: 4)); + }, count: 4, max: -1)); monitorSocket.write('from:${firstAtSign.toString().trim()}\n'); }); From aa3d3c0bbeb15aa141745287ad8920ca245e24c6 Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 29 Mar 2024 14:26:09 +0000 Subject: [PATCH 15/24] test: tweak enroll_verb_test.dart --- tests/at_functional_test/test/enroll_verb_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/at_functional_test/test/enroll_verb_test.dart b/tests/at_functional_test/test/enroll_verb_test.dart index 07d1548d2..0702bbba7 100644 --- a/tests/at_functional_test/test/enroll_verb_test.dart +++ b/tests/at_functional_test/test/enroll_verb_test.dart @@ -460,7 +460,7 @@ void main() { 3. On sending a cram request, server returns "data:success" 4. On sending monitor request, server returns enrollment request */ - }, count: 4, max: -1)); + }, count: 5)); monitorSocket.write('from:${firstAtSign.toString().trim()}\n'); }); From c0b98c8bb1be771e087269f6c345ac72f479e1d3 Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 29 Mar 2024 14:31:11 +0000 Subject: [PATCH 16/24] chore: no-op commit to please the semantic PR checker --- packages/at_server_spec/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/at_server_spec/CHANGELOG.md b/packages/at_server_spec/CHANGELOG.md index 6a199f6ee..d3ca95160 100644 --- a/packages/at_server_spec/CHANGELOG.md +++ b/packages/at_server_spec/CHANGELOG.md @@ -1,7 +1,7 @@ ## 5.0.0 - fix: BREAKING: Change signature of AtConnection.write - from `void write(String data)` to `Future write(String data);` + from `void write(String data)` to `Future write(String data)` ## 4.0.1 From 4c46baab21203e365d0975d2a9038ba85776f238 Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 29 Mar 2024 18:11:47 +0000 Subject: [PATCH 17/24] feat: better logging when closing inbound and outbound connections --- .../src/connection/inbound/inbound_connection_impl.dart | 9 +++++---- .../src/connection/inbound/inbound_message_listener.dart | 5 ++--- .../connection/outbound/outbound_connection_impl.dart | 8 +++++--- .../connection/outbound/outbound_message_listener.dart | 1 + 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/at_secondary_server/lib/src/connection/inbound/inbound_connection_impl.dart b/packages/at_secondary_server/lib/src/connection/inbound/inbound_connection_impl.dart index 1ec529550..a0ff5b072 100644 --- a/packages/at_secondary_server/lib/src/connection/inbound/inbound_connection_impl.dart +++ b/packages/at_secondary_server/lib/src/connection/inbound/inbound_connection_impl.dart @@ -226,11 +226,12 @@ class InboundConnectionImpl extends BaseSocketConnection } try { - var address = underlying.remoteAddress; - var port = underlying.remotePort; + logger.info(logger.getAtConnectionLogMessage( + metaData, 'destroying socket (' + 'this side: ${underlying.address}:${underlying.port}' + ' remote side: ${underlying.remoteAddress}:${underlying.remotePort}' + ')')); underlying.destroy(); - logger.finer(logger.getAtConnectionLogMessage( - metaData, '$address:$port Disconnected')); } catch (_) { // Ignore exception on a connection close metaData.isStale = true; diff --git a/packages/at_secondary_server/lib/src/connection/inbound/inbound_message_listener.dart b/packages/at_secondary_server/lib/src/connection/inbound/inbound_message_listener.dart index 9f326f53d..f42a649d6 100644 --- a/packages/at_secondary_server/lib/src/connection/inbound/inbound_message_listener.dart +++ b/packages/at_secondary_server/lib/src/connection/inbound/inbound_message_listener.dart @@ -106,13 +106,12 @@ class InboundMessageListener { /// Closes the [InboundConnection] Future _finishedHandler() async { + logger.info('_finishedHandler called - closing connection'); await _closeConnection(); } Future _closeConnection() async { - if (!connection.isInValid()) { - await connection.close(); - } + await connection.close(); // Removes the connection from the InboundConnectionPool. InboundConnectionPool.getInstance().remove(connection); } diff --git a/packages/at_secondary_server/lib/src/connection/outbound/outbound_connection_impl.dart b/packages/at_secondary_server/lib/src/connection/outbound/outbound_connection_impl.dart index f02a71335..7b58ae274 100644 --- a/packages/at_secondary_server/lib/src/connection/outbound/outbound_connection_impl.dart +++ b/packages/at_secondary_server/lib/src/connection/outbound/outbound_connection_impl.dart @@ -52,10 +52,12 @@ class OutboundConnectionImpl try { var socket = underlying; - var address = socket.remoteAddress; - var port = socket.remotePort; + logger.info(logger.getAtConnectionLogMessage( + metaData, 'destroying socket (' + 'this side: ${underlying.address}:${underlying.port}' + ' remote side: ${underlying.remoteAddress}:${underlying.remotePort}' + ')')); socket.destroy(); - logger.finer('$address:$port Disconnected'); } catch (_) { // Ignore exception on a connection close metaData.isStale = true; diff --git a/packages/at_secondary_server/lib/src/connection/outbound/outbound_message_listener.dart b/packages/at_secondary_server/lib/src/connection/outbound/outbound_message_listener.dart index 62b0e996f..9aba6567e 100644 --- a/packages/at_secondary_server/lib/src/connection/outbound/outbound_message_listener.dart +++ b/packages/at_secondary_server/lib/src/connection/outbound/outbound_message_listener.dart @@ -132,6 +132,7 @@ class OutboundMessageListener { /// Closes the [OutboundClient] void _finishedHandler() async { + logger.info('_finishedHandler called - closing connection'); _closeOutboundClient(); } From 4b21d971e9d3ec85af97f9407b3c1ff1f6977d6f Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 29 Mar 2024 18:18:14 +0000 Subject: [PATCH 18/24] build: upgrade at_server_spec dependency to 5.0.0 --- packages/at_secondary_server/pubspec.yaml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/at_secondary_server/pubspec.yaml b/packages/at_secondary_server/pubspec.yaml index b04e3a26e..b64f32b0e 100644 --- a/packages/at_secondary_server/pubspec.yaml +++ b/packages/at_secondary_server/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: at_utils: 3.0.16 at_chops: 2.0.0 at_lookup: 3.0.46 - at_server_spec: 4.0.1 + at_server_spec: 5.0.0 at_persistence_spec: 2.0.14 at_persistence_secondary_server: 3.0.61 intl: ^0.19.0 @@ -34,13 +34,6 @@ dependencies: yaml: 3.1.2 logging: 1.2.0 -dependency_overrides: - at_server_spec: - git: - url: https://github.com/atsign-foundation/at_server - ref: gkc/change-atConnection-write-signature - path: packages/at_server_spec - dev_dependencies: test: ^1.24.4 coverage: ^1.6.1 From 9bfd724bd1dab6473202ad5f4ba4f91514707a53 Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 29 Mar 2024 18:28:26 +0000 Subject: [PATCH 19/24] chore: logging tweak --- .../at_secondary_server/lib/src/server/at_secondary_impl.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/at_secondary_server/lib/src/server/at_secondary_impl.dart b/packages/at_secondary_server/lib/src/server/at_secondary_impl.dart index c0dc66d87..d3a4e2402 100644 --- a/packages/at_secondary_server/lib/src/server/at_secondary_impl.dart +++ b/packages/at_secondary_server/lib/src/server/at_secondary_impl.dart @@ -442,7 +442,7 @@ class AtSecondaryServerImpl implements AtSecondaryServer { /// Throws [Exception] for any other exceptions. /// @param - ServerSocket void _listen(var serverSocket) { - logger.finer('serverSocket _listen : ${serverSocket.runtimeType}'); + logger.info('serverSocket _listen : ${serverSocket.runtimeType}'); serverSocket.listen(((clientSocket) { var sessionID = '_${Uuid().v4()}'; InboundConnection? connection; From c20f240593aaffd35dcc45d7134a96a642b15907 Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 29 Mar 2024 19:05:10 +0000 Subject: [PATCH 20/24] chore: more logging so we can correlate construction and closing of inbound and outbound connections --- .../lib/src/connection/inbound/inbound_connection_impl.dart | 6 ++++++ .../src/connection/outbound/outbound_connection_impl.dart | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/packages/at_secondary_server/lib/src/connection/inbound/inbound_connection_impl.dart b/packages/at_secondary_server/lib/src/connection/inbound/inbound_connection_impl.dart index a0ff5b072..88356a8f5 100644 --- a/packages/at_secondary_server/lib/src/connection/inbound/inbound_connection_impl.dart +++ b/packages/at_secondary_server/lib/src/connection/inbound/inbound_connection_impl.dart @@ -87,6 +87,12 @@ class InboundConnectionImpl extends BaseSocketConnection timeFrameInMillis = AtSecondaryConfig.timeFrameInMills; requestTimestampQueue = Queue(); + logger.info(logger.getAtConnectionLogMessage( + metaData, 'New connection (' + 'this side: ${underlying.address}:${underlying.port}' + ' remote side: ${underlying.remoteAddress}:${underlying.remotePort}' + ')')); + socket.done.onError((error, stackTrace) { logger.info('socket.done.onError called with $error. Calling this.close()'); this.close(); diff --git a/packages/at_secondary_server/lib/src/connection/outbound/outbound_connection_impl.dart b/packages/at_secondary_server/lib/src/connection/outbound/outbound_connection_impl.dart index 7b58ae274..f2253c4c0 100644 --- a/packages/at_secondary_server/lib/src/connection/outbound/outbound_connection_impl.dart +++ b/packages/at_secondary_server/lib/src/connection/outbound/outbound_connection_impl.dart @@ -18,6 +18,12 @@ class OutboundConnectionImpl ..created = DateTime.now().toUtc() ..isCreated = true; + logger.info(logger.getAtConnectionLogMessage( + metaData, 'New connection (' + 'this side: ${underlying.address}:${underlying.port}' + ' remote side: ${underlying.remoteAddress}:${underlying.remotePort}' + ')')); + socket.done.onError((error, stackTrace) { logger.info('socket.done.onError called with $error. Calling this.close()'); this.close(); From 2d6f41bc36f7ac28215d472b63c15f21139d7d79 Mon Sep 17 00:00:00 2001 From: gkc Date: Fri, 29 Mar 2024 19:16:49 +0000 Subject: [PATCH 21/24] test: tweak MockSocket in test_utils.dart to return values for address, remoteAddress, port and remotePort --- packages/at_secondary_server/test/test_utils.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/at_secondary_server/test/test_utils.dart b/packages/at_secondary_server/test/test_utils.dart index ba1c65fa9..311bf9171 100644 --- a/packages/at_secondary_server/test/test_utils.dart +++ b/packages/at_secondary_server/test/test_utils.dart @@ -44,6 +44,14 @@ class MockSocket extends Mock implements Socket { Completer completer = Completer(); @override Future get done => completer.future; + @override + InternetAddress get remoteAddress => InternetAddress('127.0.0.1'); + @override + int get remotePort => 9999; + @override + InternetAddress get address => InternetAddress('127.0.0.1'); + @override + int get port => 5555; } class MockStreamSubscription extends Mock implements StreamSubscription {} From d73c4736636c2edfc9b6737b334feeb3413b080f Mon Sep 17 00:00:00 2001 From: gkc Date: Sun, 31 Mar 2024 10:21:23 +0100 Subject: [PATCH 22/24] docs: update atServer CHANGELOG.md --- packages/at_secondary_server/CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/at_secondary_server/CHANGELOG.md b/packages/at_secondary_server/CHANGELOG.md index 1359e65b6..cabca0b44 100644 --- a/packages/at_secondary_server/CHANGELOG.md +++ b/packages/at_secondary_server/CHANGELOG.md @@ -1,8 +1,12 @@ ## 3.0.42 -- feat: allow filtering of requests in EnrollVerbHandler using enrollment approval status +- feat: allow filtering of requests in EnrollVerbHandler using enrollment + approval status - feat: authorization changes for keys with no namespace and for reserved keys - build(deps): dependabot changes - fix: Improve socket handling for better server resilience +- fix: Ensure cached keys like 'cached:public:publicKey' are not considered + protected keys and can thus be deleted + ## 3.0.41 - fix: bug in access control for otp put ## 3.0.40 From 62d4c84ba4799ef2263721145279361c68187c5a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 00:09:07 +0000 Subject: [PATCH 23/24] build(deps): Bump subosito/flutter-action from 2.14.0 to 2.15.0 Bumps [subosito/flutter-action](https://github.com/subosito/flutter-action) from 2.14.0 to 2.15.0. - [Release notes](https://github.com/subosito/flutter-action/releases) - [Commits](https://github.com/subosito/flutter-action/compare/1c5eb12d812966ca84680edc38353a0851c8fd56...3d804929922b667a63a229bc59037807f969e885) --- updated-dependencies: - dependency-name: subosito/flutter-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/melos_bootstrap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/melos_bootstrap.yaml b/.github/workflows/melos_bootstrap.yaml index 280a25b3e..c18c593b0 100644 --- a/.github/workflows/melos_bootstrap.yaml +++ b/.github/workflows/melos_bootstrap.yaml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - - uses: subosito/flutter-action@1c5eb12d812966ca84680edc38353a0851c8fd56 # v2.14.0 + - uses: subosito/flutter-action@3d804929922b667a63a229bc59037807f969e885 # v2.15.0 with: channel: "stable" - name: flutter pub get From b8dcad84182cf3cac955f246a43ce99063413d37 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 00:45:04 +0000 Subject: [PATCH 24/24] build(deps): Bump subosito/flutter-action from 2.15.0 to 2.16.0 Bumps [subosito/flutter-action](https://github.com/subosito/flutter-action) from 2.15.0 to 2.16.0. - [Release notes](https://github.com/subosito/flutter-action/releases) - [Commits](https://github.com/subosito/flutter-action/compare/3d804929922b667a63a229bc59037807f969e885...44ac965b96f18d999802d4b807e3256d5a3f9fa1) --- updated-dependencies: - dependency-name: subosito/flutter-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/melos_bootstrap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/melos_bootstrap.yaml b/.github/workflows/melos_bootstrap.yaml index c18c593b0..9a61d5ba1 100644 --- a/.github/workflows/melos_bootstrap.yaml +++ b/.github/workflows/melos_bootstrap.yaml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - - uses: subosito/flutter-action@3d804929922b667a63a229bc59037807f969e885 # v2.15.0 + - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # v2.16.0 with: channel: "stable" - name: flutter pub get