Exemplo n.º 1
0
        private bool StartConnection()
        {
            VPNProperties properties;

            try
            {
                if (UseDedicatedIP)
                {
                    if (!CanConnect)
                    {
                        Messages.ShowMessage(Messages.HostAndProtocolRequired);
                        return(false);
                    }

                    properties = new VPNProperties(Host, PrimaryProtocol);
                }
                else if (UseSmartConnect)
                {
                    List <SmartConnectTag> smartConnectTagsList = new List <SmartConnectTag>();

                    if (SmartConnectTagsListBox?.SelectedItems?.Count > 0)
                    {
                        foreach (var item in SmartConnectTagsListBox.SelectedItems)
                        {
                            smartConnectTagsList.Add((SmartConnectTag)item);
                        }
                    }

                    bool isValidate = AtomHelper.AtomManagerInstance.IsSmartConnectAvailableOnProtocol(PrimaryProtocol, smartConnectTagsList);

                    if (isValidate)
                    {
                        properties = new VPNProperties(PrimaryProtocol, smartConnectTagsList?.Count > 0 ? smartConnectTagsList : null);
                    }
                    else
                    {
                        ParentWindow.ConnectionDialog += "No SmartConnect DNS available for dialing or you are not permitted to this resource";
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }

                properties.DoCheckInternetConnectivity = true;
                AtomHelper.Connect(properties);
                return(true);
            }
            catch (Exception ex)
            {
                ParentWindow.ConnectionDialog += ex.Message;
                return(false);
            }
        }
        private bool StartConnection()
        {
            if (!CanConnect)
            {
                Messages.ShowMessage(Messages.PSKRequired);
                return(false);
            }
            var properties = new VPNProperties(PSK);

            properties.DoCheckInternetConnectivity = true;
            AtomHelper.Connect(properties);
            return(true);
        }