public static List <FreeDNSURL> CurrentHosts(AfraidDNSSettings settings)
        {
            List <FreeDNSURL> updateURLs = new List <FreeDNSURL>();

            try
            {
                string       url       = endPointURL + settings.HashedLogin;
                string       response  = GenericHelper.MakeHTTPGETRequest(url);
                StringReader strReader = new StringReader(response);
                string       line      = string.Empty;
                while (!string.IsNullOrEmpty(line = strReader.ReadLine()))
                {
                    string[] parts = line.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length == 3)
                    {
                        if (settings == null || !settings.Hosts.Any() || settings.Hosts.Contains(parts[0]))
                        {
                            updateURLs.Add(new FreeDNSURL()
                            {
                                url = parts[2], entry = parts[0]
                            });
                        }
                    }
                }
            }
            catch (Exception e)
            {
                errorMessage = e.ToString();
            }
            return(updateURLs);
        }
        public static string RunUpdates(AfraidDNSSettings settings)
        {
            string            returnStatus      = "";
            List <FreeDNSURL> hostsToUpdateURLs = CurrentHosts(settings);

            if (hostsToUpdateURLs.Any())
            {
                foreach (FreeDNSURL url in hostsToUpdateURLs)
                {
                    string response = GenericHelper.MakeHTTPGETRequest(url.url);
                    if (response.StartsWith("Exception"))
                    {
                        returnStatus += serviceName + " host " + url.entry + " failed to update due to a system exception. " + response.Replace(Environment.NewLine, " ") + Environment.NewLine;
                    }
                    else if (response.StartsWith("ERROR"))
                    {
                        returnStatus += serviceName + " host " + url.entry + " failed to update to your current IP address. " + response + Environment.NewLine;
                    }
                    else
                    {
                        returnStatus += serviceName + " host " + url.entry + " was successfully updated to point to your current IP address. " + response + Environment.NewLine;
                    }
                }
            }

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

            if (dyndnsServices != null && settings.Enabled)
            {
                // Perform validation
                if (string.IsNullOrEmpty(dyndnsServices.freeDNSLogin.Text))
                {
                    errors++;
                    errorMessage += "You must provide your " + serviceName + " login!" + Environment.NewLine;
                }

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

                if (dyndnsServices.freeDNSHosts.Items.Count <= 0)
                {
                    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);
        }
示例#4
0
        private void retreiveHostsButton_Click(object sender, EventArgs e)
        {
            AfraidDNSSettings temp = new AfraidDNSSettings();

            temp.Login    = freeDNSLogin.Text;
            temp.Password = freeDNSPass.Text;
            var hosts = AfraidDNSHelper.CurrentHosts(temp);

            if (hosts.Any())
            {
                freeDNSHosts.Items.Clear();
                foreach (var host in hosts)
                {
                    freeDNSHosts.Items.Add(host.entry);
                }
            }
            else
            {
                MessageBox.Show("Failed to retrieve hosts from " + AfraidDNSHelper.serviceName + "! Please make sure you've entered your login and password." + Environment.NewLine + Environment.NewLine + AfraidDNSHelper.errorMessage, "Generic Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#5
0
        private void saveFreeDNSSettings()
        {
            AfraidDNSSettings aSettings = new AfraidDNSSettings();

            aSettings.Enabled = freeDNSEnable.Checked;
            aSettings.Hosts   = freeDNSHosts.Items.Cast <String>().ToList();
            aSettings.Login   = freeDNSLogin.Text;

            var success = AfraidDNSHelper.SaveOptions(aSettings, this);

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

            try
            {
                if (File.Exists(settingsFile))
                {
                    using (Stream stream = File.Open(settingsFile, FileMode.Open))
                    {
                        settings = (AfraidDNSSettings)bformatter.Deserialize(stream);
                    }

                    settings.Password = GenericHelper.DecodeFrom64(settings.Password);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            if (dyndnsServices != null)
            {
                dyndnsServices.freeDNSPass.Text       = settings.Password;
                dyndnsServices.freeDNSPassVerify.Text = settings.Password;
                dyndnsServices.freeDNSEnable.Checked  = settings.Enabled;
                dyndnsServices.freeDNSHosts.Items.Clear();
                if (settings.Hosts.Any())
                {
                    dyndnsServices.freeDNSHosts.Items.AddRange(settings.Hosts.ToArray());
                }
                dyndnsServices.freeDNSLogin.Text = settings.Login;
            }

            return(settings);
        }
        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();
            }
        }
示例#8
0
 private void getFreeDNSSettings()
 {
     afraidDNSSettings = AfraidDNSHelper.LoadOptions(this);
 }