public static string RunUpdates(DynamixSettings settings, string IPAddress)
        {
            string returnStatus = "";

            foreach (string host in settings.Hosts)
            {
                SubdomainDomain info = DomainHelper.getSubdomainDomainFromString(host);
                if (info != null && !string.IsNullOrEmpty(info.domain))
                {
                    string url = endPointURL + "?key=" + settings.Password + "&action=ddns&subaction=update";
                    url += (!string.IsNullOrEmpty(info.subdomain) ? "&subdomain=" + info.subdomain : "");
                    url += "&domain=" + info.domain + "&ip=" + IPAddress;
                    string response = GenericHelper.MakeHTTPGETRequest(url);
                    if (response == "1")
                    {
                        returnStatus += serviceName + " host " + host + " was successfully updated to your current IP address." + Environment.NewLine;
                    }
                    else if (response == "0")
                    {
                        returnStatus += serviceName + " host " + host + " failed to update to your current IP address." + Environment.NewLine;
                    }
                    else if (response.StartsWith("Exception"))
                    {
                        returnStatus += serviceName + " host " + host + " failed to update due to a system exception. " + response.Replace(Environment.NewLine, " ") + Environment.NewLine;
                    }
                    else if (response.StartsWith("error="))
                    {
                        returnStatus += serviceName + " host " + host + " failed to update. " + response.Replace("error=", "");
                    }
                }
            }

            return(returnStatus);
        }
        public static string SaveOptions(DynamixSettings settings)
        {
            int    errors       = 0;
            string errorMessage = string.Empty;

            if (string.IsNullOrEmpty(settings.Password) && settings.Enabled)
            {
                errors++;
                errorMessage += "You cannot leave the Dynamix user key field blank!" + Environment.NewLine;
            }

            if (!settings.Hosts.Any() && settings.Enabled)
            {
                errors++;
                errorMessage += "There are no " + serviceName + " hosts 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);
        }
        public static DynamixSettings LoadOptions(dyndnsServices dyndnsServices = null)
        {
            DynamixSettings settings = new DynamixSettings();

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

            if (dyndnsServices != null)
            {
                if (settings.Hosts.Any())
                {
                    dyndnsServices.hostsBoxDynamix.Items.Clear();
                    dyndnsServices.hostsBoxDynamix.Items.AddRange(settings.Hosts.Select(c => c).ToArray());
                }
                dyndnsServices.enableDynamixCB.Checked  = settings.Enabled;
                dyndnsServices.dynamix_user_key_TB.Text = settings.Password;
            }

            return(settings);
        }
Example #4
0
        private void saveDynamixSettingsLogic()
        {
            // UI to class
            DynamixSettings updatedSettings = new DynamixSettings();

            updatedSettings.Enabled  = enableDynamixCB.Checked;
            updatedSettings.Password = dynamix_user_key_TB.Text;
            updatedSettings.Hosts    = hostsBoxDynamix.Items.Cast <String>().ToList();

            // Save the options using our static class
            string result = DynamixHelper.SaveOptions(updatedSettings);

            // Display any errors
            if (result != string.Empty)
            {
                customError err = new customError("You have the following problems with your Dynamix settings!", result);
                err.intervalForTimer = 30000;
                err.Show();
                errorCount++;
            }
            else
            {
                successCount++;
                saveSuccess += "Your " + DynamixHelper.serviceName + " settings were successfully saved! \n";
            }
        }
        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();
            }
        }
Example #6
0
 private void getDynamixSettings()
 {
     dynamixSettings = DynamixHelper.LoadOptions(this);
 }