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

Move management interface to its own package #7399

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
42 changes: 33 additions & 9 deletions desktop/package-lock.json

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

1 change: 1 addition & 0 deletions desktop/packages/management-interface/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,22 @@ cd "$SCRIPT_DIR"
ARCH="$(uname -m)"
PLATFORM="$(uname -s)"
MANAGEMENT_INTERFACE_PROTO_BUILD_DIR=${MANAGEMENT_INTERFACE_PROTO_BUILD_DIR:-}
NODE_MODULES_DIR="$(cd ../../../node_modules/.bin && pwd)"
PROTO_DIR="../../../../mullvad-management-interface/proto"
NODE_MODULES_DIR="$(cd ../../node_modules/.bin && pwd)"
OUT_DIR="dist"
PROTO_DIR="../../../mullvad-management-interface/proto"
PROTO_FILENAME="management_interface.proto"
DESTINATION_DIR="../build/src/main/management_interface"
TYPES_DESTINATION_DIR="../src/main/management_interface"

TS_PROTOC_PLUGIN="$NODE_MODULES_DIR/protoc-gen-ts"
if [[ "$(uname -s)" == "MINGW"* ]]; then
TS_PROTOC_PLUGIN="$TS_PROTOC_PLUGIN.cmd"
fi

mkdir -p $DESTINATION_DIR
mkdir -p $TYPES_DESTINATION_DIR
mkdir -p $OUT_DIR

if [[ "$PLATFORM" == "Linux" && ("${ARCH,,}" == "arm64" || "${ARCH,,}" == "aarch64") ]]; then
if [[ -n "${MANAGEMENT_INTERFACE_PROTO_BUILD_DIR}" ]]; then
cp "$MANAGEMENT_INTERFACE_PROTO_BUILD_DIR"/*.js $DESTINATION_DIR
cp "$MANAGEMENT_INTERFACE_PROTO_BUILD_DIR"/*.ts $TYPES_DESTINATION_DIR
cp "$MANAGEMENT_INTERFACE_PROTO_BUILD_DIR"/*.js .
cp "$MANAGEMENT_INTERFACE_PROTO_BUILD_DIR"/*.ts .
else
>&2 echo "Building management interface proto files on aarch64 is not supported"
>&2 echo "(see https://github.com/grpc/grpc-node/issues/1497)."
Expand All @@ -35,14 +33,14 @@ if [[ "$PLATFORM" == "Linux" && ("${ARCH,,}" == "arm64" || "${ARCH,,}" == "aarch
fi
else
"$NODE_MODULES_DIR/grpc_tools_node_protoc" \
--js_out=import_style=commonjs,binary:$DESTINATION_DIR \
--grpc_out=grpc_js:$DESTINATION_DIR \
--js_out=import_style=commonjs,binary:$OUT_DIR \
--grpc_out=grpc_js:$OUT_DIR \
--proto_path=$PROTO_DIR \
$PROTO_DIR/$PROTO_FILENAME

"$NODE_MODULES_DIR/grpc_tools_node_protoc" \
--plugin=protoc-gen-ts="$TS_PROTOC_PLUGIN" \
--ts_out=grpc_js:$TYPES_DESTINATION_DIR \
--ts_out=grpc_js:$OUT_DIR \
--proto_path=$PROTO_DIR \
$PROTO_DIR/$PROTO_FILENAME
fi
21 changes: 21 additions & 0 deletions desktop/packages/management-interface/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "management-interface",
"version": "0.0.0",
"author": "Mullvad VPN",
"license": "GPL-3.0",
"description": "",
"main": "./dist/index.js",
"devDependencies": {
"grpc_tools_node_protoc_ts": "^5.3.3"
},
"optionalDependencies": {
"grpc-tools": "^1.12.4"
},
"peerDependencies": {
"google-protobuf": "*"
},
"scripts": {
"postinstall": "npm run build",
"build": "./build.sh && tsc"
}
}
2 changes: 2 additions & 0 deletions desktop/packages/management-interface/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from '../dist/management_interface_grpc_pb';
export * as types from '../dist/management_interface_pb';
17 changes: 17 additions & 0 deletions desktop/packages/management-interface/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"outDir": "dist",
"rootDirs": [
"src"
],
"typeRoots": [
"../../node_modules/@types"
]
},
"exclude": [
"dist"
]
}
1 change: 0 additions & 1 deletion desktop/packages/mullvad-vpn/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/node_modules
/build
/scripts/out/
/src/main/management_interface/
/test/e2e/screenshots/
/test-results/
/standalone-tests.sea.blob
13 changes: 3 additions & 10 deletions desktop/packages/mullvad-vpn/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs');
const { task, series, parallel } = require('gulp');
const { task, series } = require('gulp');

const scripts = require('./tasks/scripts');
const assets = require('./tasks/assets');
Expand All @@ -18,15 +18,8 @@ task('set-prod-env', function (done) {
task('clean', function (done) {
fs.rm('./build', { recursive: true, force: true }, done);
});
task('build-proto', scripts.buildProto);
task(
'build',
series('clean', 'set-prod-env', parallel(assets.copyAll, scripts.buildProto), scripts.build),
);
task(
'develop',
series('clean', 'set-dev-env', scripts.buildProto, scripts.buildNseventforwarder, watch.start),
);
task('build', series('clean', 'set-prod-env', assets.copyAll, scripts.build));
task('develop', series('clean', 'set-dev-env', scripts.buildNseventforwarder, watch.start));
task('pack-win', series('build', dist.packWin));
task('pack-linux', series('build', dist.packLinux));
task('pack-mac', series('build', dist.packMac));
6 changes: 1 addition & 5 deletions desktop/packages/mullvad-vpn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"gettext-parser": "^6.0.0",
"gl-matrix": "^3.4.3",
"google-protobuf": "^3.21.0",
"management-interface": "0.0.0",
"node-gettext": "^3.0.0",
"nseventforwarder": "0.0.0",
"react": "^18.3.1",
Expand All @@ -28,9 +29,6 @@
"sprintf-js": "^1.1.2",
"styled-components": "^6.1.13"
},
"optionalDependencies": {
"grpc-tools": "^1.12.4"
},
"devDependencies": {
"@playwright/test": "^1.41.1",
"@types/chai": "^4.3.3",
Expand Down Expand Up @@ -60,7 +58,6 @@
"eslint-plugin-react-hooks": "^0.0.0-experimental-2d16326d-20240930",
"gettext-extractor": "^3.5.4",
"globals": "^15.9.0",
"grpc_tools_node_protoc_ts": "^5.3.3",
"gulp": "^4.0.2",
"gulp-inject-string": "^1.1.2",
"gulp-sourcemaps": "^3.0.0",
Expand All @@ -77,7 +74,6 @@
"scripts": {
"preinstall": "test -d node_modules || mkdir node_modules",
"build": "gulp build",
"build-proto": "gulp build-proto",
"pack-test-executable": "./scripts/build-test-executable.sh",
"build-test-executable": "npm run build && npm run pack-test-executable",
"lint": "eslint .",
Expand Down
2 changes: 1 addition & 1 deletion desktop/packages/mullvad-vpn/src/main/daemon-rpc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as grpc from '@grpc/grpc-js';
import { Empty } from 'google-protobuf/google/protobuf/empty_pb.js';
import { BoolValue, StringValue } from 'google-protobuf/google/protobuf/wrappers_pb.js';
import { types as grpcTypes } from 'management-interface';

import {
AccessMethodSetting,
Expand Down Expand Up @@ -44,7 +45,6 @@ import {
convertToRelayConstraints,
ensureExists,
} from './grpc-type-convertions';
import * as grpcTypes from './management_interface/management_interface_pb';

const DAEMON_RPC_PATH =
process.platform === 'win32' ? 'unix:////./pipe/Mullvad VPN' : 'unix:///var/run/mullvad-vpn';
Expand Down
2 changes: 1 addition & 1 deletion desktop/packages/mullvad-vpn/src/main/grpc-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
StringValue,
UInt32Value,
} from 'google-protobuf/google/protobuf/wrappers_pb.js';
import { ManagementServiceClient } from 'management-interface';
import { promisify } from 'util';

import log from '../shared/logging';
import { ManagementServiceClient } from './management_interface/management_interface_grpc_pb';

const NETWORK_CALL_TIMEOUT = 10000;
const CHANNEL_STATE_TIMEOUT = 1000 * 60 * 60;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { types as grpcTypes } from 'management-interface';

import {
AccessMethod,
AccessMethodSetting,
Expand Down Expand Up @@ -58,7 +60,6 @@ import {
TunnelType,
wrapConstraint,
} from '../shared/daemon-rpc-types';
import * as grpcTypes from './management_interface/management_interface_pb';

export class ResponseParseError extends Error {
constructor(message: string) {
Expand Down
6 changes: 0 additions & 6 deletions desktop/packages/mullvad-vpn/tasks/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ function makeBrowserifyPreload(debug) {
return browserifyPreload;
}

function buildProto(callback) {
exec('bash ./scripts/build-proto.sh', (err) => callback(err));
}

function buildNseventforwarder(callback) {
if (process.platform === 'darwin') {
exec('npm -w nseventforwarder run build-debug', (err) => callback(err));
Expand All @@ -122,13 +118,11 @@ function buildNseventforwarder(callback) {
}

compileScripts.displayName = 'compile-scripts';
buildProto.displayName = 'build-proto';
buildNseventforwarder.displayName = 'build-nseventforwarder';

exports.build = series(
compileScripts,
parallel(makeBrowserifyPreload(false), makeBrowserifyRenderer(false)),
);
exports.buildProto = buildProto;
exports.buildNseventforwarder = buildNseventforwarder;
exports.makeWatchCompiler = makeWatchCompiler;
Loading