private string getExternalIP()
        {
            try
            {
                if (string.IsNullOrEmpty(urlForIPCheck))
                {
                    urlForIPCheck = "https://dynamix.run/ip.php";
                }
                var response = GenericHelper.MakeHTTPGETRequest(urlForIPCheck);

                //Search for the ip in the html
                int first = response.IndexOf("Address: ") + 9;
                int last  = response.LastIndexOf("</body>");
                if (first != -1 && last != -1)
                {
                    response = response.Substring(first, last - first);
                }
                response = GenericHelper.ParseIPv4Addr(response);

                //Write the IP to oldip.txt
                if (!string.IsNullOrEmpty(response) && GenericHelper.CheckIPValid(response))
                {
                    if (!File.Exists(oldIPFile))
                    {
                        writeOldIP(response);
                        oldIP = response;
                    }
                    else
                    {
                        oldIP = loadOldIP();
                    }
                    currentIP.Text = response;
                }
                resetTimeLabels();
                return(response);
            }
            catch
            {
                resetTimeLabels();
                customError unableToConnect = new customError("Unable to determine your external IP address.", "Unable to contact " + urlForIPCheck + "\nA firewall has blocked the connection!\nYou have no connection to the internet!");
                if (timer1.Enabled == true)
                {
                    if (timer1.Interval > 10000)
                    {
                        unableToConnect.intervalForTimer = timer1.Interval;
                    }
                    else
                    {
                        unableToConnect.intervalForTimer = 10000;
                    }
                }
                else
                {
                    unableToConnect.intervalForTimer = 10000;
                }
                unableToConnect.Show();
                //MessageBox.Show(" \n\tPossible causes:\n\t No internet connection\n\t DynDns IP service down.", "Error Determining IP", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return("");
            }
        }
        private void parseMessagesAndShowResults(string messages)
        {
            string success = string.Empty;
            string error   = string.Empty;

            string[] finalMessages = messages.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string mess in finalMessages)
            {
                if (mess.IndexOf("failed") == -1)
                {
                    success += mess + Environment.NewLine;
                }
                else
                {
                    error += mess + Environment.NewLine;
                }
            }

            if (error != "" & error != null)
            {
                customError showError = new customError("Error Synchronizing to Service", error);
                showError.intervalForTimer = 60000;
                showError.Show();
            }
            if (success != "" & success != null)
            {
                success synced = new success(success);
                synced.Show();
            }
        }
Beispiel #3
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";
            }
        }
Beispiel #4
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++;
            }
        }
Beispiel #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++;
            }
        }
Beispiel #6
0
        private void saveNoIPSettings()
        {
            NoIPDNSSettings noIPSettings = new NoIPDNSSettings();

            noIPSettings.Enabled = noIPEnabled.Checked;
            noIPSettings.Hosts   = noIPHosts.Items.Cast <String>().ToList();
            noIPSettings.Login   = noIPLogin.Text;

            string result = NoIPHelper.SaveOptions(noIPSettings, this);

            if (result != string.Empty)
            {
                customError err = new customError("You have the following problems with your " + NoIPHelper.serviceName + " settings!", result);
                err.intervalForTimer = 30000;
                err.Show();
                errorCount++;
            }
            else
            {
                successCount++;
                saveSuccess += "Your " + NoIPHelper.serviceName + " settings were successfully saved! \n";
            }
        }
        private void runExternalApps()
        {
            if (appSettings.ExternalScriptToRun.Any())
            {
                string errorsForScripts = "", successesForScripts = "";
                foreach (string prog in appSettings.ExternalScriptToRun)
                {
                    // Add the positonal parameters
                    // Send oldIP and newIP values for to all executables
                    string parameters = " " + oldIP + " " + IPAddress;
                    string extension  = "";
                    if (File.Exists(prog))
                    {
                        // Check and see if the program has a valid extension.  If it is, run it... if not, show error!
                        if (prog.LastIndexOf('.') == -1)
                        {
                            extension = "NO_EXTENSION";
                        }
                        else
                        {
                            extension = prog.Substring(prog.LastIndexOf('.'));
                        }
                        switch (extension)
                        {
                        case ".php":
                            // Add the positonal parameters
                            // Send oldIP and newIP values for to all executables
                            string runPHPProg = "\"" + prog + "\"" + parameters;

                            // phpPath will not be set to "" if they were prompted in the past for a PHP path since it didn't exist where it was supposed to be (perhaps no installation of Dynamix DNS).
                            if (phpPath != "")
                            {
                                processRun(phpPath, runPHPProg);
                                successesForScripts += prog + " ran successfully!\n";
                            }
                            else
                            {
                                phpExecutablePrompt phpNew = new phpExecutablePrompt();
                                if (Application.OpenForms.OfType <phpExecutablePrompt>().Count() > 0)
                                {
                                }
                                else
                                {
                                    phpNew.ShowDialog();
                                }
                                string returnedPath = phpNew.getPath();
                                phpPath = returnedPath;
                                if (returnedPath != "")
                                {
                                    processRun(returnedPath, runPHPProg);
                                    successesForScripts += prog + " ran successfully!\n";
                                }

                                else
                                {
                                    errorsForScripts += "Unable to find the php.exe executable on your system!  Until the path is entered, you cannot run .php scripts!";
                                }
                            }
                            break;

                        case ".exe":
                            processRun(prog, parameters);
                            successesForScripts += prog + " ran successfully!\n";
                            break;

                        case ".bat":
                            processRun(prog, parameters);
                            successesForScripts += prog + " ran successfully!\n";
                            break;

                        case ".jar":
                            processRun(prog, parameters);
                            successesForScripts += prog + " ran successfully!\n";
                            break;

                        default:
                            errorsForScripts += prog + " has an invalid extension of " + extension + "!  Only .exe, .php, .bat, and .jar are allowed!\n";
                            break;
                        }
                    }
                    else
                    {
                        errorsForScripts += prog + " doesn't even exist!";
                    }
                }
                if (errorsForScripts != "")
                {
                    customError newError = new customError("The following scripts did not run because:", errorsForScripts);
                    newError.Show();
                    //MessageBox.Show(errorsForScripts, "Error Running Scripts", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (successesForScripts != "")
                {
                    success scriptsHaveRan = new success(successesForScripts);
                    scriptsHaveRan.Show();
                }
            }
        }