From 869f96a337fc31e6f3d9beda3c0ce0e10bc899b2 Mon Sep 17 00:00:00 2001 From: xavierchanth Date: Sat, 22 Jul 2023 00:10:49 -0400 Subject: [PATCH 1/2] fix: LateInitializationError sshrvdPort --- packages/sshnoports/lib/sshnp/sshnp_impl.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sshnoports/lib/sshnp/sshnp_impl.dart b/packages/sshnoports/lib/sshnp/sshnp_impl.dart index e99ecd76c..cc99e344c 100644 --- a/packages/sshnoports/lib/sshnp/sshnp_impl.dart +++ b/packages/sshnoports/lib/sshnp/sshnp_impl.dart @@ -115,7 +115,7 @@ class SSHNPImpl implements SSHNP { /// When using sshrvd, this is fetched from sshrvd during [init] @override - late final String sshrvdPort; + late String sshrvdPort; /// Set to '$localPort $port $username $host $sessionId' during [init] @override From 9b6d4923f636f71bfd25d595aa2f0513e8de5bf9 Mon Sep 17 00:00:00 2001 From: xavierchanth Date: Sat, 22 Jul 2023 00:14:58 -0400 Subject: [PATCH 2/2] chore: cleanup sshnp sshrvdPort interface --- packages/sshnoports/lib/sshnp/sshnp.dart | 2 +- packages/sshnoports/lib/sshnp/sshnp_impl.dart | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/sshnoports/lib/sshnp/sshnp.dart b/packages/sshnoports/lib/sshnp/sshnp.dart index ca7879452..6a184ea19 100644 --- a/packages/sshnoports/lib/sshnp/sshnp.dart +++ b/packages/sshnoports/lib/sshnp/sshnp.dart @@ -87,7 +87,7 @@ abstract class SSHNP { abstract final String namespace; /// When using sshrvd, this is fetched from sshrvd during [init] - abstract final String sshrvdPort; + String get sshrvdPort; /// Set to '$localPort $port $username $host $sessionId' during [init] abstract final String sshString; diff --git a/packages/sshnoports/lib/sshnp/sshnp_impl.dart b/packages/sshnoports/lib/sshnp/sshnp_impl.dart index cc99e344c..973e2830a 100644 --- a/packages/sshnoports/lib/sshnp/sshnp_impl.dart +++ b/packages/sshnoports/lib/sshnp/sshnp_impl.dart @@ -114,8 +114,12 @@ class SSHNPImpl implements SSHNP { late final String namespace; /// When using sshrvd, this is fetched from sshrvd during [init] + /// This is only set when using sshrvd + /// (i.e. after [getHostAndPortFromSshrvd] has been called) @override - late String sshrvdPort; + String get sshrvdPort => _sshrvdPort; + + late String _sshrvdPort; /// Set to '$localPort $port $username $host $sessionId' during [init] @override @@ -484,7 +488,7 @@ class SSHNPImpl implements SSHNP { List results = ipPorts.split(','); host = results[0]; port = results[1]; - sshrvdPort = results[2]; + _sshrvdPort = results[2]; sshrvdAck = true; }); @@ -525,7 +529,7 @@ class SSHNPImpl implements SSHNP { // Connect to rendezvous point using background process. // sshnp (this program) can then exit without issue. - unawaited(Process.run(getSshrvCommand(), [host, sshrvdPort])); + unawaited(Process.run(getSshrvCommand(), [host, _sshrvdPort])); } Future generateSshKeys() async {