コード例 #1
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);
        }
コード例 #2
0
        public override bool OnDnsSwitchDo(string dns)
        {
            string mode = Engine.Instance.Storage.GetLower("dns.mode");

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

                    string current = ShellCmd("networksetup -getdnsservers \"" + i2 + "\"");

                    // v2
                    List <string> ips = new List <string>();
                    foreach (string line in current.Split('\n'))
                    {
                        string ip = line.Trim();
                        if (IpAddress.IsIP(ip))
                        {
                            ips.Add(ip);
                        }
                    }

                    if (ips.Count != 0)
                    {
                        current = String.Join(",", ips.ToArray());
                    }
                    else
                    {
                        current = "";
                    }
                    if (current != dns)
                    {
                        // Switch
                        Engine.Instance.Logs.Log(LogType.Verbose, Messages.Format(Messages.NetworkAdapterDnsDone, i2, ((current == "") ? "Automatic" : current), dns));

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

                        string dns2 = dns.Replace(",", "\" \"");
                        ShellCmd("networksetup -setdnsservers \"" + i2 + "\" \"" + dns2 + "\"");
                    }
                }

                Recovery.Save();
            }

            base.OnDnsSwitchDo(dns);

            return(true);
        }
コード例 #3
0
ファイル: Osx.cs プロジェクト: Clodo76/airvpn-client
        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);
        }
コード例 #4
0
ファイル: Osx.cs プロジェクト: Clodo76/airvpn-client
        public override bool OnDnsSwitchDo(string dns)
        {
            string mode = Engine.Instance.Storage.GetLower("dns.mode");

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

                    string current = ShellCmd("networksetup -getdnsservers \"" + i2 + "\"");

                    // v2
                    List<string> ips = new List<string>();
                    foreach(string line in current.Split('\n'))
                    {
                        string ip = line.Trim();
                        if (IpAddress.IsIP(ip))
                            ips.Add(ip);
                    }

                    if (ips.Count != 0)
                        current = String.Join(",", ips.ToArray());
                    else
                        current = "";
                    if (current != dns)
                    {
                        // Switch
                        Engine.Instance.Logs.Log(LogType.Verbose, MessagesFormatter.Format(Messages.NetworkAdapterDnsDone, i2, ((current == "") ? "Automatic" : current), dns));

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

                        string dns2 = dns.Replace(",", "\" \"");
                        ShellCmd("networksetup -setdnsservers \"" + i2 + "\" \"" + dns2 + "\"");
                    }
                }

                Recovery.Save ();
            }

            base.OnDnsSwitchDo(dns);

            return true;
        }