summaryrefslogtreecommitdiffhomepage
path: root/gui/src/main
diff options
context:
space:
mode:
authorJonathan <jonathan@mullvad.net>2024-01-03 14:39:12 +0100
committerJonathan <jonathan@mullvad.net>2024-01-03 14:39:12 +0100
commit711d4e439866ab12e03d33d5efae3c2355c0c229 (patch)
tree80d3a23c1a96bd3d80e05ac66b530e39c252d48a /gui/src/main
parentc510df96772b1e4ab7998e739ced42806c78e931 (diff)
parent4fdc34acbba60d5092e45ce3e513d30ec996c317 (diff)
downloadmullvadvpn-711d4e439866ab12e03d33d5efae3c2355c0c229.tar.xz
mullvadvpn-711d4e439866ab12e03d33d5efae3c2355c0c229.zip
Merge branch 'implement-custom-openvpn-socks5-bridge-client-in-daemon-des-430'
Diffstat (limited to 'gui/src/main')
-rw-r--r--gui/src/main/daemon-rpc.ts138
-rw-r--r--gui/src/main/default-settings.ts2
2 files changed, 98 insertions, 42 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts
index ad7b60dec2..d5d29ad709 100644
--- a/gui/src/main/daemon-rpc.ts
+++ b/gui/src/main/daemon-rpc.ts
@@ -15,6 +15,7 @@ import {
AuthFailedError,
BridgeSettings,
BridgeState,
+ BridgeType,
ConnectionConfig,
Constraint,
CustomListError,
@@ -51,7 +52,6 @@ import {
ObfuscationSettings,
ObfuscationType,
Ownership,
- ProxySettings,
ProxyType,
RelayEndpointType,
RelayLocation,
@@ -341,13 +341,52 @@ export class DaemonRpc {
public async setBridgeSettings(bridgeSettings: BridgeSettings): Promise<void> {
const grpcBridgeSettings = new grpcTypes.BridgeSettings();
- if ('normal' in bridgeSettings) {
- const normalSettings = convertToNormalBridgeSettings(bridgeSettings.normal);
- grpcBridgeSettings.setNormal(normalSettings);
+ if (bridgeSettings.type === 'custom') {
+ throw configNotSupported;
}
- if ('custom' in bridgeSettings) {
- throw configNotSupported;
+ grpcBridgeSettings.setBridgeType(grpcTypes.BridgeSettings.BridgeType.NORMAL);
+
+ const normalSettings = convertToNormalBridgeSettings(bridgeSettings.normal);
+ grpcBridgeSettings.setNormal(normalSettings);
+
+ if (bridgeSettings.custom) {
+ const customProxy = new grpcTypes.CustomProxy();
+
+ const customSettings = bridgeSettings.custom;
+
+ if ('local' in customSettings) {
+ const local = customSettings.local;
+ const socks5Local = new grpcTypes.Socks5Local();
+ socks5Local.setLocalPort(local.localPort);
+ socks5Local.setRemoteIp(local.remoteIp);
+ socks5Local.setRemotePort(local.remotePort);
+ customProxy.setSocks5local(socks5Local);
+ }
+ if ('remote' in customSettings) {
+ const remote = customSettings.remote;
+ const socks5Remote = new grpcTypes.Socks5Remote();
+ if (remote.auth) {
+ const auth = new grpcTypes.SocksAuth();
+ auth.setUsername(remote.auth.username);
+ auth.setPassword(remote.auth.password);
+ socks5Remote.setAuth(auth);
+ }
+ socks5Remote.setIp(remote.ip);
+ socks5Remote.setPort(remote.port);
+ customProxy.setSocks5remote(socks5Remote);
+ }
+ if ('shadowsocks' in customSettings) {
+ const shadowsocks = customSettings.shadowsocks;
+ const shadowOut = new grpcTypes.Shadowsocks();
+ shadowOut.setCipher(shadowsocks.cipher);
+ shadowOut.setIp(shadowsocks.ip);
+ shadowOut.setPort(shadowsocks.port);
+ shadowOut.setPassword(shadowsocks.password);
+ customProxy.setShadowsocks(shadowOut);
+ }
+
+ grpcBridgeSettings.setCustom(customProxy);
}
await this.call<grpcTypes.BridgeSettings, Empty>(
@@ -1140,49 +1179,64 @@ function convertFromRelaySettings(
function convertFromBridgeSettings(bridgeSettings: grpcTypes.BridgeSettings): BridgeSettings {
const bridgeSettingsObject = bridgeSettings.toObject();
+
+ const detailsMap: Record<grpcTypes.BridgeSettings.BridgeType, BridgeType> = {
+ [grpcTypes.BridgeSettings.BridgeType.NORMAL]: 'normal',
+ [grpcTypes.BridgeSettings.BridgeType.CUSTOM]: 'custom',
+ };
+ const type = detailsMap[bridgeSettingsObject.bridgeType];
+
const normalSettings = bridgeSettingsObject.normal;
- if (normalSettings) {
- const locationConstraint = convertFromLocationConstraint(
- bridgeSettings.getNormal()?.getLocation(),
- );
- const location = wrapConstraint(locationConstraint);
- const providers = normalSettings.providersList;
- const ownership = convertFromOwnership(normalSettings.ownership);
- return {
- normal: {
- location,
- providers,
- ownership,
- },
- };
- }
+ const locationConstraint = convertFromLocationConstraint(
+ bridgeSettings.getNormal()?.getLocation(),
+ );
+ const location = wrapConstraint(locationConstraint);
+ const providers = normalSettings!.providersList;
+ const ownership = convertFromOwnership(normalSettings!.ownership);
- const customSettings = (settings: ProxySettings): BridgeSettings => {
- return { custom: settings };
+ const normal = {
+ location,
+ providers,
+ ownership,
};
- const localSettings = bridgeSettingsObject.local;
- if (localSettings) {
- return customSettings({
- port: localSettings.port,
- peer: localSettings.peer,
- });
- }
+ let custom = undefined;
- const remoteSettings = bridgeSettingsObject.remote;
- if (remoteSettings) {
- return customSettings({
- address: remoteSettings.address,
- auth: remoteSettings.auth && { ...remoteSettings.auth },
- });
+ if (bridgeSettingsObject.custom) {
+ const localSettings = bridgeSettingsObject.custom.socks5local;
+ if (localSettings) {
+ custom = {
+ local: {
+ localPort: localSettings.localPort,
+ remoteIp: localSettings.remoteIp,
+ remotePort: localSettings.remotePort,
+ },
+ };
+ }
+ const remoteSettings = bridgeSettingsObject.custom.socks5remote;
+ if (remoteSettings) {
+ custom = {
+ remote: {
+ ip: remoteSettings.ip,
+ port: remoteSettings.port,
+ auth: remoteSettings.auth && { ...remoteSettings.auth },
+ },
+ };
+ }
+ const shadowsocksSettings = bridgeSettingsObject.custom.shadowsocks;
+ if (shadowsocksSettings) {
+ custom = {
+ shadowsocks: {
+ ip: shadowsocksSettings.ip,
+ port: shadowsocksSettings.port,
+ password: shadowsocksSettings.password,
+ cipher: shadowsocksSettings.cipher,
+ },
+ };
+ }
}
- const shadowsocksSettings = bridgeSettingsObject.shadowsocks!;
- return customSettings({
- peer: shadowsocksSettings.peer!,
- password: shadowsocksSettings.password!,
- cipher: shadowsocksSettings.cipher!,
- });
+ return { type, normal, custom };
}
function convertFromConnectionConfig(
diff --git a/gui/src/main/default-settings.ts b/gui/src/main/default-settings.ts
index 55f420b659..fea88e4c27 100644
--- a/gui/src/main/default-settings.ts
+++ b/gui/src/main/default-settings.ts
@@ -29,11 +29,13 @@ export function getDefaultSettings(): ISettings {
},
},
bridgeSettings: {
+ type: 'normal',
normal: {
location: 'any',
providers: [],
ownership: Ownership.any,
},
+ custom: undefined,
},
bridgeState: 'auto',
tunnelOptions: {