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

feat: sshnpd: add --storage-path option #650

Merged
merged 16 commits into from
Jan 1, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/multibuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- run: cp -r bundles/${{ matrix.bundle }}/* sshnp/
- run: cp LICENSE sshnp
- run: tar -cvzf tarball/${{ matrix.output-name }}.tgz sshnp
- uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: x64_binaries
path: ./packages/sshnoports/tarball/${{ matrix.output-name }}.tgz
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
--platform ${{ matrix.platform }} -o type=tar,dest=bins.tar .
- run: mkdir tarballs
- run: tar -xvf bins.tar -C tarballs
- uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: other_binaries
path: ./packages/sshnoports/tarballs/${{ matrix.output-name }}.tgz
Expand Down
4 changes: 4 additions & 0 deletions packages/noports_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 5.0.3
- feat: Add `--storage-path` option to sshnpd to allow users to specify where
it keeps any locally stored data

# 5.0.2

- fix: Add more supported ssh public key types to the send ssh public key filters for sshnpd.
Expand Down
9 changes: 9 additions & 0 deletions packages/noports_core/lib/src/sshnpd/sshnpd_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SshnpdParams {
final int localSshdPort;
final String ephemeralPermissions;
final SupportedSshAlgorithm sshAlgorithm;
final String? storagePath;

// Non param variables
static final ArgParser parser = _createArgParser();
Expand All @@ -37,6 +38,7 @@ class SshnpdParams {
required this.localSshdPort,
required this.ephemeralPermissions,
required this.sshAlgorithm,
required this.storagePath,
});

static Future<SshnpdParams> fromArgs(List<String> args) async {
Expand Down Expand Up @@ -76,6 +78,7 @@ class SshnpdParams {
int.tryParse(r['local-sshd-port']) ?? DefaultArgs.localSshdPort,
ephemeralPermissions: r['ephemeral-permissions'],
sshAlgorithm: SupportedSshAlgorithm.fromString(r['ssh-algorithm']),
storagePath: r['storage-path'],
);
}

Expand Down Expand Up @@ -171,6 +174,12 @@ class SshnpdParams {
allowed: SupportedSshAlgorithm.values.map((c) => c.toString()).toList(),
);

parser.addOption(
'storage-path',
mandatory: false,
help: r'Directory for local storage. Defaults to $HOME/.sshnp/${atSign}/storage',
);

return parser;
}
}
2 changes: 1 addition & 1 deletion packages/noports_core/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/noports_core/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: noports_core
description: Core library code for sshnoports
homepage: https://docs.atsign.com/

version: 5.0.2
version: 5.0.3

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down
1 change: 1 addition & 0 deletions packages/sshnoports/bin/sshnpd.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ void main(List<String> args) async {
atsign: p.deviceAtsign,
atKeysFilePath: p.atKeysFilePath,
rootDomain: p.rootDomain,
storagePath: p.storagePath,
),
usageCallback: (e, s) {
printVersion();
Expand Down
6 changes: 4 additions & 2 deletions packages/sshnoports/lib/src/create_at_client_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Future<AtClient> createAtClientCli({
required String homeDirectory,
required String atsign,
required String atKeysFilePath,
String? storagePath,
String? pathExtension,
String subDirectory = '.sshnp',
String namespace = DefaultArgs.namespace,
Expand All @@ -21,12 +22,13 @@ Future<AtClient> createAtClientCli({
if (pathExtension != null) {
pathBase += '$pathExtension${Platform.pathSeparator}';
}
storagePath ??= path.normalize('$pathBase/storage');
AtOnboardingPreference atOnboardingConfig = AtOnboardingPreference()
..hiveStoragePath = path.normalize('$pathBase/storage')
..hiveStoragePath = storagePath
..namespace = namespace
..downloadPath = path.normalize('$homeDirectory/$subDirectory/files')
..isLocalStoreRequired = true
..commitLogPath = path.normalize('$pathBase/storage/commitLog')
..commitLogPath = path.normalize('$storagePath/commitLog')
..fetchOfflineNotifications = false
..atKeysFilePath = atKeysFilePath
..atProtocolEmitted = Version(2, 0, 0)
Expand Down
2 changes: 1 addition & 1 deletion packages/sshnoports/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions packages/sshnoports/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,10 @@ packages:
noports_core:
dependency: "direct main"
description:
name: noports_core
sha256: c9228de65289f6946c07f12606feb106a6c53d65ca22b69f3da10a71f3f12e0d
url: "https://pub.dev"
source: hosted
version: "5.0.2"
path: "../noports_core"
relative: true
source: path
version: "5.0.3"
openssh_ed25519:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions packages/sshnoports/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: sshnoports
publish_to: none

version: 4.0.4
version: 4.0.5

environment:
sdk: ">=3.0.0 <4.0.0"

dependencies:
noports_core: 5.0.2
noports_core: 5.0.3
at_onboarding_cli: 1.4.1

dependency_overrides:
Expand Down