Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dependency upgrades + cleanup error messages in sshnp #265

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/sshnoports/bin/sshnp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ import 'package:at_utils/at_logger.dart';
// local packages
import 'package:sshnoports/sshnp/sshnp.dart';
import 'package:sshnoports/sshnp/cleanup.dart';
import 'package:sshnoports/sshnp/sshnp_params.dart';

void main(List<String> args) async {
AtSignLogger.root_level = 'SHOUT';
SSHNP? sshnp;

var params = SSHNPParams.fromPartial(SSHNPPartialParams.fromArgs(args));

try {
sshnp = await SSHNP.fromCommandLineArgs(args);
sshnp = await SSHNP.fromParams(params);

ProcessSignal.sigint.watch().listen((signal) async {
await cleanUp(sshnp!.sessionId, sshnp.logger);
Expand All @@ -25,8 +29,11 @@ void main(List<String> args) async {
} on ArgumentError catch (_) {
exit(1);
} catch (error, stackTrace) {
stderr.writeln('Error: ${error.toString()}');
stderr.writeln('Stack Trace: ${stackTrace.toString()}');
stderr.writeln(error.toString());

if (params.verbose) {
stderr.writeln('\nStack Trace: ${stackTrace.toString()}');
}

if (sshnp != null) {
await cleanUp(sshnp.sessionId, sshnp.logger);
Expand Down
7 changes: 5 additions & 2 deletions packages/sshnoports/lib/sshnp/sshnp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:at_client/at_client.dart';
import 'package:at_utils/at_logger.dart';
import 'package:meta/meta.dart';
import 'package:sshnoports/sshnp/sshnp_impl.dart';
import 'package:sshnoports/sshnp/sshnp_params.dart';

abstract class SSHNP {
abstract final AtSignLogger logger;
Expand Down Expand Up @@ -113,8 +114,6 @@ abstract class SSHNP {
@visibleForTesting
bool initialized = false;



factory SSHNP({
// final fields
required AtClient atClient,
Expand Down Expand Up @@ -155,6 +154,10 @@ abstract class SSHNP {
return SSHNPImpl.fromCommandLineArgs(args);
}

static Future<SSHNP> fromParams(SSHNPParams p) {
return SSHNPImpl.fromParams(p);
}

/// Must be run after construction, to complete initialization
/// - Starts notification subscription to listen for responses from sshnpd
/// - calls [generateSshKeys] which generates the ssh keypair to use
Expand Down
11 changes: 6 additions & 5 deletions packages/sshnoports/lib/sshnp/sshnp_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,13 @@ class SSHNPImpl implements SSHNP {
}
}

static Future<SSHNP> fromCommandLineArgs(List<String> args) async {
try {
var p = SSHNPParams.fromPartial(
SSHNPPartialParams.fromArgs(args),
);
static Future<SSHNP> fromCommandLineArgs(List<String> args) {
var params = SSHNPParams.fromPartial(SSHNPPartialParams.fromArgs(args));
return fromParams(params);
}

static Future<SSHNP> fromParams(SSHNPParams p) async {
try {
if (p.clientAtSign == null) {
throw ArgumentError('Option from is mandatory.');
}
Expand Down
11 changes: 5 additions & 6 deletions packages/sshnoports/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ version: 3.4.0
homepage: https://docs.atsign.com/

environment:
sdk: '>=3.0.0 <4.0.0'
sdk: ">=3.0.0 <4.0.0"


dependencies:
dependencies:
args: 2.4.2
at_client: 3.0.61
at_lookup: 3.0.37
at_client: 3.0.63
at_lookup: 3.0.38
at_onboarding_cli: 1.3.0
at_utils: 3.0.13
at_utils: 3.0.15
crypton: 2.1.0
dartssh2: 2.8.2
ssh_key: ">=0.7.1 <0.9.0"
Expand Down