Beispiel #1
0
        public override bool OnDnsSwitchDo(string dns)
        {
            string mode = Engine.Instance.Storage.Get("dns.mode").ToLowerInvariant();

            if (mode == "auto")
            {
                string[] interfaces = GetInterfaces();
                foreach (string i in interfaces)
                {
                    string i2 = i.Trim();

                    string current = ShellCmd("networksetup -getdnsservers \"" + i2 + "\"");
                    current = current.Replace("\n", ";");
                    if (current.StartsWith("There aren't any DNS Servers set on "))
                    {
                        current = "0.0.0.0";
                    }
                    if (Utils.IsIP(current))
                    {
                        if (current != dns)
                        {
                            // Switch
                            Engine.Instance.Log(Engine.LogType.Info, Messages.Format(Messages.NetworkAdapterDnsDone, i2));

                            DnsSwitchEntry e = new DnsSwitchEntry();
                            e.Name = i2;
                            e.Dns  = current;
                            m_listDnsSwitch.Add(e);

                            string dns2 = dns.Replace(",", "\" \"");
                            ShellCmd("networksetup -setdnsservers \"" + i2 + "\" \"" + dns2 + "\"");
                        }
                    }
                    else
                    {
                        Engine.Instance.Log(Engine.LogType.Verbose, "Unknown networksetup output: '" + current + "' for interface '" + i + "'");
                    }
                }

                Recovery.Save();
            }

            base.OnDnsSwitchDo(dns);

            return(true);
        }
Beispiel #2
0
		public override bool OnDnsSwitchDo(string dns)
		{
			string mode = Engine.Instance.Storage.Get("dns.mode").ToLowerInvariant();

			if (mode == "auto")
			{
				string[] interfaces = GetInterfaces();
				foreach (string i in interfaces)
				{
					string i2 = i.Trim();
					
					string current = ShellCmd("networksetup -getdnsservers \"" + i2 + "\"");
					current = current.Replace ("\n", ";");
					if (current.StartsWith("There aren't any DNS Servers set on "))
						current = "0.0.0.0";
					if (Utils.IsIP(current))
					{
						if (current != dns)
						{
							// Switch
							Engine.Instance.Log(Engine.LogType.Info, Messages.Format(Messages.NetworkAdapterDnsDone, i2));

							DnsSwitchEntry e = new DnsSwitchEntry();
							e.Name = i2;
							e.Dns = current;
							m_listDnsSwitch.Add(e);

							string dns2 = dns.Replace(",", "\" \"");							
							ShellCmd("networksetup -setdnsservers \"" + i2 + "\" \"" + dns2 + "\"");
						}
					}
					else
					{
						Engine.Instance.Log(Engine.LogType.Verbose, "Unknown networksetup output: '" + current + "' for interface '" + i + "'");
					}
				}

				Recovery.Save ();
			}

			base.OnDnsSwitchDo(dns);

			return true;
		}
Beispiel #3
0
		public override void OnRecoveryLoad(XmlElement root)
		{
			XmlElement nodeDns = Utils.XmlGetFirstElementByTagName(root, "DnsSwitch");
			if (nodeDns != null)
			{
				foreach (XmlElement nodeEntry in nodeDns.ChildNodes)
				{
					DnsSwitchEntry entry = new DnsSwitchEntry();
					entry.ReadXML(nodeEntry);
					m_listDnsSwitch.Add(entry);
				}
			}

			XmlElement nodeIpV6 = Utils.XmlGetFirstElementByTagName(root, "IpV6");
			if (nodeIpV6 != null)
			{
				foreach (XmlElement nodeEntry in nodeIpV6.ChildNodes)
				{
					IpV6ModeEntry entry = new IpV6ModeEntry();
					entry.ReadXML(nodeEntry);
					m_listIpV6Mode.Add(entry);
				}
			}

			base.OnRecoveryLoad(root);
		}