private void LoadIpAddressCb(RecordUpdateRequest theRur)
        {
            string strJsonIp = string.Format("Dynamic/Public (JSONIP.com) / {0}", DnsCymbalUpdater.GetPublicIP());
            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface nic in nics)
            {
                if (nic.NetworkInterfaceType == NetworkInterfaceType.Loopback)
                {
                    // Skip
                }
                else if(nic.OperationalStatus == OperationalStatus.Up && nic.Speed > 0)
                {
                    _cbIpAddress.Items.Add(new IpAddressOption(nic));
                }
            }

            // Add JSONIP dynamic option
            _cbIpAddress.Items.Add(strJsonIp);

            // JSONIP.com option selected?
            if (null != theRur && theRur.IpAddressType == RecordUpdateRequest.IpAddressTypes.JsonIp)
            {
                _cbIpAddress.SelectedItem = strJsonIp;
                _toolTip.SetToolTip(_cbIpAddress, strJsonIp);
            }
        }
Example #2
0
        private void LoadIpAddressCb(RecordUpdateRequest theRur)
        {
            string strJsonIp = string.Format("Dynamic/Public (JSONIP.com) / {0}", DnsCymbalUpdater.GetPublicIP());

            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface nic in nics)
            {
                if (nic.NetworkInterfaceType == NetworkInterfaceType.Loopback)
                {
                    // Skip
                }
                else if (nic.OperationalStatus == OperationalStatus.Up && nic.Speed > 0)
                {
                    _cbIpAddress.Items.Add(new IpAddressOption(nic));
                }
            }

            // Add JSONIP dynamic option
            _cbIpAddress.Items.Add(strJsonIp);

            // JSONIP.com option selected?
            if (null != theRur && theRur.IpAddressType == RecordUpdateRequest.IpAddressTypes.JsonIp)
            {
                _cbIpAddress.SelectedItem = strJsonIp;
                _toolTip.SetToolTip(_cbIpAddress, strJsonIp);
            }
        }
Example #3
0
        private void ConfigurationForm_Load(object sender, EventArgs e)
        {
            try
            {
                _chkAutoStartApp.Checked = _config.AutoStartApplication;

                // Show the config we currently have...
                if (_config.RecordUpdateRequests.Count > 0)
                {
                    RecordUpdateRequest theRur = _config.RecordUpdateRequests[0];
                    _chkEnableDNSimple.Checked = theRur.Enabled;
                    _txtEmailAddr.Text         = theRur.EmailAddress;
                    _txtPassword.Text          = Str_PwordUnchanged;
                    _chkIsApiToken.Checked     = theRur.IsApiToken;
                    _txtDomain.Text            = theRur.Domain;
                    _txtRecordId.Text          = theRur.RecordId.ToString();
                    _txtRecordName.Text        = theRur.RecordName;
                    _txtUpdateFreq.Text        = theRur.UpdateFrequencyMinutes.ToString();

                    LoadIpAddressCb(theRur);
                    EnableDNSimpleControls(theRur.Enabled);
                }
                else
                {
                    LoadIpAddressCb(null);
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
Example #4
0
        public void Save()
        {
            if (this.RecordUpdateRequests.Count > 0)
            {
                RecordUpdateRequest rur = this.RecordUpdateRequests[0];
                _config.AppSettings.Settings[Name.DNSimple_UpdaterEnabled].Value    = rur.Enabled.ToString();
                _config.AppSettings.Settings[Name.DNSimple_Email].Value             = rur.EmailAddress;
                _config.AppSettings.Settings[Name.DNSimple_Pword].Value             = ConvertToBase64(rur.Password);
                _config.AppSettings.Settings[Name.DNSimple_Domain].Value            = rur.Domain;
                _config.AppSettings.Settings[Name.DNSimple_RecordId].Value          = rur.RecordId.ToString();
                _config.AppSettings.Settings[Name.DNSimple_RecordName].Value        = rur.RecordName;
                _config.AppSettings.Settings[Name.DNSimple_UpdateFreqMinutes].Value = rur.UpdateFrequencyMinutes.ToString();
            }

            _config.Save();
        }
Example #5
0
        private static void UpdateRecordIfNeeded(RecordUpdateRequest rur)
        {
            try
            {
                // Is the update request enabled?
                if (rur.Enabled)
                {
                    // Yes, so validate first
                    rur.Validate();

                    // Check if it is time to update...
                    bool bUpdate = true;
                    if (rur.LastUpdated.HasValue)
                    {
                        TimeSpan ts = DateTime.Now.Subtract(rur.LastUpdated.Value);
                        bUpdate = ts.TotalMinutes >= rur.UpdateFrequencyMinutes;
                    }

                    // Update?
                    if (bUpdate)
                    {
                        string pwd = null;
                        string tok = null;
                        if (rur.IsApiToken)
                        {
                            tok = rur.Password;
                        }
                        else
                        {
                            pwd = rur.Password;
                        }

                        DNSimple.DNSimpleRestClient c = new DNSimpleRestClient(rur.EmailAddress, pwd, tok);

                        rur.RecordContent = GetPublicIP();
                        dynamic ret = c.UpdateRecord(rur.Domain, rur.RecordId, rur.RecordName, rur.RecordContent);
                        rur.LastUpdated = DateTime.Now;
                    }
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
Example #6
0
        private void _btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                RecordUpdateRequest theRur;
                if (0 < _config.RecordUpdateRequests.Count)
                {
                    theRur = _config.RecordUpdateRequests[0];
                }
                else
                {
                    theRur = new RecordUpdateRequest();
                    _config.RecordUpdateRequests.Add(theRur);
                }

                theRur.Enabled      = _chkEnableDNSimple.Checked;
                theRur.EmailAddress = _txtEmailAddr.Text;
                if (_txtPassword.Text != Str_PwordUnchanged)
                {
                    theRur.Password = _txtPassword.Text;
                }
                theRur.IsApiToken             = _chkIsApiToken.Checked;
                theRur.Domain                 = _txtDomain.Text;
                theRur.RecordId               = Convert.ToInt32(_txtRecordId.Text);
                theRur.RecordName             = _txtRecordName.Text;
                theRur.UpdateFrequencyMinutes = Convert.ToInt32(_txtUpdateFreq.Text);

                _config.AutoStartApplication = _chkAutoStartApp.Checked;

                // Save the config
                _config.Save();

                // Close the form
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
        private static void UpdateRecordIfNeeded(RecordUpdateRequest rur)
        {
            try
            {
                // Is the update request enabled?
                if (rur.Enabled)
                {
                    // Yes, so validate first
                    rur.Validate();

                    // Check if it is time to update...
                    bool bUpdate = true;
                    if (rur.LastUpdated.HasValue)
                    {
                        TimeSpan ts = DateTime.Now.Subtract(rur.LastUpdated.Value);
                        bUpdate = ts.TotalMinutes >= rur.UpdateFrequencyMinutes;
                    }

                    // Update?
                    if (bUpdate)
                    {
                        string pwd = null;
                        string tok = null;
                        if(rur.IsApiToken)
                        {
                            tok = rur.Password;
                        }
                        else
                        {
                            pwd = rur.Password;
                        }

                        DNSimple.DNSimpleRestClient c = new DNSimpleRestClient(rur.EmailAddress, pwd, tok);

                        rur.RecordContent = GetPublicIP();
                        dynamic ret = c.UpdateRecord(rur.Domain, rur.RecordId, rur.RecordName, rur.RecordContent);
                        rur.LastUpdated = DateTime.Now;
                    }
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
        private void _btnOk_Click(object sender, EventArgs e)
        {
            try
            {

                RecordUpdateRequest theRur;
                if (0 < _config.RecordUpdateRequests.Count)
                {
                    theRur = _config.RecordUpdateRequests[0];
                }
                else
                {
                    theRur = new RecordUpdateRequest();
                    _config.RecordUpdateRequests.Add(theRur);
                }

                theRur.Enabled = _chkEnableDNSimple.Checked;
                theRur.EmailAddress = _txtEmailAddr.Text;
                if (_txtPassword.Text != Str_PwordUnchanged)
                {
                    theRur.Password = _txtPassword.Text;
                }
                theRur.IsApiToken = _chkIsApiToken.Checked;
                theRur.Domain = _txtDomain.Text;
                theRur.RecordId = Convert.ToInt32(_txtRecordId.Text);
                theRur.RecordName = _txtRecordName.Text;
                theRur.UpdateFrequencyMinutes = Convert.ToInt32(_txtUpdateFreq.Text);

                _config.AutoStartApplication = _chkAutoStartApp.Checked;

                // Save the config
                _config.Save();

                // Close the form
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }