Skip to content

Commit

Permalink
Merge pull request #300 from atsign-foundation/jeremy-rootdomain
Browse files Browse the repository at this point in the history
feat: rootDomain option in ArgParser
  • Loading branch information
gkc authored Aug 7, 2023
2 parents a9b73d5 + 021ca2a commit d2b96b9
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/sshnoports/lib/common/create_at_client_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Future<AtClient> createAtClientCli({
String? pathExtension,
String subDirectory = '.sshnp',
String namespace = 'sshnp',
String rootDomain = 'root.atsign.org',
}) async {
// Now on to the atPlatform startup
//onboarding preference builder can be used to set onboardingService parameters
Expand All @@ -30,7 +31,9 @@ Future<AtClient> createAtClientCli({
'$pathBase/storage/commitLog'.replaceAll('/', Platform.pathSeparator)
..fetchOfflineNotifications = false
..atKeysFilePath = atKeysFilePath
..atProtocolEmitted = Version(2, 0, 0);
..atProtocolEmitted = Version(2, 0, 0)
..rootDomain = rootDomain
;

AtOnboardingService onboardingService = AtOnboardingServiceImpl(
atsign, atOnboardingConfig,
Expand Down
7 changes: 7 additions & 0 deletions packages/sshnoports/lib/sshnp/sshnp_arg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,12 @@ class SSHNPArg {
abbr: 'u',
help: 'username to use in the ssh session on the remote host',
),
SSHNPArg(
name: 'root-domain',
help: 'atDirectory domain',
defaultsTo: 'root.atsign.org',
mandatory: false,
format: ArgFormat.option,
),
];
}
4 changes: 3 additions & 1 deletion packages/sshnoports/lib/sshnp/sshnp_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ class SSHNPImpl implements SSHNP {
atsign: p.clientAtSign!,
namespace: '${p.device}.sshnp',
pathExtension: sessionId,
atKeysFilePath: p.atKeysFilePath);
atKeysFilePath: p.atKeysFilePath,
rootDomain: p.rootDomain
);

var sshnp = SSHNP(
atClient: atClient,
Expand Down
7 changes: 7 additions & 0 deletions packages/sshnoports/lib/sshnp/sshnp_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SSHNPParams {
late final bool rsa;
late final String? remoteUsername;
late final bool verbose;
late final String rootDomain;

/// Special Arguments
late final bool listDevices;
Expand All @@ -44,6 +45,7 @@ class SSHNPParams {
this.rsa = false,
this.remoteUsername,
String? atKeysFilePath,
this.rootDomain = 'root.atsign.org',
this.listDevices = false,
}) {
// Do we have a username ?
Expand Down Expand Up @@ -80,6 +82,7 @@ class SSHNPParams {
verbose: partial.verbose ?? false,
remoteUsername: partial.remoteUsername,
atKeysFilePath: partial.atKeysFilePath,
rootDomain: partial.rootDomain ?? 'root.atsign.org',
listDevices: partial.listDevices,
);
}
Expand All @@ -102,6 +105,7 @@ class SSHNPPartialParams {
late final bool? rsa;
late final String? remoteUsername;
late final bool? verbose;
late final String? rootDomain;

/// Special Params
// N.B. config file is a meta param and doesn't need to be included
Expand All @@ -123,6 +127,7 @@ class SSHNPPartialParams {
this.rsa,
this.remoteUsername,
this.verbose,
this.rootDomain,
this.listDevices = false,
});

Expand All @@ -149,6 +154,7 @@ class SSHNPPartialParams {
rsa: params2.rsa ?? params1.rsa,
remoteUsername: params2.remoteUsername ?? params1.remoteUsername,
verbose: params2.verbose ?? params1.verbose,
rootDomain: params2.rootDomain ?? params1.rootDomain,
listDevices: params2.listDevices || params1.listDevices,
);
}
Expand All @@ -167,6 +173,7 @@ class SSHNPPartialParams {
rsa: args['rsa'],
remoteUsername: args['remote-user-name'],
verbose: args['verbose'],
rootDomain: args['root-domain'],
listDevices: args['list-devices'] ?? false,
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/sshnoports/lib/sshnpd/sshnpd_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class SSHNPDImpl implements SSHNPD {
homeDirectory: p.homeDirectory,
atsign: p.deviceAtsign,
atKeysFilePath: p.atKeysFilePath,
rootDomain: p.rootDomain,
);

var sshnpd = SSHNPD(
Expand Down
9 changes: 9 additions & 0 deletions packages/sshnoports/lib/sshnpd/sshnpd_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class SSHNPDParams {
late final String deviceAtsign;
late final bool verbose;
late final SupportedSshClient sshClient;
late final String rootDomain;

// Non param variables
static final ArgParser parser = _createArgParser();
Expand Down Expand Up @@ -43,6 +44,8 @@ class SSHNPDParams {

sshClient = SupportedSshClient.values
.firstWhere((c) => c.cliArg == r['ssh-client']);

rootDomain = r['root-domain'];
}

static ArgParser _createArgParser() {
Expand Down Expand Up @@ -100,6 +103,12 @@ class SSHNPDParams {
allowed: SupportedSshClient.values.map((c) => c.cliArg).toList(),
help: 'What to use for outbound ssh connections.');

parser.addOption('root-domain',
mandatory: false,
defaultsTo: 'root.atsign.org',
help: 'atDirectory domain',
);

return parser;
}
}
1 change: 1 addition & 0 deletions packages/sshnoports/lib/sshrvd/sshrvd_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class SSHRVDImpl implements SSHRVD {
atsign: p.atSign,
atKeysFilePath: p.atKeysFilePath,
namespace: SSHRVD.namespace,
rootDomain: p.rootDomain,
);

var sshrvd = SSHRVD(
Expand Down
8 changes: 8 additions & 0 deletions packages/sshnoports/lib/sshrvd/sshrvd_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SSHRVDParams {
late final String ipAddress;
late final bool verbose;
late final bool snoop;
late final String rootDomain;

// Non param variables
static final ArgParser parser = _createArgParser();
Expand All @@ -33,6 +34,7 @@ class SSHRVDParams {

verbose = r['verbose'];
snoop = r['snoop'];
rootDomain = r['root-domain'];
}

static ArgParser _createArgParser() {
Expand Down Expand Up @@ -77,6 +79,12 @@ class SSHRVDParams {
defaultsTo: false,
help: 'Snoop on traffic passing through service',
);
parser.addOption(
'root-domain',
mandatory: false,
defaultsTo: 'root.atsign.org',
help: 'atDirectory domain',
);
return parser;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
image-manual-local:
build:
context: ../../../../../
dockerfile: test/end2end_tests/image/Dockerfile
dockerfile: tests/end2end_tests/image/Dockerfile
target: manual-local
image: atsigncompany/sshnp-e2e-manual:local
deploy:
Expand Down

0 comments on commit d2b96b9

Please sign in to comment.