Beispiel #1
0
        static private bool CreateAndConnectToProxyAsync(BaseProxyServer item)
        {
            bool statusChanged = false;

            if (!NetConnUtils.IsConnected(item))
            {
                if (NetConnUtils.IsActiveConnectionPresent())
                {
                    NetConnUtils.CloseAllActiveConnections(false);
                }
                if (NetConnUtils.IsConnectionEntryExist(item) == false)
                {
                    if (item.IsProtocolAvailable(ProxyProtocolTypeEnum.PPTP))
                    {
                        NetConnUtils.CreateConnectionEntry(item, ProxyProtocolTypeEnum.PPTP);
                    }
                    else if (item.IsProtocolAvailable(ProxyProtocolTypeEnum.L2TP))
                    {
                        NetConnUtils.CreateConnectionEntry(item, ProxyProtocolTypeEnum.L2TP);
                    }
                    else
                    {
                        throw new ArgumentException(VpnSelectorLibRes.Non_PPTP_no_L2TP_protocols_available_for_this_vpn_entry);
                    }
                }
                NetConnUtils.OpenConnect(item);
                //DotRasUtils.CurrentProxyServer = item;
                statusChanged = true;
            }
            return(statusChanged);
        }