Skip to content

Commit

Permalink
Merge pull request #546 from atsign-foundation/notify_ephemeral_changes
Browse files Browse the repository at this point in the history
fix: Uptake notify ephemeral changes
  • Loading branch information
gkc committed Oct 25, 2023
2 parents 5e3b965 + cd76e09 commit 9c10f88
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ abstract class SSHNPForward extends SSHNPCore {

@override
int get sshrvdPort => _sshrvdPort;

@override
set sshrvdPort(int? port) => _sshrvdPort = port!;

Expand All @@ -32,9 +33,7 @@ abstract class SSHNPForward extends SSHNPCore {
..namespace = this.namespace
..sharedBy = clientAtSign
..sharedWith = sshnpdAtSign
..metadata = (Metadata()
..ttr = -1
..ttl = 10000),
..metadata = (Metadata()..ttl = 10000),
signAndWrapAndJsonEncode(
atClient,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ class SSHNPLegacyImpl extends SSHNPReverse with LegacySSHNPDPayloadHandler {
..sharedBy = clientAtSign
..sharedWith = sshnpdAtSign
..namespace = this.namespace
..metadata = (Metadata()
..ttr = -1
..ttl = 10000);
..metadata = (Metadata()..ttl = 10000);
await notify(
sendOurPrivateKeyToSshnpd, ephemeralKeyPair.privateKeyContents);

Expand Down Expand Up @@ -62,9 +60,7 @@ class SSHNPLegacyImpl extends SSHNPReverse with LegacySSHNPDPayloadHandler {
..namespace = this.namespace
..sharedBy = clientAtSign
..sharedWith = sshnpdAtSign
..metadata = (Metadata()
..ttr = -1
..ttl = 10000),
..metadata = (Metadata()..ttl = 10000),
'$localPort $port $localUsername $host $sessionId',
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class SSHNPReverseImpl extends SSHNPReverse with DefaultSSHNPDPayloadHandler {
..sharedBy = clientAtSign
..sharedWith = sshnpdAtSign
..metadata = (Metadata()
..ttr = -1
..ttl = 10000),
signAndWrapAndJsonEncode(
atClient,
Expand Down
11 changes: 6 additions & 5 deletions packages/noports_core/lib/src/sshnp/sshnp_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,17 @@ abstract class SSHNPCore implements SSHNP {

@protected
final Completer<void> doneCompleter = Completer<void>();

@override
Future<void> get done => doneCompleter.future;

bool _initializeStarted = false;

@protected
bool get initializeStarted => _initializeStarted;
@protected
final Completer<void> initializedCompleter = Completer<void>();

@override
Future<void> get initialized => initializedCompleter.future;

Expand All @@ -105,9 +108,11 @@ abstract class SSHNPCore implements SSHNP {
// ====================================================================

String get clientAtSign => atClient.getCurrentAtSign()!;

String get sshnpdAtSign => params.sshnpdAtSign;

static String getNamespace(String device) => '$device.sshnp';

String get namespace => getNamespace(params.device);

FutureOr<AtSSHKeyPair?> identityKeyPair;
Expand Down Expand Up @@ -333,7 +338,6 @@ abstract class SSHNPCore implements SSHNP {
// as we are sending a notification to the sshrvd namespace,
// we don't want to append our namespace
..namespaceAware = false
..ttr = -1
..ttl = 10000);
logger.info('Sending notification to sshrvd: $ourSshrvdIdKey');
await notify(ourSshrvdIdKey, sessionId);
Expand Down Expand Up @@ -378,9 +382,7 @@ abstract class SSHNPCore implements SSHNP {
..key = 'sshpublickey'
..sharedBy = clientAtSign
..sharedWith = sshnpdAtSign
..metadata = (Metadata()
..ttr = -1
..ttl = 10000);
..metadata = (Metadata()..ttl = 10000);
await notify(sendOurPublicKeyToSshnpd, publicKeyContents);
} catch (e, s) {
throw SSHNPError(
Expand Down Expand Up @@ -491,7 +493,6 @@ abstract class SSHNPCore implements SSHNP {
var metaData = Metadata()
..isPublic = false
..isEncrypted = true
..ttr = -1
..namespaceAware = true;

var pingKey = AtKey()
Expand Down
8 changes: 3 additions & 5 deletions packages/noports_core/lib/src/sshnpd/sshnpd_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class SSHNPDImpl implements SSHNPD {
var metaData = Metadata()
..isPublic = false
..isEncrypted = true
..ttr = -1
..ttr = -1 // we want this to be cacheable by managerAtsign
..namespaceAware = true;

var atKey = AtKey()
Expand Down Expand Up @@ -293,7 +293,6 @@ class SSHNPDImpl implements SSHNPD {
..metadata = (Metadata()
..isPublic = false
..isEncrypted = true
..ttr = -1
..ttl = 10000 // allow only ten seconds before this record expires
..namespaceAware = true);

Expand Down Expand Up @@ -625,7 +624,6 @@ class SSHNPDImpl implements SSHNPD {
..isPublic = false
..isEncrypted = true
..namespaceAware = true
..ttr = -1
..ttl = 10000);
return atKey;
}
Expand Down Expand Up @@ -859,8 +857,8 @@ class SSHNPDImpl implements SSHNPD {
var metaData = Metadata()
..isPublic = false
..isEncrypted = true
..ttr = -1
..ttl = ttl
..ttr = -1 // we want this to be cacheable by managerAtsign
..ttl = ttl // but to expire after 30 days
..updatedAt = DateTime.now()
..namespaceAware = true;

Expand Down
1 change: 0 additions & 1 deletion packages/noports_core/lib/src/sshrvd/sshrvd_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ class SSHRVDImpl implements SSHRVD {
var metaData = Metadata()
..isPublic = false
..isEncrypted = true
..ttr = -1
..ttl = 10000
..namespaceAware = true;

Expand Down
7 changes: 3 additions & 4 deletions packages/sshnoports/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,9 @@ packages:
noports_core:
dependency: "direct main"
description:
name: noports_core
sha256: "02331701ef45e985a637d17319e9969deaa6d53b9b171bb234d47e9c60aee94e"
url: "https://pub.dev"
source: hosted
path: "../noports_core"
relative: true
source: path
version: "4.0.0-dev.3"
openssh_ed25519:
dependency: transitive
Expand Down
4 changes: 2 additions & 2 deletions packages/sshnp_gui/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ packages:
dependency: transitive
description:
name: at_commons
sha256: "091ca795288910f7d426ab4534e5e0e6e1fae3a12e2c65a578f1244d1f3d67bc"
sha256: a3b5c171c0a7a7cbfd334302df7670f831f00b9b701d8bec9ebbc1765e69f489
url: "https://pub.dev"
source: hosted
version: "3.0.55"
version: "3.0.57"
at_contact:
dependency: "direct main"
description:
Expand Down

0 comments on commit 9c10f88

Please sign in to comment.