Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Nov 8, 2024
1 parent fe47a77 commit 2d52f57
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion client/electron/go_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import {pathToEmbeddedTun2socksBinary} from './app_paths';
import {ChildProcessHelper} from './process';
import {TransportConfigJson} from '../src/www/app/outline_server_repository/vpn';
import {TransportConfigJson} from '../src/www/app/outline_server_repository/config';

/**
* Verifies the UDP connectivity of the server specified in `config`.
Expand Down
10 changes: 4 additions & 6 deletions client/electron/go_vpn_tunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ import {checkUDPConnectivity} from './go_helpers';
import {ChildProcessHelper, ProcessTerminatedSignalError} from './process';
import {RoutingDaemon} from './routing_service';
import {VpnTunnel} from './vpn_tunnel';
import {
TransportConfigJson,
TunnelStatus,
} from '../src/www/app/outline_server_repository/vpn';
import * as config from '../src/www/app/outline_server_repository/config';
import {TunnelStatus} from '../src/www/app/outline_server_repository/vpn';

const isLinux = platform() === 'linux';
const isWindows = platform() === 'win32';
Expand Down Expand Up @@ -66,7 +64,7 @@ export class GoVpnTunnel implements VpnTunnel {

constructor(
private readonly routing: RoutingDaemon,
readonly transportConfig: TransportConfigJson
readonly transportConfig: config.TransportConfigJson
) {
this.tun2socks = new GoTun2socks();

Expand Down Expand Up @@ -251,7 +249,7 @@ class GoTun2socks {
* @param isUdpEnabled Indicates whether the remote Outline server supports UDP.
*/
async start(
config: TransportConfigJson,
config: config.TransportConfigJson,
isUdpEnabled: boolean
): Promise<void> {
// ./tun2socks.exe \
Expand Down
10 changes: 4 additions & 6 deletions client/electron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ import {GoVpnTunnel} from './go_vpn_tunnel';
import {installRoutingServices, RoutingDaemon} from './routing_service';
import {TunnelStore} from './tunnel_store';
import {VpnTunnel} from './vpn_tunnel';
import * as config from '../src/www/app/outline_server_repository/config';
import {
getHostFromTransportConfig,
setTransportConfigHost,
StartRequestJson,
TunnelConfigJson,
TunnelStatus,
} from '../src/www/app/outline_server_repository/vpn';
import * as errors from '../src/www/model/errors';
Expand Down Expand Up @@ -346,22 +344,22 @@ async function tearDownAutoLaunch() {
// Factory function to create a VPNTunnel instance backed by a network stack
// specified at build time.
async function createVpnTunnel(
tunnelConfig: TunnelConfigJson,
tunnelConfig: config.TunnelConfigJson,
isAutoConnect: boolean
): Promise<VpnTunnel> {
// We must convert the host from a potential "hostname" to an "IP" address
// because startVpn will add a routing table entry that prefixed with this
// host (e.g. "<host>/32"), therefore <host> must be an IP address.
// TODO: make sure we resolve it in the native code
const host = getHostFromTransportConfig(tunnelConfig.transport);
const host = config.getHostFromTransportConfig(tunnelConfig.transport);
if (!host) {
throw new errors.IllegalServerConfiguration('host is missing');
}
const hostIp = await lookupIp(host);
const routing = new RoutingDaemon(hostIp || '', isAutoConnect);
// Make sure the transport will use the IP we will allowlist.
const resolvedTransport =
setTransportConfigHost(tunnelConfig.transport, hostIp) ??
config.setTransportConfigHost(tunnelConfig.transport, hostIp) ??
tunnelConfig.transport;
const tunnel = new GoVpnTunnel(routing, resolvedTransport);
routing.onNetworkChange = tunnel.networkChanged.bind(tunnel);
Expand Down

0 comments on commit 2d52f57

Please sign in to comment.