Exemplo n.º 1
0
        private async Task <bool> DoesIPMatchAppIPAsync()
        {
            Nest.Model.AppDomain defaultDomain = (from domain in AppViewModel.DomainViewModel.Domains
                                                  where domain.Default == true
                                                  select domain).First();

            if (!await Dns.IsDomainIPAsync(Name.Text, defaultDomain.IPAddress))
            {
                IsServiceActive = false;
                await ErrorHandler.ExceptionAsync(this, "The domain name " + Name.Text +
                                                  " currently does not resolve to " + defaultDomain.IPAddress +
                                                  ". Make sure to update the DNS");

                return(false);
            }

            string unmatchedAlias = await Dns.GetUnmatchedDomainAliasIPAsync(
                Aliases.Text, defaultDomain.IPAddress);

            if (unmatchedAlias != null)
            {
                IsServiceActive = false;
                await ErrorHandler.ExceptionAsync(this, "The alias " + unmatchedAlias +
                                                  " currently does not resolve to " + defaultDomain.IPAddress +
                                                  ". Make sure to update the DNS");

                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
 private async void ButtonCert_ClickedAsync(object sender, EventArgs e)
 {
     if (AppDomainsList.SelectedItem != null)
     {
         Nest.Model.AppDomain browseDomain = AppDomainsList.SelectedItem as Nest.Model.AppDomain;
         AppViewModel.DomainViewModel.EditDomain = browseDomain;
         await MainView.StackViewAsync(new AppDomainCertView(AppViewModel));
     }
 }
Exemplo n.º 3
0
        async private void OnAddButtonClickedAsync(object sender, EventArgs e)
        {
            IsServiceActive = true;

            try
            {
                var existDomains = from domain in AppViewModel.DomainViewModel.Domains
                                   where domain.Tag == Tag.Text
                                   select domain;
                if (existDomains.Any())
                {
                    IsServiceActive = false;
                    await ErrorHandler.ExceptionAsync(this, "The domain with this tag already exist");

                    return;
                }

                existDomains = from domain in AppViewModel.DomainViewModel.Domains
                               where domain.Name == Name.Text
                               select domain;
                if (existDomains.Any())
                {
                    IsServiceActive = false;
                    await ErrorHandler.ExceptionAsync(this, "The domain already exist");

                    return;
                }

                if (!await DoesIPMatchAppIPAsync())
                {
                    return;
                }

                Nest.Model.AppDomain newDomain = CopyUpdate(new Nest.Model.AppDomain());
                if (newDomain != null)
                {
                    await AppViewModel.DomainViewModel.CreateDomainAsync(newDomain);

                    SetPrimaryDomain(newDomain);
                }

                Clear();
            }
            catch (Exception ex)
            {
                await ErrorHandler.ExceptionAsync(this, ex);
            }

            IsServiceActive = false;
        }
Exemplo n.º 4
0
        private Nest.Model.AppDomain CopyUpdate(Nest.Model.AppDomain browsDomain)
        {
            browsDomain.OwnedBy = AppViewModel.EditApp;
            browsDomain.Tag     = Tag.Text;
            browsDomain.Name    = Name.Text;
            if (Aliases.Text == null || Aliases.Text.Length == 0)
            {
                Aliases.Text = null;
            }
            browsDomain.Aliases = Aliases.Text;
            browsDomain.Primary = IsPrimary.IsToggled;

            return(browsDomain);
        }
Exemplo n.º 5
0
        private void SetDefaults()
        {
            bool enableEdits = true;

            if (AppDomainsList.SelectedItem != null)
            {
                Nest.Model.AppDomain browseDomain = AppDomainsList.SelectedItem as Nest.Model.AppDomain;
                browseDomain.CopyTo(AppViewModel.DomainViewModel.EditDomain);
                enableEdits         = !browseDomain.Default;
                IsPrimary.IsToggled = AppViewModel
                                      .EditApp.PrimaryDomainId == browseDomain.Id;
            }

            Tag.IsEnabled       = enableEdits;
            Name.IsEnabled      = enableEdits;
            Aliases.IsEnabled   = enableEdits;
            IsPrimary.IsEnabled = enableEdits;
        }
Exemplo n.º 6
0
 async private void SetPrimaryDomain(Nest.Model.AppDomain priaryDomain)
 {
     /*
      * The default domain is the <apptag>.nestapp.yt
      * this never changes.  The primary domain is the
      * webserver primary domain.  This is needed for
      * SSL certificates.
      *
      */
     try
     {
         priaryDomain.Primary = true;
         AppViewModel.EditApp.PrimaryDomainId = priaryDomain.Id;
         await AppViewModel.UpdateAppAsync(AppViewModel.EditApp);
     }
     catch (Exception ex)
     {
         await ErrorHandler.ExceptionAsync(this, ex);
     }
 }
Exemplo n.º 7
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return(false);
            }

            Nest.Model.AppDomain domain = value as Nest.Model.AppDomain;
            if (domain != null && domain.Default)
            {
                return(false);
            }

            //AppDomainCertificate cert = value as AppDomainCertificate;
            //if (cert != null && cert.Type == "free")
            //{
            //    return false;
            //}

            return(true);
        }
Exemplo n.º 8
0
        private async Task <bool> IsDnsOkAsync()
        {
            Nest.Model.AppDomain defaultDomain = (from domain in AppViewModel.DomainViewModel.Domains
                                                  where domain.Default == true
                                                  select domain).First();

            foreach (Nest.Model.AppDomain domain in AppViewModel.DomainViewModel.Domains)
            {
                if (domain.Default)
                {
                    continue;
                }

                if (!await Dns.IsDomainIPAsync(domain.Name, defaultDomain.IPAddress))
                {
                    await ErrorHandler.ExceptionAsync(this, "The domain name " + domain.Name +
                                                      " currently does not resolve to " + defaultDomain.IPAddress +
                                                      ". Make sure to update the DNS");

                    return(false);
                }

                string unmatchedAlias = await Dns.GetUnmatchedDomainAliasIPAsync(
                    domain.Aliases, defaultDomain.IPAddress);

                if (unmatchedAlias != null)
                {
                    await ErrorHandler.ExceptionAsync(this, "The alias " + unmatchedAlias +
                                                      " currently does not resolve to " + defaultDomain.IPAddress +
                                                      ". Make sure to update the DNS");

                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 9
0
        async private void OnUpdateButtonClickedAsync(object sender, EventArgs e)
        {
            IsServiceActive = true;

            try
            {
                Nest.Model.AppDomain updatingDomain = AppDomainsList.SelectedItem as Nest.Model.AppDomain;

                if (updatingDomain.Default)
                {
                    IsServiceActive = false;
                    await ErrorHandler.ExceptionAsync(this, "Cannot make changes to the default domain");

                    return;
                }

                var existDomains = from domain in AppViewModel.DomainViewModel.Domains
                                   where domain.Tag == Tag.Text && domain.Id != updatingDomain.Id
                                   select domain;
                if (existDomains.Any())
                {
                    IsServiceActive = false;
                    await ErrorHandler.ExceptionAsync(this, "The domain with this tag already exist");

                    return;
                }

                existDomains = from domain in AppViewModel.DomainViewModel.Domains
                               where domain.Name == Name.Text && domain.Id != updatingDomain.Id
                               select domain;
                if (existDomains.Any())
                {
                    IsServiceActive = false;
                    await ErrorHandler.ExceptionAsync(this, "The domain already exist");

                    return;
                }

                if (!await DoesIPMatchAppIPAsync())
                {
                    return;
                }

                Nest.Model.AppDomain updateDomain = CopyUpdate(updatingDomain);
                if (updateDomain != null)
                {
                    bool proceed = true;

                    if (updateDomain.Certificate != null)
                    {
                        proceed = await DisplayAlert("Nester", "This will clear the existing SSL certificate. Proceed?", "Yes", "No");
                    }

                    if (proceed)
                    {
                        updateDomain.Certificate = null;

                        await Process(updateDomain, true,
                                      AppViewModel.DomainViewModel.UpdateDomainAsync
                                      );

                        SetDefaults();

                        if (!AppViewModel.DomainViewModel.Domains.Where(x => x.Primary == true).Any())
                        {
                            SetPrimaryDomain(AppViewModel.DomainViewModel.Domains.First());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                await ErrorHandler.ExceptionAsync(this, ex);
            }

            IsServiceActive = false;
        }