Beispiel #1
0
        public Task <bool> Start(OpenVpnProcessParams processParams)
        {
            _startCompletionSource?.TrySetCanceled();
            _startCompletionSource = new TaskCompletionSource <bool>();

            string arguments = GetCommandLineArguments(processParams);

            _process = _processes.Process(_config.ExePath, arguments);
            AddEventHandlers();
            _process.Start();

            _logger.Info("OpenVPN <- Management channel password");
            _process.StandardInput.WriteLine(processParams.Password);

            return(_startCompletionSource.Task);
        }
Beispiel #2
0
        public Task <bool> Start(OpenVpnProcessParams processParams)
        {
            var localIp = new BestLocalEndpoint(processParams.Endpoint).Ip();

            var arguments = new CommandLineArguments()
                            .Add(new BasicArguments(_config))
                            .Add(new ManagementArguments(_config, processParams.ManagementPort))
                            .Add(new EndpointArguments(processParams.Endpoint))
                            .Add(new BindArguments(localIp))
                            .Add(new CustomDnsArguments(processParams.CustomDns))
                            .Add(new TlsVerifyArguments(_config, processParams.Endpoint.Server.Name));

            if (processParams.SplitTunnelMode == SplitTunnelMode.Permit)
            {
                arguments.Add(new LowDefaultRouteArgument());
            }

            if (processParams.SplitTunnelMode != SplitTunnelMode.Disabled &&
                processParams.SplitTunnelIPs.Count > 0)
            {
                arguments.Add(new SplitTunnelRoutesArgument(
                                  processParams.SplitTunnelIPs,
                                  processParams.SplitTunnelMode));
            }

            _startCompletionSource?.TrySetCanceled();
            _startCompletionSource = new TaskCompletionSource <bool>();

            _process = _processes.Process(_config.ExePath, arguments);
            AddEventHandlers();
            _process.Start();

            _logger.Info("OpenVPN <- Management channel password");
            _process.StandardInput.WriteLine(processParams.Password);

            return(_startCompletionSource.Task);
        }