From 8e8d1a1f58d77a5c0216edf605b24b52d9851dd5 Mon Sep 17 00:00:00 2001 From: xavierchanth Date: Tue, 28 Nov 2023 15:01:20 -0500 Subject: [PATCH 1/9] chore: disable snooping for sshrvd at compile time (by default) --- .../noports_core/lib/src/sshrvd/build_env.dart | 4 ++++ .../lib/src/sshrvd/sshrvd_impl.dart | 11 +++++++++-- .../lib/src/sshrvd/sshrvd_params.dart | 17 ++++++++++------- 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 packages/noports_core/lib/src/sshrvd/build_env.dart diff --git a/packages/noports_core/lib/src/sshrvd/build_env.dart b/packages/noports_core/lib/src/sshrvd/build_env.dart new file mode 100644 index 000000000..4bbc87383 --- /dev/null +++ b/packages/noports_core/lib/src/sshrvd/build_env.dart @@ -0,0 +1,4 @@ +class BuildEnv { + static final bool enableSnoop = + bool.fromEnvironment('ENABLE_SNOOP', defaultValue: false); +} diff --git a/packages/noports_core/lib/src/sshrvd/sshrvd_impl.dart b/packages/noports_core/lib/src/sshrvd/sshrvd_impl.dart index e14465995..77eb9e834 100644 --- a/packages/noports_core/lib/src/sshrvd/sshrvd_impl.dart +++ b/packages/noports_core/lib/src/sshrvd/sshrvd_impl.dart @@ -6,6 +6,7 @@ import 'package:at_client/at_client.dart'; import 'package:at_utils/at_logger.dart'; import 'package:logging/logging.dart'; import 'package:meta/meta.dart'; +import 'package:noports_core/src/sshrvd/build_env.dart'; import 'package:noports_core/src/sshrvd/socket_connector.dart'; import 'package:noports_core/src/sshrvd/sshrvd.dart'; import 'package:noports_core/src/sshrvd/sshrvd_params.dart'; @@ -168,8 +169,14 @@ class SshrvdImpl implements Sshrvd { /// Spawn an isolate and wait for it to send back the issued port numbers ReceivePort receivePort = ReceivePort(session); - ConnectorParams parameters = - (receivePort.sendPort, portA, portB, session, forAtsign, snoop); + ConnectorParams parameters = ( + receivePort.sendPort, + portA, + portB, + session, + forAtsign, + BuildEnv.enableSnoop && snoop, + ); logger .info("Spawning socket connector isolate with parameters $parameters"); diff --git a/packages/noports_core/lib/src/sshrvd/sshrvd_params.dart b/packages/noports_core/lib/src/sshrvd/sshrvd_params.dart index 97c3ad5fa..8cd7ba27a 100644 --- a/packages/noports_core/lib/src/sshrvd/sshrvd_params.dart +++ b/packages/noports_core/lib/src/sshrvd/sshrvd_params.dart @@ -1,5 +1,6 @@ import 'package:args/args.dart'; import 'package:noports_core/src/common/file_system_utils.dart'; +import 'package:noports_core/src/sshrvd/build_env.dart'; class SshrvdParams { final String username; @@ -43,7 +44,7 @@ class SshrvdParams { managerAtsign: r['manager'], ipAddress: r['ip'], verbose: r['verbose'], - snoop: r['snoop'], + snoop: BuildEnv.enableSnoop && r['snoop'], rootDomain: r['root-domain'], ); } @@ -84,12 +85,14 @@ class SshrvdParams { abbr: 'v', help: 'More logging', ); - parser.addFlag( - 'snoop', - abbr: 's', - defaultsTo: false, - help: 'Snoop on traffic passing through service', - ); + if (BuildEnv.enableSnoop) { + parser.addFlag( + 'snoop', + abbr: 's', + defaultsTo: false, + help: 'Snoop on traffic passing through service', + ); + } parser.addOption( 'root-domain', mandatory: false, From 2a0cff2ec41a4ac732f5933f449e130098deb5d6 Mon Sep 17 00:00:00 2001 From: xavierchanth Date: Tue, 28 Nov 2023 15:05:33 -0500 Subject: [PATCH 2/9] ci: add file extensions to multibuild for windows --- .github/workflows/multibuild.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/multibuild.yaml b/.github/workflows/multibuild.yaml index e06a063b2..5c385e6cb 100644 --- a/.github/workflows/multibuild.yaml +++ b/.github/workflows/multibuild.yaml @@ -24,10 +24,13 @@ jobs: include: - os: ubuntu-latest output-name: sshnp-linux-x64 + ext: '' - os: macOS-latest output-name: sshnp-macos-x64 + ext: '' - os: windows-latest output-name: sshnp-windows-x64 + ext: '.exe' steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -36,11 +39,11 @@ jobs: - run: mkdir tarball - run: dart pub get - run: dart run build_runner build --delete-conflicting-outputs - - run: dart compile exe bin/activate_cli.dart -v -o sshnp/at_activate - - run: dart compile exe bin/sshnp.dart -v -o sshnp/sshnp - - run: dart compile exe bin/sshnpd.dart -v -o sshnp/sshnpd - - run: dart compile exe bin/sshrv.dart -v -o sshnp/sshrv - - run: dart compile exe bin/sshrvd.dart -v -o sshnp/sshrvd + - run: dart compile exe bin/activate_cli.dart -v -o sshnp/at_activate${{ matrix.ext }} + - run: dart compile exe bin/sshnp.dart -v -o sshnp/sshnp${{ matrix.ext }} + - run: dart compile exe bin/sshnpd.dart -v -o sshnp/sshnpd${{ matrix.ext }} + - run: dart compile exe bin/sshrv.dart -v -o sshnp/sshrv${{ matrix.ext }} + - run: dart compile exe bin/sshrvd.dart -v -o sshnp/sshrvd${{ matrix.ext }} - run: cp -r templates sshnp/templates - run: cp LICENSE sshnp - run: tar -cvzf tarball/${{ matrix.output-name }}.tgz sshnp From 21138bda13bbb2624be5603478e149350dcef1ed Mon Sep 17 00:00:00 2001 From: xavierchanth Date: Tue, 28 Nov 2023 15:06:57 -0500 Subject: [PATCH 3/9] ci: add debug build for sshrvd --- .github/workflows/multibuild.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/multibuild.yaml b/.github/workflows/multibuild.yaml index 5c385e6cb..25666c705 100644 --- a/.github/workflows/multibuild.yaml +++ b/.github/workflows/multibuild.yaml @@ -37,6 +37,7 @@ jobs: - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # v1.6.0 - run: mkdir sshnp - run: mkdir tarball + - run: mkdir sshnp/debug - run: dart pub get - run: dart run build_runner build --delete-conflicting-outputs - run: dart compile exe bin/activate_cli.dart -v -o sshnp/at_activate${{ matrix.ext }} @@ -44,6 +45,7 @@ jobs: - run: dart compile exe bin/sshnpd.dart -v -o sshnp/sshnpd${{ matrix.ext }} - run: dart compile exe bin/sshrv.dart -v -o sshnp/sshrv${{ matrix.ext }} - run: dart compile exe bin/sshrvd.dart -v -o sshnp/sshrvd${{ matrix.ext }} + - run: dart compile exe bin/sshrvd.dart -D ENABLE_SNOOP=true -v -o sshnp/debug/sshrvd-debug${{ matrix.ext }} - run: cp -r templates sshnp/templates - run: cp LICENSE sshnp - run: tar -cvzf tarball/${{ matrix.output-name }}.tgz sshnp From 06812bcabb7f800d4702115096c0990c0c2519c0 Mon Sep 17 00:00:00 2001 From: xavierchanth Date: Tue, 28 Nov 2023 15:11:36 -0500 Subject: [PATCH 4/9] ci: disable non-ready windows binaries --- .github/workflows/multibuild.yaml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/multibuild.yaml b/.github/workflows/multibuild.yaml index 25666c705..68994ecfd 100644 --- a/.github/workflows/multibuild.yaml +++ b/.github/workflows/multibuild.yaml @@ -37,15 +37,20 @@ jobs: - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # v1.6.0 - run: mkdir sshnp - run: mkdir tarball - - run: mkdir sshnp/debug + - if: ${{ matrix.os === 'windows-latest' } + run: mkdir sshnp/debug - run: dart pub get - run: dart run build_runner build --delete-conflicting-outputs - run: dart compile exe bin/activate_cli.dart -v -o sshnp/at_activate${{ matrix.ext }} - run: dart compile exe bin/sshnp.dart -v -o sshnp/sshnp${{ matrix.ext }} - - run: dart compile exe bin/sshnpd.dart -v -o sshnp/sshnpd${{ matrix.ext }} - - run: dart compile exe bin/sshrv.dart -v -o sshnp/sshrv${{ matrix.ext }} - - run: dart compile exe bin/sshrvd.dart -v -o sshnp/sshrvd${{ matrix.ext }} - - run: dart compile exe bin/sshrvd.dart -D ENABLE_SNOOP=true -v -o sshnp/debug/sshrvd-debug${{ matrix.ext }} + - if: ${{ matrix.os != 'windows-latest' }} + run: dart compile exe bin/sshnpd.dart -v -o sshnp/sshnpd${{ matrix.ext }} + - if: ${{ matrix.os != 'windows-latest' } + run: dart compile exe bin/sshrv.dart -v -o sshnp/sshrv${{ matrix.ext }} + - if: ${{ matrix.os != 'windows-latest' } + run: dart compile exe bin/sshrvd.dart -v -o sshnp/sshrvd${{ matrix.ext }} + - if: ${{ matrix.os != 'windows-latest' } + run: dart compile exe bin/sshrvd.dart -D ENABLE_SNOOP=true -v -o sshnp/debug/sshrvd${{ matrix.ext }} - run: cp -r templates sshnp/templates - run: cp LICENSE sshnp - run: tar -cvzf tarball/${{ matrix.output-name }}.tgz sshnp From 4e9e0c5d35872451767c4781efdf8d2bc2e1c8bb Mon Sep 17 00:00:00 2001 From: xavierchanth Date: Wed, 29 Nov 2023 13:08:41 -0500 Subject: [PATCH 5/9] fix: closing braces in multibuild.yaml --- .github/workflows/multibuild.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/multibuild.yaml b/.github/workflows/multibuild.yaml index 68994ecfd..e93f14244 100644 --- a/.github/workflows/multibuild.yaml +++ b/.github/workflows/multibuild.yaml @@ -37,7 +37,7 @@ jobs: - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # v1.6.0 - run: mkdir sshnp - run: mkdir tarball - - if: ${{ matrix.os === 'windows-latest' } + - if: ${{ matrix.os === 'windows-latest' }} run: mkdir sshnp/debug - run: dart pub get - run: dart run build_runner build --delete-conflicting-outputs @@ -45,11 +45,11 @@ jobs: - run: dart compile exe bin/sshnp.dart -v -o sshnp/sshnp${{ matrix.ext }} - if: ${{ matrix.os != 'windows-latest' }} run: dart compile exe bin/sshnpd.dart -v -o sshnp/sshnpd${{ matrix.ext }} - - if: ${{ matrix.os != 'windows-latest' } + - if: ${{ matrix.os != 'windows-latest' }} run: dart compile exe bin/sshrv.dart -v -o sshnp/sshrv${{ matrix.ext }} - - if: ${{ matrix.os != 'windows-latest' } + - if: ${{ matrix.os != 'windows-latest' }} run: dart compile exe bin/sshrvd.dart -v -o sshnp/sshrvd${{ matrix.ext }} - - if: ${{ matrix.os != 'windows-latest' } + - if: ${{ matrix.os != 'windows-latest' }} run: dart compile exe bin/sshrvd.dart -D ENABLE_SNOOP=true -v -o sshnp/debug/sshrvd${{ matrix.ext }} - run: cp -r templates sshnp/templates - run: cp LICENSE sshnp From b40254f444eeb2a444aedba6783f90e4d1f44724 Mon Sep 17 00:00:00 2001 From: xavierchanth Date: Wed, 29 Nov 2023 13:09:33 -0500 Subject: [PATCH 6/9] fix: double equals instead of triple equals --- .github/workflows/multibuild.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/multibuild.yaml b/.github/workflows/multibuild.yaml index e93f14244..c5aa8893a 100644 --- a/.github/workflows/multibuild.yaml +++ b/.github/workflows/multibuild.yaml @@ -37,7 +37,7 @@ jobs: - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # v1.6.0 - run: mkdir sshnp - run: mkdir tarball - - if: ${{ matrix.os === 'windows-latest' }} + - if: ${{ matrix.os == 'windows-latest' }} run: mkdir sshnp/debug - run: dart pub get - run: dart run build_runner build --delete-conflicting-outputs From 9641ca0a1b4e5b48a89c6d0c90321bf29f5252b4 Mon Sep 17 00:00:00 2001 From: xavierchanth Date: Wed, 29 Nov 2023 13:12:17 -0500 Subject: [PATCH 7/9] fix: flip `==` to `!=` --- .github/workflows/multibuild.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/multibuild.yaml b/.github/workflows/multibuild.yaml index c5aa8893a..1e476f60a 100644 --- a/.github/workflows/multibuild.yaml +++ b/.github/workflows/multibuild.yaml @@ -37,7 +37,7 @@ jobs: - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # v1.6.0 - run: mkdir sshnp - run: mkdir tarball - - if: ${{ matrix.os == 'windows-latest' }} + - if: ${{ matrix.os != 'windows-latest' }} run: mkdir sshnp/debug - run: dart pub get - run: dart run build_runner build --delete-conflicting-outputs From 046cba5b009e691d4a0d59fccb2e78e68ecc5a24 Mon Sep 17 00:00:00 2001 From: xavierchanth Date: Wed, 29 Nov 2023 13:42:58 -0500 Subject: [PATCH 8/9] ci: docker buildx debug sshrvd binary --- packages/sshnoports/tools/Dockerfile.package | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/sshnoports/tools/Dockerfile.package b/packages/sshnoports/tools/Dockerfile.package index 830136e9e..11dde8bcf 100644 --- a/packages/sshnoports/tools/Dockerfile.package +++ b/packages/sshnoports/tools/Dockerfile.package @@ -9,7 +9,7 @@ RUN set -eux; \ arm64) ARCH="arm64";; \ riscv64) ARCH="riscv64";; \ esac; \ - mkdir sshnp; \ + mkdir -p sshnp/debug; \ mkdir tarball; \ dart pub get; \ dart run build_runner build --delete-conflicting-outputs; \ @@ -18,6 +18,7 @@ RUN set -eux; \ dart compile exe bin/sshnpd.dart -v -o sshnp/sshnpd; \ dart compile exe bin/sshrv.dart -v -o sshnp/sshrv; \ dart compile exe bin/sshrvd.dart -v -o sshnp/sshrvd; \ + dart compile exe bin/sshrvd.dart -D ENABLE_SNOOP=true -v -o sshnp/debug/sshrvd \ cp -r templates sshnp/templates; \ cp LICENSE sshnp/; \ tar -cvzf tarball/sshnp-linux-${ARCH}.tgz sshnp From fa200b1e06537024560e00171f521fda0f262f3b Mon Sep 17 00:00:00 2001 From: xavierchanth Date: Thu, 30 Nov 2023 10:53:53 -0500 Subject: [PATCH 9/9] fix: add missing ; --- packages/sshnoports/tools/Dockerfile.package | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sshnoports/tools/Dockerfile.package b/packages/sshnoports/tools/Dockerfile.package index 11dde8bcf..e506347c6 100644 --- a/packages/sshnoports/tools/Dockerfile.package +++ b/packages/sshnoports/tools/Dockerfile.package @@ -18,7 +18,7 @@ RUN set -eux; \ dart compile exe bin/sshnpd.dart -v -o sshnp/sshnpd; \ dart compile exe bin/sshrv.dart -v -o sshnp/sshrv; \ dart compile exe bin/sshrvd.dart -v -o sshnp/sshrvd; \ - dart compile exe bin/sshrvd.dart -D ENABLE_SNOOP=true -v -o sshnp/debug/sshrvd \ + dart compile exe bin/sshrvd.dart -D ENABLE_SNOOP=true -v -o sshnp/debug/sshrvd; \ cp -r templates sshnp/templates; \ cp LICENSE sshnp/; \ tar -cvzf tarball/sshnp-linux-${ARCH}.tgz sshnp