summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar <oskar@mullvad.net>2024-09-26 16:52:25 +0200
committerOskar <oskar@mullvad.net>2024-09-30 09:14:13 +0200
commit98c90e70e271907687ae2a0a32408e682f4837b3 (patch)
tree2241d5585567dd77f7d275546ffa1a43149d5ac5
parenta8ffb06d9868870a69305d6bad181d3e0b98e3f4 (diff)
downloadmullvadvpn-98c90e70e271907687ae2a0a32408e682f4837b3.tar.xz
mullvadvpn-98c90e70e271907687ae2a0a32408e682f4837b3.zip
Move the daemon rpc path to DaemonRpc
-rw-r--r--gui/src/main/daemon-rpc.ts9
-rw-r--r--gui/src/main/grpc-client.ts12
2 files changed, 14 insertions, 7 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts
index 76f1f7f112..4bd5d58116 100644
--- a/gui/src/main/daemon-rpc.ts
+++ b/gui/src/main/daemon-rpc.ts
@@ -27,7 +27,7 @@ import {
TunnelState,
VoucherResponse,
} from '../shared/daemon-rpc-types';
-import { GrpcClient, noConnectionError } from './grpc-client';
+import { ConnectionObserver, GrpcClient, noConnectionError } from './grpc-client';
import {
convertFromApiAccessMethodSetting,
convertFromDaemonEvent,
@@ -46,6 +46,9 @@ import {
} 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';
+
export class SubscriptionListener<T> {
// Only meant to be used by DaemonRpc
// @internal
@@ -73,6 +76,10 @@ export class DaemonRpc extends GrpcClient {
private nextSubscriptionId = 0;
private subscriptions: Map<number, grpc.ClientReadableStream<grpcTypes.DaemonEvent>> = new Map();
+ public constructor(connectionObserver?: ConnectionObserver) {
+ super(DAEMON_RPC_PATH, connectionObserver);
+ }
+
public disconnect() {
for (const subscriptionId of this.subscriptions.keys()) {
this.removeSubscription(subscriptionId);
diff --git a/gui/src/main/grpc-client.ts b/gui/src/main/grpc-client.ts
index 3096522a06..fa04cdf855 100644
--- a/gui/src/main/grpc-client.ts
+++ b/gui/src/main/grpc-client.ts
@@ -10,9 +10,6 @@ import { promisify } from 'util';
import log from '../shared/logging';
import { ManagementServiceClient } from './management_interface/management_interface_grpc_pb';
-const DAEMON_RPC_PATH =
- process.platform === 'win32' ? 'unix:////./pipe/Mullvad VPN' : 'unix:///var/run/mullvad-vpn';
-
const NETWORK_CALL_TIMEOUT = 10000;
const CHANNEL_STATE_TIMEOUT = 1000 * 60 * 60;
@@ -47,9 +44,12 @@ export class GrpcClient {
private isClosed = false;
private reconnectionTimeout?: NodeJS.Timeout;
- constructor(private connectionObserver?: ConnectionObserver) {
+ constructor(
+ private rpcPath: string,
+ private connectionObserver?: ConnectionObserver,
+ ) {
this.client = new ManagementServiceClient(
- DAEMON_RPC_PATH,
+ rpcPath,
grpc.credentials.createInsecure(),
this.channelOptions(),
);
@@ -63,7 +63,7 @@ export class GrpcClient {
if (this.isClosed) {
this.isClosed = false;
this.client = new ManagementServiceClient(
- DAEMON_RPC_PATH,
+ this.rpcPath,
grpc.credentials.createInsecure(),
this.channelOptions(),
);