Пример #1
0
 public Config()
     : base()
 {
     CloudFlareAPIKey = "";
     CloudFlareEmailAddress = "";
     LogToDisk = false;
     EmailAlertIPChange = true;
     EmailAlertNewVersion = true;
     EmailAlertUpdateError = true;
     EmailFrom = "";
     EmailTo = "";
     GetExternalIPMethodOrder = new GetExternalIPv4Methods[] { GetExternalIPv4Methods.UnicastAddress,
                                                               GetExternalIPv4Methods.NatPmp,
                                                               GetExternalIPv4Methods.Upnp,
                                                               GetExternalIPv4Methods.Http8880,
                                                               GetExternalIPv4Methods.Http80 };
     LastIPAddress = IPAddress.None.ToString();
     PointAPIKey = "";
     PointEmailAddress = "";
     SmtpHostname = "";
     SmtpPassword = new RMSecureString();
     SmtpPort = 587;
     SmtpSsl = true;
     SmtpUsername = "";
     if (!Load()) Save(); // Load (and save default config if not found)
 }
Пример #2
0
 public Config() : base()
 {
     CloudFlareAPIKey       = "";
     CloudFlareEmailAddress = "";
     LogToDisk             = false;
     EmailAlertIPChange    = true;
     EmailAlertNewVersion  = true;
     EmailAlertUpdateError = true;
     EmailFrom             = "";
     EmailTo = "";
     GetExternalIPMethodOrder = new GetExternalIPv4Methods[] { GetExternalIPv4Methods.UnicastAddress,
                                                               GetExternalIPv4Methods.NatPmp,
                                                               GetExternalIPv4Methods.Upnp,
                                                               GetExternalIPv4Methods.Http8880,
                                                               GetExternalIPv4Methods.Http80 };
     LastIPAddress     = IPAddress.None.ToString();
     PointAPIKey       = "";
     PointEmailAddress = "";
     SmtpHostname      = "";
     SmtpPassword      = new RMSecureString();
     SmtpPort          = 587;
     SmtpSsl           = true;
     SmtpUsername      = "";
     if (!Load())
     {
         Save();          // Load (and save default config if not found)
     }
 }
Пример #3
0
 private void CorrectEnumArrays()
 {
     // ConfigHelper returns enum arrays as int arrays, so we need to fix that
     GetExternalIPv4Methods[] NewMethodOrder = new GetExternalIPv4Methods[GetExternalIPMethodOrder.Length];
     for (int i = 0; i < GetExternalIPMethodOrder.Length; i++)
     {
         NewMethodOrder[i] = (GetExternalIPv4Methods)((int)GetExternalIPMethodOrder[i]);
     }
     GetExternalIPMethodOrder = NewMethodOrder;
 }
Пример #4
0
        void cmdSave_Click(object sender, EventArgs e)
        {
            if (lvResults.CheckedItems.Count == 0)
            {
                Dialog.Error("Please select at least one IP detection method", "Error");
                return;
            }

            int Index = 0;
            GetExternalIPv4Methods[] NewMethodOrder = new GetExternalIPv4Methods[lvResults.CheckedItems.Count];
            if (lvResults.Items[0].Checked) NewMethodOrder[Index++] = GetExternalIPv4Methods.UnicastAddress;
            if (lvResults.Items[1].Checked) NewMethodOrder[Index++] = GetExternalIPv4Methods.NatPmp;
            if (lvResults.Items[2].Checked) NewMethodOrder[Index++] = GetExternalIPv4Methods.Upnp;
            if (lvResults.Items[3].Checked) NewMethodOrder[Index++] = GetExternalIPv4Methods.Http8880;
            if (lvResults.Items[4].Checked) NewMethodOrder[Index++] = GetExternalIPv4Methods.Http80;
            Config.Default.GetExternalIPMethodOrder = NewMethodOrder;
            Config.Default.Save();

            DialogResult = DialogResult.OK;
        }
Пример #5
0
        void cmdSave_Click(object sender, EventArgs e)
        {
            if (lvResults.CheckedItems.Count == 0)
            {
                Dialog.Error("Please select at least one IP detection method", "Error");
                return;
            }

            int Index = 0;

            GetExternalIPv4Methods[] NewMethodOrder = new GetExternalIPv4Methods[lvResults.CheckedItems.Count];
            if (lvResults.Items[0].Checked)
            {
                NewMethodOrder[Index++] = GetExternalIPv4Methods.UnicastAddress;
            }
            if (lvResults.Items[1].Checked)
            {
                NewMethodOrder[Index++] = GetExternalIPv4Methods.NatPmp;
            }
            if (lvResults.Items[2].Checked)
            {
                NewMethodOrder[Index++] = GetExternalIPv4Methods.Upnp;
            }
            if (lvResults.Items[3].Checked)
            {
                NewMethodOrder[Index++] = GetExternalIPv4Methods.Http8880;
            }
            if (lvResults.Items[4].Checked)
            {
                NewMethodOrder[Index++] = GetExternalIPv4Methods.Http80;
            }
            Config.Default.GetExternalIPMethodOrder = NewMethodOrder;
            Config.Default.Save();

            DialogResult = DialogResult.OK;
        }
Пример #6
0
        public static IPAddress GetExternalIPv4(GetExternalIPv4Methods[] methodOrder)
        {
            IPAddress Result = IPAddress.None;

            foreach (GetExternalIPv4Methods method in methodOrder)
            {
                try
                {
                    switch (method)
                    {
                        case GetExternalIPv4Methods.Http80:
                            Result = GetExternalIPv4ByHttp(80);
                            break;
                        case GetExternalIPv4Methods.Http81:
                            Result = GetExternalIPv4ByHttp(81);
                            break;
                        case GetExternalIPv4Methods.NatPmp:
                            Result = GetExternalIPv4ByNatPmp();
                            break;
                        case GetExternalIPv4Methods.UnicastAddress:
                            Result = GetExternalIPv4ByUnicastAddress();
                            break;
                        case GetExternalIPv4Methods.Upnp:
                            Result = GetExternalIPv4ByUpnp();
                            break;
                    }
                    if (Result != IPAddress.None) break;
                }
                catch
                {
                    // Ignore, move on to the next method type
                }
            }

            return Result;
        }
Пример #7
0
 private void CorrectEnumArrays()
 {
     // ConfigHelper returns enum arrays as int arrays, so we need to fix that
     GetExternalIPv4Methods[] NewMethodOrder = new GetExternalIPv4Methods[GetExternalIPMethodOrder.Length];
     for (int i = 0; i < GetExternalIPMethodOrder.Length; i++)
     {
         NewMethodOrder[i] = (GetExternalIPv4Methods)((int)GetExternalIPMethodOrder[i]);
     }
     GetExternalIPMethodOrder = NewMethodOrder;
 }