Skip to content

Commit 29d055a

Browse files
committed
Add IPC and RPC calls for updating dns options
1 parent f9bebec commit 29d055a

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

gui/src/main/daemon-rpc.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
ProxySettings,
4949
VoucherResponse,
5050
TunnelProtocol,
51+
IDnsOptions,
5152
} from '../shared/daemon-rpc-types';
5253

5354
import * as managementInterface from './management_interface/management_interface_grpc_pb';
@@ -452,6 +453,14 @@ export class DaemonRpc {
452453
};
453454
}
454455

456+
public async setDnsOptions(dns: IDnsOptions): Promise<void> {
457+
const dnsOptions = new grpcTypes.DnsOptions();
458+
dnsOptions.setCustom(dns.custom);
459+
dnsOptions.setAddressesList(dns.addresses);
460+
461+
await this.call<grpcTypes.DnsOptions, Empty>(this.client.setDnsOptions, dnsOptions);
462+
}
463+
455464
public async verifyWireguardKey(): Promise<boolean> {
456465
const response = await this.callEmpty<BoolValue>(this.client.verifyWireguardKey);
457466
return response.getValue();

gui/src/main/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
DaemonEvent,
1616
IAccountData,
1717
IAppVersionInfo,
18+
IDnsOptions,
1819
ILocation,
1920
IRelayList,
2021
ISettings,
@@ -988,6 +989,9 @@ class ApplicationMain {
988989
IpcMainEventChannel.settings.handleUpdateBridgeSettings((bridgeSettings: BridgeSettings) => {
989990
return this.daemonRpc.setBridgeSettings(bridgeSettings);
990991
});
992+
IpcMainEventChannel.settings.handleDnsOptions((dns: IDnsOptions) => {
993+
return this.daemonRpc.setDnsOptions(dns);
994+
});
991995
IpcMainEventChannel.autoStart.handleSet((autoStart: boolean) => {
992996
return this.setAutoStart(autoStart);
993997
});

gui/src/renderer/app.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
BridgeState,
3333
IAccountData,
3434
IAppVersionInfo,
35+
IDnsOptions,
3536
ILocation,
3637
IRelayList,
3738
ISettings,
@@ -303,6 +304,10 @@ export default class AppRenderer {
303304
return IpcRendererEventChannel.settings.updateBridgeSettings(bridgeSettings);
304305
}
305306

307+
public setDnsOptions(dns: IDnsOptions) {
308+
return IpcRendererEventChannel.settings.setDnsOptions(dns);
309+
}
310+
306311
public removeAccountFromHistory(accountToken: AccountToken): Promise<void> {
307312
return IpcRendererEventChannel.accountHistory.removeItem(accountToken);
308313
}

gui/src/shared/ipc-event-channel.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
BridgeState,
1414
IAccountData,
1515
IAppVersionInfo,
16+
IDnsOptions,
1617
ILocation,
1718
IRelayList,
1819
ISettings,
@@ -78,6 +79,7 @@ interface ISettingsMethods extends IReceiver<ISettings> {
7879
setWireguardMtu(mtu?: number): Promise<void>;
7980
updateRelaySettings(update: RelaySettingsUpdate): Promise<void>;
8081
updateBridgeSettings(bridgeSettings: BridgeSettings): Promise<void>;
82+
setDnsOptions(dns: IDnsOptions): Promise<void>;
8183
}
8284

8385
interface ISettingsHandlers extends ISender<ISettings> {
@@ -90,6 +92,7 @@ interface ISettingsHandlers extends ISender<ISettings> {
9092
handleWireguardMtu(fn: (mtu?: number) => Promise<void>): void;
9193
handleUpdateRelaySettings(fn: (update: RelaySettingsUpdate) => Promise<void>): void;
9294
handleUpdateBridgeSettings(fn: (bridgeSettings: BridgeSettings) => Promise<void>): void;
95+
handleDnsOptions(fn: (dns: IDnsOptions) => Promise<void>): void;
9396
}
9497

9598
interface IGuiSettingsMethods extends IReceiver<IGuiSettingsState> {
@@ -188,6 +191,7 @@ const SET_OPENVPN_MSSFIX = 'set-openvpn-mssfix';
188191
const SET_WIREGUARD_MTU = 'set-wireguard-mtu';
189192
const UPDATE_RELAY_SETTINGS = 'update-relay-settings';
190193
const UPDATE_BRIDGE_SETTINGS = 'update-bridge-location';
194+
const SET_DNS_OPTIONS = 'set-dns-options';
191195

192196
const LOCATION_CHANGED = 'location-changed';
193197
const RELAYS_CHANGED = 'relays-changed';
@@ -275,6 +279,7 @@ export class IpcRendererEventChannel {
275279
setWireguardMtu: requestSender(SET_WIREGUARD_MTU),
276280
updateRelaySettings: requestSender(UPDATE_RELAY_SETTINGS),
277281
updateBridgeSettings: requestSender(UPDATE_BRIDGE_SETTINGS),
282+
setDnsOptions: requestSender(SET_DNS_OPTIONS),
278283
};
279284

280285
public static location: IReceiver<ILocation> = {
@@ -385,6 +390,7 @@ export class IpcMainEventChannel {
385390
handleWireguardMtu: requestHandler(SET_WIREGUARD_MTU),
386391
handleUpdateRelaySettings: requestHandler(UPDATE_RELAY_SETTINGS),
387392
handleUpdateBridgeSettings: requestHandler(UPDATE_BRIDGE_SETTINGS),
393+
handleDnsOptions: requestHandler(SET_DNS_OPTIONS),
388394
};
389395

390396
public static relays: ISender<IRelayListPair> = {

0 commit comments

Comments
 (0)