Beispiel #1
0
        public override void OnRecoveryLoad(XmlElement root)
        {
            XmlElement nodeDhcp = Utils.XmlGetFirstElementByTagName(root, "DhcpSwitch");

            if (nodeDhcp != null)
            {
                foreach (XmlElement nodeEntry in nodeDhcp.ChildNodes)
                {
                    NetworkManagerDhcpEntry entry = new NetworkManagerDhcpEntry();
                    entry.ReadXML(nodeEntry);
                    m_listOldDhcp.Add(entry);
                }
            }

            XmlElement nodeDns = Utils.XmlGetFirstElementByTagName(root, "DnsSwitch");

            if (nodeDns != null)
            {
                foreach (XmlElement nodeEntry in nodeDns.ChildNodes)
                {
                    NetworkManagerDnsEntry entry = new NetworkManagerDnsEntry();
                    entry.ReadXML(nodeEntry);
                    m_listOldDns.Add(entry);
                }
            }

            if (Utils.XmlExistsAttribute(root, "IpV6"))
            {
                m_oldIpV6 = Conversions.ToUInt32(Utils.XmlGetAttributeInt64(root, "IpV6", 0), 0);
            }

            SwitchToStaticRestore();

            base.OnRecoveryLoad(root);
        }
Beispiel #2
0
        public override void OnRecoveryLoad(XmlElement root)
        {
            XmlElement nodeDhcp = Utils.XmlGetFirstElementByTagName(root, "DhcpSwitch");

            if (nodeDhcp != null)
            {
                foreach (XmlElement nodeEntry in nodeDhcp.ChildNodes)
                {
                    NetworkManagerDhcpEntry entry = new NetworkManagerDhcpEntry();
                    entry.ReadXML(nodeEntry);
                    ListOldDhcp.Add(entry);
                }
            }

            XmlElement nodeDns = Utils.XmlGetFirstElementByTagName(root, "DnsSwitch");

            if (nodeDns != null)
            {
                foreach (XmlElement nodeEntry in nodeDns.ChildNodes)
                {
                    NetworkManagerDnsEntry entry = new NetworkManagerDnsEntry();
                    entry.ReadXML(nodeEntry);
                    ListOldDns.Add(entry);
                }
            }

            SwitchToStaticRestore();
            DnsForceRestore();
        }
Beispiel #3
0
        public override bool OnDnsSwitchDo(string dns)
        {
            string[] dnsArray = dns.Split(',');

            string mode = Engine.Instance.Storage.Get("dns.mode").ToLowerInvariant();

            if (mode == "auto")
            {
                try
                {
                    ManagementClass            objMC  = new ManagementClass("Win32_NetworkAdapterConfiguration");
                    ManagementObjectCollection objMOC = objMC.GetInstances();

                    foreach (ManagementObject objMO in objMOC)
                    {
                        /*
                         * if (!((bool)objMO["IPEnabled"]))
                         *      continue;
                         */
                        NetworkManagerDnsEntry entry = new NetworkManagerDnsEntry();

                        entry.Guid        = objMO["SettingID"] as string;
                        entry.Description = objMO["Description"] as string;
                        entry.Dns         = objMO["DNSServerSearchOrder"] as string[];

                        entry.AutoDns = ((Registry.GetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\" + entry.Guid, "NameServer", "") as string) == "");

                        if (entry.Dns == null)
                        {
                            continue;
                        }

                        Engine.Instance.Log(Engine.LogType.Info, Messages.Format(Messages.NetworkAdapterDnsDone, entry.Description));

                        ManagementBaseObject objSetDNSServerSearchOrder = objMO.GetMethodParameters("SetDNSServerSearchOrder");
                        //objSetDNSServerSearchOrder["DNSServerSearchOrder"] = null;
                        //objSetDNSServerSearchOrder["DNSServerSearchOrder"] = new string[] { Constants.DnsVpn };
                        objSetDNSServerSearchOrder["DNSServerSearchOrder"] = dnsArray;
                        ManagementBaseObject objSetDNSServerSearchOrderMethod = objMO.InvokeMethod("SetDNSServerSearchOrder", objSetDNSServerSearchOrder, null);

                        m_listOldDns.Add(entry);
                    }
                }
                catch (Exception e)
                {
                    Engine.Instance.Log(e);
                }

                Recovery.Save();
            }

            base.OnDnsSwitchDo(dns);

            return(true);
        }
Beispiel #4
0
        private bool DnsForceDo()
        {
            try
            {
                ManagementClass            objMC  = new ManagementClass("Win32_NetworkAdapterConfiguration");
                ManagementObjectCollection objMOC = objMC.GetInstances();

                foreach (ManagementObject objMO in objMOC)
                {
                    if (!((bool)objMO["IPEnabled"]))
                    {
                        continue;
                    }

                    NetworkManagerDnsEntry entry = new NetworkManagerDnsEntry();

                    entry.Guid        = objMO["SettingID"] as string;
                    entry.Description = objMO["Description"] as string;
                    entry.Dns         = objMO["DNSServerSearchOrder"] as string[];

                    entry.AutoDns = ((Registry.GetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\" + entry.Guid, "NameServer", "") as string) == "");

                    if (entry.Dns == null)
                    {
                        continue;
                    }

                    Engine.Instance.Log(Engine.LogType.Info, Messages.Format(Messages.NetworkAdapterDnsDone, entry.Description));

                    ManagementBaseObject objSetDNSServerSearchOrder = objMO.GetMethodParameters("SetDNSServerSearchOrder");
                    //objSetDNSServerSearchOrder["DNSServerSearchOrder"] = null;
                    objSetDNSServerSearchOrder["DNSServerSearchOrder"] = new string[] { Constants.DnsVpn };
                    ManagementBaseObject objSetDNSServerSearchOrderMethod = objMO.InvokeMethod("SetDNSServerSearchOrder", objSetDNSServerSearchOrder, null);

                    ListOldDns.Add(entry);
                }

                return(true);
            }
            catch (Exception e)
            {
                Engine.Instance.Log(e);
                return(false);
            }
        }
Beispiel #5
0
		public override void OnRecoveryLoad(XmlElement root)
		{
			XmlElement nodeDhcp = Utils.XmlGetFirstElementByTagName(root, "DhcpSwitch");
			if (nodeDhcp != null)
			{
				foreach (XmlElement nodeEntry in nodeDhcp.ChildNodes)
				{
					NetworkManagerDhcpEntry entry = new NetworkManagerDhcpEntry();
					entry.ReadXML(nodeEntry);
					m_listOldDhcp.Add(entry);
				}
			}

			XmlElement nodeDns = Utils.XmlGetFirstElementByTagName(root, "DnsSwitch");
			if (nodeDns != null)
			{
				foreach (XmlElement nodeEntry in nodeDns.ChildNodes)
				{
					NetworkManagerDnsEntry entry = new NetworkManagerDnsEntry();
					entry.ReadXML(nodeEntry);
					m_listOldDns.Add(entry);
				}
			}

			if (Utils.XmlExistsAttribute(root, "IpV6"))
			{
				m_oldIpV6 = Conversions.ToUInt32(Utils.XmlGetAttributeInt64(root, "IpV6", 0), 0);
			}

			SwitchToStaticRestore();

			base.OnRecoveryLoad(root);			
		}
Beispiel #6
0
		public override bool OnDnsSwitchDo(string dns)
		{
			string[] dnsArray = dns.Split(',');

			string mode = Engine.Instance.Storage.Get("dns.mode").ToLowerInvariant();

			if (mode == "auto")
			{
				try
				{
					ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration");
					ManagementObjectCollection objMOC = objMC.GetInstances();

					foreach (ManagementObject objMO in objMOC)
					{
						/*
						if (!((bool)objMO["IPEnabled"]))
							continue;
						*/
						NetworkManagerDnsEntry entry = new NetworkManagerDnsEntry();

						entry.Guid = objMO["SettingID"] as string;
						entry.Description = objMO["Description"] as string;
						entry.Dns = objMO["DNSServerSearchOrder"] as string[];

						entry.AutoDns = ((Registry.GetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\" + entry.Guid, "NameServer", "") as string) == "");

						if (entry.Dns == null)
							continue;

						Engine.Instance.Log(Engine.LogType.Info, Messages.Format(Messages.NetworkAdapterDnsDone, entry.Description));

						ManagementBaseObject objSetDNSServerSearchOrder = objMO.GetMethodParameters("SetDNSServerSearchOrder");
						//objSetDNSServerSearchOrder["DNSServerSearchOrder"] = null;
						//objSetDNSServerSearchOrder["DNSServerSearchOrder"] = new string[] { Constants.DnsVpn };
						objSetDNSServerSearchOrder["DNSServerSearchOrder"] = dnsArray;
						ManagementBaseObject objSetDNSServerSearchOrderMethod = objMO.InvokeMethod("SetDNSServerSearchOrder", objSetDNSServerSearchOrder, null);

						m_listOldDns.Add(entry);
					}
				}
				catch (Exception e)
				{
					Engine.Instance.Log(e);
				}

				Recovery.Save();				
			}

			base.OnDnsSwitchDo(dns);

			return true;
		}