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

ci: no snooping rvd build + windows build configuration #596

Merged
merged 9 commits into from
Dec 2, 2023
20 changes: 15 additions & 5 deletions .github/workflows/multibuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,33 @@ 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
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d # v1.6.0
- run: mkdir sshnp
- run: mkdir tarball
- if: ${{ matrix.os != 'windows-latest' }}
run: mkdir sshnp/debug
- run: dart pub get
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did a separate mkdir instead of mkdir -p because I'm fairly confident that the powershell mkdir doesn't support that flag.

- 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 }}
- 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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disable certain binaries on windows and add their file extension

- run: cp LICENSE sshnp
- run: tar -cvzf tarball/${{ matrix.output-name }}.tgz sshnp
Expand Down
4 changes: 4 additions & 0 deletions packages/noports_core/lib/src/sshrvd/build_env.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class BuildEnv {
static final bool enableSnoop =
bool.fromEnvironment('ENABLE_SNOOP', defaultValue: false);
}
11 changes: 9 additions & 2 deletions packages/noports_core/lib/src/sshrvd/sshrvd_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disable snooping at the point of passing it to the socket connector

logger
.info("Spawning socket connector isolate with parameters $parameters");
Expand Down
17 changes: 10 additions & 7 deletions packages/noports_core/lib/src/sshrvd/sshrvd_params.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -43,7 +44,7 @@ class SshrvdParams {
managerAtsign: r['manager'],
ipAddress: r['ip'],
verbose: r['verbose'],
snoop: r['snoop'],
snoop: BuildEnv.enableSnoop && r['snoop'],
Copy link
Member Author

@XavierChanth XavierChanth Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Block the boolean condition from trying to call r['snoop'] (which will be null since we didn't add the parser flag - see the other comment in this file)

rootDomain: r['root-domain'],
);
}
Expand Down Expand Up @@ -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',
);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disable the flag in the parser / usage

parser.addOption(
'root-domain',
mandatory: false,
Expand Down
3 changes: 2 additions & 1 deletion packages/sshnoports/tools/Dockerfile.package
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN set -eux; \
arm64) ARCH="arm64";; \
riscv64) ARCH="riscv64";; \
esac; \
mkdir sshnp; \
mkdir -p sshnp/debug; \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mkdir -p is okay here since Dockerfile.package is linux only

Copy link
Member Author

@XavierChanth XavierChanth Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(The output folder name is hard-coded to linux in this file as well)

mkdir tarball; \
dart pub get; \
dart run build_runner build --delete-conflicting-outputs; \
Expand All @@ -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
Expand Down