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

refactor: noports core #507

Merged
merged 52 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
2f4ec28
chore: rename SSHCommand to SSHNPSuccess
XavierChanth Sep 27, 2023
58b4f7e
chore: rename SSHNPCommandResult to SSHNPSuccess
XavierChanth Sep 27, 2023
44a619a
chore: remove unused code
XavierChanth Sep 28, 2023
e6372cd
chore: reduce scope pollution of SSHNP's argParser
XavierChanth Sep 28, 2023
3606586
chore: separate params class, defaults
XavierChanth Sep 28, 2023
44ba240
chore: remove unused imports
XavierChanth Sep 28, 2023
1687d9f
chore: remove part statements from sshnp
XavierChanth Sep 28, 2023
a503f47
chore: move literally everything into a src folder to protect it, and…
XavierChanth Sep 28, 2023
1c21f15
chore: rename params to sshnp_params
XavierChanth Sep 28, 2023
15faa63
refactor: remove the rest of the part definitions and properly expose…
XavierChanth Sep 28, 2023
e3f6d58
refactor: split sshnp_impl by code path
XavierChanth Sep 28, 2023
53a5280
Merge remote-tracking branch 'origin/trunk' into refactor/noports_core
XavierChanth Sep 28, 2023
2c59810
chore: unify connectionBean on SSHNPSuccess class
XavierChanth Sep 29, 2023
3346a58
feat: add killConnectionBean to SSHNPSuccess
XavierChanth Sep 29, 2023
29f33a1
feat: increment package version of noports core
XavierChanth Sep 29, 2023
55a5ad2
chore: run end2end tests against noports_core 4.0.0-dev.2
XavierChanth Sep 29, 2023
58ff1a2
ci: add better version tag checker
XavierChanth Sep 29, 2023
e2a5081
chore: use local build for end2end tests where appropriate, use hoste…
XavierChanth Sep 29, 2023
6407b66
chore: remove flutter constraints from melos workspace, so it can be …
XavierChanth Sep 29, 2023
4daa177
fix(end2end tests): only bootstrap what is needed
XavierChanth Sep 29, 2023
2548c1c
fix: add back initialization of publicKeyFileName
XavierChanth Sep 29, 2023
629b6a8
fix: ensure sshrvPort is always set when it should be
XavierChanth Sep 29, 2023
db66f65
chore: remove unused code
XavierChanth Sep 29, 2023
9a66a8d
chore: checkin changes
XavierChanth Oct 2, 2023
77dfdba
refactor: separate forward and reverse mixins to separate file
XavierChanth Oct 2, 2023
e5fb53b
style: remove whitespace
XavierChanth Oct 2, 2023
446cb3a
ci: set context to the root of the repo for all local docker builds
XavierChanth Oct 2, 2023
aa4fe66
fix: path to startup file
XavierChanth Oct 2, 2023
608a1a1
chore: cleanup e2e code paths
XavierChanth Oct 2, 2023
a0bbbeb
chore: cleanup success message for pure-dart
XavierChanth Oct 2, 2023
84eb917
Merge remote-tracking branch 'origin/trunk' into refactor/noports_core
XavierChanth Oct 2, 2023
9c21e07
chore: fix legacy daemon support in e2e tests
XavierChanth Oct 2, 2023
5c92c4f
chore: revert end2end test regression
XavierChanth Oct 2, 2023
d57fc7e
Revert "chore: revert end2end test regression"
XavierChanth Oct 2, 2023
01fb834
ci: use legacy daemon
XavierChanth Oct 2, 2023
396c94e
ci: replace args in entrypoint file
XavierChanth Oct 2, 2023
0e9a75d
chore: put placeholder for args in place
XavierChanth Oct 2, 2023
9559a5a
ci: pass through only legacy daemon
XavierChanth Oct 2, 2023
c326979
ci: ensure multibuild verifies tags
XavierChanth Oct 2, 2023
060d9b5
ci: verify tags for both multibuilds
XavierChanth Oct 2, 2023
9297b11
chore: more cleanup
XavierChanth Oct 2, 2023
2a0634b
chore: update .gitignore rules for pubspec.lock files
XavierChanth Oct 3, 2023
0b971c2
chore: remove unused deps
XavierChanth Oct 3, 2023
465c3b7
fix: no arg when not using legacy daemon for backward client compatab…
XavierChanth Oct 3, 2023
c9e411c
ci: use legacy placeholder
XavierChanth Oct 3, 2023
ae95c7b
ci: default legacy_daemon false
XavierChanth Oct 3, 2023
8d97b4c
chore: hardcode the legacy daemon conditions for installer
XavierChanth Oct 3, 2023
b29498b
chore: fix legacy check
XavierChanth Oct 3, 2023
940ae1b
chore: rename asciimatcher to avoid scope pollution
XavierChanth Oct 3, 2023
afa2157
chore: final cleanup
XavierChanth Oct 3, 2023
8a1019a
fix: double list devices timeout
XavierChanth Oct 3, 2023
0fb4db9
Merge branch 'trunk' into refactor/noports_core
XavierChanth Oct 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/composite/setup_entrypoints/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ inputs:
devicename:
description: Unique sshnp devicename
required: true
legacy_daemon:
description: Legacy daemon
required: false

runs:
using: composite
Expand All @@ -37,8 +40,7 @@ runs:
entrypoint_filename="sshnp_entrypoint.sh"
;;
esac
echo "entrypoint_filename: $entrypoint_filename"
./setup-sshnp-entrypoint.sh ${{ inputs.devicename }} ${{ inputs.sshnp_atsign }} ${{ inputs.sshnpd_atsign }} ${{ inputs.sshrvd_atsign }} "$entrypoint_filename"
./setup-sshnp-entrypoint.sh ${{ inputs.devicename }} ${{ inputs.sshnp_atsign }} ${{ inputs.sshnpd_atsign }} ${{ inputs.sshrvd_atsign }} "$entrypoint_filename" ${{ inputs.legacy_daemon || false }}

- name: Setup NPD entrypoint
shell: bash
Expand Down
30 changes: 30 additions & 0 deletions .github/composite/verify_cli_tags/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: verify_cli_tags
description: |
Ensures that the tag of sshnoports matches the tag of the composite.

runs:
using: composite
steps:
- name: Ensure pubspec.yaml matches version.dart
shell: bash
working-directory: ./packages/sshnoports
run: |
DART_TAG="v$(egrep -o '^const String version = "(.*)";' lib/version.dart | cut -d'"' -f2)"
PUBSPEC_TAG="v$(egrep -o '^version: (.*)$' pubspec.yaml | cut -d':' -f2 | tr -d '[:space:]')"
if [ "$PUBSPEC_TAG" != "$DART_TAG" ]; then
echo "Tag $PUBSPEC_TAG does not match version in version.dart: $DART_TAG"
exit 1
fi
- name: Ensure version.dart matches git ref (if current git ref is a version tag)
shell: bash
if: startsWith(github.ref, 'refs/tags/v')
working-directory: ./packages/sshnoports
run: |
# check version.dart
REF=${{ github.ref }}
TAG=${REF:10}
DART_TAG="v$(egrep -o '^const String version = "(.*)";' lib/version.dart | cut -d'"' -f2)"
if [ "$TAG" != "$DART_TAG" ]; then
echo "Tag $TAG does not match version in version.dart: $DART_TAG"
exit 1
fi
17 changes: 17 additions & 0 deletions .github/composite/verify_core_tags/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: verify_core_tags
description: |
Ensures that the tag of noports_core matches the tag of the composite.

runs:
using: composite
steps:
- name: Ensure pubspec.yaml matches version.dart
shell: bash
working-directory: ./packages/noports_core
run: |
DART_TAG="v$(grep -Po '^const String version = "(.*)";' lib/version.dart | cut -d'"' -f2)"
PUBSPEC_TAG="v$(egrep -o '^version: (.*)$' pubspec.yaml | cut -d':' -f2 | tr -d '[:space:]')"
if [ "$PUBSPEC_TAG" != "$DART_TAG" ]; then
echo "Tag $PUBSPEC_TAG does not match version in version.dart: $DART_TAG"
exit 1
fi
17 changes: 4 additions & 13 deletions .github/workflows/dockerhub_sshnpd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,9 @@ jobs:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0

- name: Ensure version matches tag
if: startsWith(github.ref, 'refs/tags/v')
working-directory: ./packages/sshnoports
run: |
# check version.dart
REF=${{ github.ref }}
TAG=${REF:10}
DART_TAG="v$(grep -Po '^const String version = "(.*)";' lib/version.dart | cut -d'"' -f2)"
if [ "$TAG" != "$DART_TAG" ]; then
echo "Tag $TAG does not match version in version.dart: $DART_TAG"
exit 1
fi
# verify tags
- uses: ./.github/workflows/verify_cli_tags
- uses: ./.github/workflows/verify_core_tags

- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
Expand All @@ -51,7 +42,7 @@ jobs:
- name: Build and push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: ./packages/sshnoports
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/end2end_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ jobs:
# Don't run these against themselves, pointless to test
- np: local
npd: local

include:
- np: local
npd: installer
legacy_daemon: true
steps:
- name: Show Matrix Values
run: |
Expand Down Expand Up @@ -244,6 +249,7 @@ jobs:
sshnpd_atsign: ${{ env.SSHNPD_ATSIGN }}
sshrvd_atsign: ${{ env[env.PROD_RVD_ATSIGN] }}
devicename: ${{ env.DEVICENAME }}
legacy_daemon: ${{ matrix.legacy_daemon || false }}

- name: Ensure entrypoints exist
working-directory: tests/end2end_tests/contexts
Expand Down Expand Up @@ -368,12 +374,14 @@ jobs:
matrix:
include:
- np: local
npd: latest
- np: latest
npd: v3.4.2
legacy_daemon: true
- np: v3.4.2
npd: local

- np: local
npd: v3.3.0
legacy_daemon: true
- np: v3.3.0
npd: local

Expand Down Expand Up @@ -415,6 +423,7 @@ jobs:
sshnpd_atsign: ${{ env.SSHNPD_ATSIGN }}
sshrvd_atsign: ${{ env[env.PROD_RVD_ATSIGN] }}
devicename: ${{ env.DEVICENAME }}
legacy_daemon: ${{ matrix.legacy_daemon || false }}

- name: Ensure entrypoints exist
working-directory: tests/end2end_tests/contexts
Expand Down Expand Up @@ -610,4 +619,4 @@ jobs:
continue-on-error: true # failing this step does not fail the entire job
working-directory: tests/end2end_tests/tests
run: |
docker compose down
docker compose down
36 changes: 8 additions & 28 deletions .github/workflows/multibuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ permissions: # added using https://github.com/step-security/secure-repo
contents: read

jobs:
verify_tags:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: ./.github/composite/verify_cli_tags
- uses: ./.github/composite/verify_core_tags
x64_build:
needs: verify_tags
runs-on: ${{ matrix.os }}
defaults:
run:
Expand All @@ -23,20 +30,6 @@ jobs:

steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0

- name: Ensure version matches tag
if: startsWith(github.ref, 'refs/tags/v')
working-directory: ./packages/sshnoports
run: |
# check version.dart
REF=${{ github.ref }}
TAG=${REF:10}
DART_TAG="v$(egrep -o '^const String version = "(.*)";' lib/version.dart | cut -d'"' -f2)"
if [ "$TAG" != "$DART_TAG" ]; then
echo "Tag $TAG does not match version in version.dart: $DART_TAG"
exit 1
fi

- uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 # v1.5.1
- run: mkdir sshnp
- run: mkdir tarball
Expand All @@ -56,6 +49,7 @@ jobs:
if-no-files-found: error

other_build:
needs: verify_tags
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -72,20 +66,6 @@ jobs:
output-name: sshnp-linux-riscv64
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0

- name: Ensure version matches tag
if: startsWith(github.ref, 'refs/tags/v')
working-directory: ./packages/sshnoports
run: |
# check version.dart
REF=${{ github.ref }}
TAG=${REF:10}
DART_TAG="v$(grep -Po '^const String version = "(.*)";' lib/version.dart | cut -d'"' -f2)"
if [ "$TAG" != "$DART_TAG" ]; then
echo "Tag $TAG does not match version in version.dart: $DART_TAG"
exit 1
fi

- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- run: |
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: unit_tests

permissions:
contents: read

on:
workflow_dispatch:
push:
branches:
- trunk

pull_request:
branches:
- trunk

jobs:
cli_tags:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: ./.github/composite/verify_cli_tags
core_tags:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: ./.github/composite/verify_core_tags
4 changes: 2 additions & 2 deletions .github/workflows/update_python_requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

permissions:
pull-requests: write

jobs:
bump_requirements:
runs-on: ubuntu-latest
Expand All @@ -32,7 +32,7 @@ jobs:
uses: abatilo/actions-poetry@192395c0d10c082a7c62294ab5d9a9de40e48974 # v2.3.0
with:
poetry-version: '1.6.1'

- name: Bump Python dependencies
if: ${{ github.actor == 'dependabot[bot]' }}
run: |
Expand Down
4 changes: 2 additions & 2 deletions packages/noports_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# 4.0.0-dev.1
# 4.0.0

- Initial release based of the 4.0.0 pre-release code of sshnoports
- Initial release based off of the 4.0.0 pre-release code of sshnoports
14 changes: 11 additions & 3 deletions packages/noports_core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@

# No Ports Core

Abstractions of the original sshnoports core code used for building No Ports
enabled applications. Currently in development, more documentation to come with
the official release.
No Ports Core is the underlying library used to enable sshnoports and the rest of the No Ports suite.

## Examples

### CLI Example

See the [sshnoports](https://github.com/atsign-foundation/sshnoports/tree/trunk/packages/sshnoports) project.

### Flutter Example

See the [sshnp_gui](https://github.com/atsign-foundation/sshnoports/tree/trunk/packages/sshnp_gui) project.

## Maintainers

Expand Down
11 changes: 0 additions & 11 deletions packages/noports_core/lib/common/defaults.dart

This file was deleted.

7 changes: 0 additions & 7 deletions packages/noports_core/lib/common/supported_ssh_clients.dart

This file was deleted.

22 changes: 0 additions & 22 deletions packages/noports_core/lib/common/sync_listener.dart

This file was deleted.

30 changes: 30 additions & 0 deletions packages/noports_core/lib/src/common/default_args.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:noports_core/src/common/supported_ssh_clients.dart';
import 'package:noports_core/sshrv.dart';

class DefaultArgs {
const DefaultArgs();

static const namespace = 'sshnp';

static const verbose = false;
static const rsa = false;
static const rootDomain = 'root.atsign.org';
static const sshrvGenerator = SSHRV.exec;
static const localSshdPort = 22;
static const remoteSshdPort = 22;

/// value in seconds after which idle ssh tunnels will be closed
static const idleTimeout = 15;
static const help = false;
}

class DefaultSSHNPArgs {
static const device = 'default';
static const port = 22;
static const localPort = 0;
static const sendSshPublicKey = '';
static const localSshOptions = <String>[];
static const legacyDaemon = false;
static const listDevices = false;
static const sshClient = SupportedSshClient.exec;
}
18 changes: 18 additions & 0 deletions packages/noports_core/lib/src/common/supported_ssh_clients.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
enum SupportedSshClient {
exec(cliArg: '/usr/bin/ssh'),
dart(cliArg: 'pure-dart');

final String cliArg;
const SupportedSshClient({required this.cliArg});

factory SupportedSshClient.fromCliArg(String cliArg) {
switch (cliArg) {
case '/usr/bin/ssh':
return SupportedSshClient.exec;
case 'pure-dart':
return SupportedSshClient.dart;
default:
throw ArgumentError('Unsupported SSH client: $cliArg');
}
}
}