Example #1
0
        void OnHosts(string data)
        {
            HostsDatabase.Clear(false);

            foreach (var entry in data.Split('|'))
            {
                var param = entry.Split('/');
                if (param.Length == 4)
                {
                    HostsDatabase.Add(false,
                                      param[0].Unescape(EscapeLanguage.Xml),
                                      param[1].Unescape(EscapeLanguage.Xml),
                                      param[2].Unescape(EscapeLanguage.Xml),
                                      param[3] == "1");
                }
            }

            HostsDatabase.Save();
            EventCallbackSystem.InvokeCallback("HostsListUpdated", true);

            HostsDatabase.Lock();
            int numberOfHosts = HostsDatabase.Hosts.Count();

            HostsDatabase.Unlock();
            Logger.Log(LogType.Debug, "Received {0} hosts from server.", numberOfHosts.FormatNumber());
        }
Example #2
0
        void OnRemoveDomain(string data)
        {
            if (HostsDatabase.Remove(false, data.Unescape(EscapeLanguage.Xml)))
            {
                HostsDatabase.Save();
                EventCallbackSystem.InvokeCallback("HostsListUpdated", true);

                Logger.Log(LogType.Debug,
                           "Removed domain {0}",
                           data.Unescape(EscapeLanguage.Xml));
            }
        }
Example #3
0
 void OnRemoveDomain(UserClient client, string data)
 {
     if (HostsDatabase.Remove(false, data.Unescape(EscapeLanguage.Xml)))
     {
         HostsDatabase.Save();
         Logger.Log(LogType.Debug, "Removed domain {0}", data.Unescape(EscapeLanguage.Xml));
         BroadcastPacket("remove-domain {0}\n", data);
     }
     else
     {
         Logger.Log(LogType.Warning, "OnRemoveDomain from {0}: Domain '{1}' not found. [Action ignored]", client.NetworkClient.IP, data.Unescape(EscapeLanguage.Xml));
     }
 }
Example #4
0
 private void addNewHostToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var dlg = new AddEditHostDlg())
     {
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             if (dlg.LocalDomain)
             {
                 HostsDatabase.Add(true, dlg.DomainName, dlg.IPAddress, dlg.Description, dlg.HiddenDomain);
                 HostsDatabase.Save();
                 EventCallbackSystem.InvokeCallback("HostsListUpdated", true);
             }
             else
             {
                 _client.SendAddDomain(dlg.DomainName, dlg.IPAddress, dlg.Description, dlg.HiddenDomain);
             }
         }
     }
 }
Example #5
0
        private void LvLocalHosts_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (lvLocalHosts.SelectedItems.Count == 1)
            {
                var entry = lvLocalHosts.SelectedItems[0].Tag as HostEntry;

                using (var dlg = new AddEditHostDlg(entry, true))
                {
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        HostsDatabase.Remove(true, entry.Name);
                        HostsDatabase.Add(true, dlg.DomainName, dlg.IPAddress, dlg.Description, dlg.HiddenDomain);
                        HostsDatabase.Save();

                        EventCallbackSystem.InvokeCallback("HostsListUpdated", true);
                    }
                }
            }
        }
Example #6
0
        void OnAddDomain(string data)
        {
            var param = data.Split('/');

            if (param.Length == 4)
            {
                HostsDatabase.Add(false,
                                  param[0].Unescape(EscapeLanguage.Xml),
                                  param[1].Unescape(EscapeLanguage.Xml),
                                  param[2].Unescape(EscapeLanguage.Xml),
                                  param[3] == "1");
                HostsDatabase.Save();
                EventCallbackSystem.InvokeCallback("HostsListUpdated", true);

                Logger.Log(LogType.Debug,
                           "Added domain {0} = {1}",
                           param[0].Unescape(EscapeLanguage.Xml),
                           param[1].Unescape(EscapeLanguage.Xml));
            }
        }
Example #7
0
        void OnAddDomain(UserClient client, string data)
        {
            var param = data.Split('/');

            if (param.Length == 4)
            {
                HostsDatabase.Add(false,
                                  param[0].Unescape(EscapeLanguage.Xml),
                                  param[1].Unescape(EscapeLanguage.Xml),
                                  param[2].Unescape(EscapeLanguage.Xml),
                                  param[3] == "1");
                HostsDatabase.Save();

                Logger.Log(
                    LogType.Debug,
                    "Added domain {0} = {1}",
                    param[0].Unescape(EscapeLanguage.Xml),
                    param[1].Unescape(EscapeLanguage.Xml));

                BroadcastPacket("add-domain {0}\n", data);
            }
        }
Example #8
0
        private void LvLocalHosts_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                e.Handled = true;
                LvLocalHosts_MouseDoubleClick(sender, null);
            }
            else if (e.KeyCode == Keys.Delete)
            {
                e.Handled = true;

                if (lvLocalHosts.SelectedItems.Count > 0)
                {
                    var str =
                        lvLocalHosts.SelectedItems.Count > 1 ?
                        "Are you sure you wish to delete " + lvLocalHosts.SelectedItems.Count + " local domains?\nThis action cannot be undone." :
                        "Are you sure you wish to delete this local domain?\nThis action cannot be undone.";

                    var res = MessageBox.Show(
                        str,
                        "Confirm remove local domain(s)",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Warning);

                    if (res == DialogResult.Yes)
                    {
                        foreach (ListViewItem lvi in lvLocalHosts.SelectedItems)
                        {
                            // remove manually
                            HostsDatabase.Remove(true, (lvi.Tag as HostEntry).Name);
                        }

                        HostsDatabase.Save();
                        EventCallbackSystem.InvokeCallback("HostsListUpdated", true);
                    }
                }
            }
        }
Example #9
0
        void OnEditDomain(UserClient client, string data)
        {
            var param = data.Split('/');

            if (param.Length == 4)
            {
                var added = !HostsDatabase.Remove(false, param[0].Unescape(EscapeLanguage.Xml));
                HostsDatabase.Add(false,
                                  param[0].Unescape(EscapeLanguage.Xml),
                                  param[1].Unescape(EscapeLanguage.Xml),
                                  param[2].Unescape(EscapeLanguage.Xml),
                                  param[3] == "1");
                HostsDatabase.Save();

                Logger.Log(
                    LogType.Debug,
                    "{0} domain {1} = {2}",
                    added ? "Added" : "Edited",
                    param[0].Unescape(EscapeLanguage.Xml),
                    param[1].Unescape(EscapeLanguage.Xml));

                BroadcastPacket("edit-domain {0}\n", data);
            }
        }