public static XPertDNSSettings LoadOptions(dyndnsServices dyndnsServices = null)
        {
            XPertDNSSettings settings = new XPertDNSSettings();

            try
            {
                if (File.Exists(settingsFile))
                {
                    using (Stream stream = File.Open(settingsFile, FileMode.Open))
                    {
                        settings = (XPertDNSSettings)bformatter.Deserialize(stream);
                    }
                    settings.Password = GenericHelper.DecodeFrom64(settings.Password);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            if (dyndnsServices != null)
            {
                dyndnsServices.XPertDNSPass.Text        = settings.Password;
                dyndnsServices.XPertDNSConfirmPass.Text = settings.Password;
                dyndnsServices.xpertEnable.Checked      = settings.Enabled;
                dyndnsServices.dynIDsXPertDNS.Items.Clear();
                if (settings.Hosts.Any())
                {
                    dyndnsServices.dynIDsXPertDNS.Items.AddRange(settings.Hosts.ToArray());
                }
                dyndnsServices.login4XPertDNS.Text = settings.Login;
            }

            return(settings);
        }
        public static string SaveOptions(XPertDNSSettings settings, dyndnsServices dyndnsServices = null)
        {
            int    errors       = 0;
            string errorMessage = string.Empty;

            if (dyndnsServices != null && settings.Enabled)
            {
                // Perform validation
                if (string.IsNullOrEmpty(dyndnsServices.login4XPertDNS.Text))
                {
                    errors++;
                    errorMessage += "You must provide your " + serviceName + " login email address!" + Environment.NewLine;
                }
                else
                {
                    if (!GenericHelper.IsValidEmail(dyndnsServices.login4XPertDNS.Text))
                    {
                        errors++;
                        errorMessage += "Your " + serviceName + " login must be your email address!" + Environment.NewLine;
                    }
                }

                if (dyndnsServices.XPertDNSPass.Text != dyndnsServices.XPertDNSConfirmPass.Text)
                {
                    errors++;
                    errorMessage += "The " + serviceName + " passwords do not match!" + Environment.NewLine;
                }
                else
                {
                    if (!string.IsNullOrEmpty(dyndnsServices.XPertDNSPass.Text) && !string.IsNullOrEmpty(dyndnsServices.XPertDNSConfirmPass.Text))
                    {
                        settings.Password = dyndnsServices.XPertDNSPass.Text;
                    }
                    else
                    {
                        errors++;
                        errorMessage += "You must provide your " + serviceName + " password and confirm the password." + Environment.NewLine;
                    }
                }

                if (dyndnsServices.dynIDsXPertDNS.Items.Count <= 0)
                {
                    errors++;
                    errorMessage += "There are no " + serviceName + " host IDs to save!" + Environment.NewLine;
                }
            }

            if (errors == 0)
            {
                //serialize
                settings.Password = GenericHelper.EncodeTo64(settings.Password);
                using (Stream stream = File.Open(settingsFile, FileMode.Create))
                {
                    bformatter.Serialize(stream, settings);
                }
            }

            return(errorMessage);
        }
Esempio n. 3
0
        private void saveXpertSettings()
        {
            XPertDNSSettings xSettings = new XPertDNSSettings();

            xSettings.Enabled = xpertEnable.Checked;
            xSettings.Hosts   = dynIDsXPertDNS.Items.Cast <String>().ToList();
            xSettings.Login   = login4XPertDNS.Text;

            var success = XpertDNSHelper.SaveOptions(xSettings, this);

            if (string.IsNullOrEmpty(success))
            {
                successCount++;
                saveSuccess += "Your " + XpertDNSHelper.serviceName + " settings were successfully saved! \n";
            }
            else
            {
                customError err = new customError("You have the following problems with your " + XpertDNSHelper.serviceName + " Settings!", success);
                err.intervalForTimer = 30000;
                err.Show();
                errorCount++;
            }
        }
        public static string RunUpdates(XPertDNSSettings settings, string IPAddress)
        {
            string returnStatus = "";

            foreach (string host in settings.Hosts)
            {
                string url      = endPointURL + "?dynid=" + host + "&ip=" + IPAddress + "&uname=" + settings.Login + "&password="******"Exception"))
                {
                    returnStatus += serviceName + " host ID " + host + " failed to update due to a system exception. " + response.Replace(Environment.NewLine, " ") + Environment.NewLine;
                }
                else if (response.Trim() != (host + "=Successfully Updated=") && !response.Trim().StartsWith(host + "=Successfully Updated="))
                {
                    returnStatus += serviceName + " host ID " + host + " failed to update to your current IP address. " + response + Environment.NewLine;
                }
                else
                {
                    returnStatus += serviceName + " host ID " + host + " was successfully updated to point to your current IP address. " + response + Environment.NewLine;
                }
            }

            return(returnStatus);
        }
        private void getSavedOptions()
        {
            appSettings = AppHelper.LoadOptions();

            // Reading Saved Options:
            switch (appSettings.TimeIntervalMode)
            {
            default:
            case 1:
                timer1.Interval = appSettings.TimeInterval * 1000;
                break;

            case 2:
                timer1.Interval = appSettings.TimeInterval * 1000 * 60;
                break;

            case 3:
                timer1.Interval = appSettings.TimeInterval * 1000 * 3600;
                break;
            }

            if (appSettings.AutoStart)
            {
                timer1.Enabled         = true;
                timer2.Enabled         = true;
                scanButton.Visible     = false;
                stopScanButton.Visible = true;
            }
            else
            {
                timer1.Enabled         = false;
                timer2.Enabled         = false;
                scanButton.Visible     = true;
                stopScanButton.Visible = false;
            }

            switch (appSettings.IPService)
            {
            case 1:
                urlForIPCheck = "https://dynamix.run/ip.php";
                break;

            case 3:
                urlForIPCheck = "http://dinofly.com/misc/ipcheck.php";
                break;

            case 2:
                urlForIPCheck = "http://grabip.tk";
                break;

            default:
                urlForIPCheck = "https://dynamix.run/ip.php";
                break;
            }


            if (File.Exists(phpPathFile))
            {
                phpPath = File.ReadAllText(phpPathFile);
            }

            if (appSettings.RunDynamicServices)
            {
                XpertDNSSettings  = XpertDNSHelper.LoadOptions();
                dynamixSettings   = DynamixHelper.LoadOptions();
                afraidDNSSettings = AfraidDNSHelper.LoadOptions();
                noIPDNSSettings   = NoIPHelper.LoadOptions();
            }
        }
Esempio n. 6
0
 private void getXpertSettings()
 {
     xpertDNSSettings = XpertDNSHelper.LoadOptions(this);
 }