Пример #1
0
        public override void Deactivation()
        {
            base.Deactivation();

            // IPv4
            string rulesBackupSessionV4 = GetBackupPath("4");

            if (Platform.Instance.FileExists(rulesBackupSessionV4))
            {
                /* // Removed in 2.17 // TOCLEAN
                 * // Flush
                 * DoIptablesShell("iptables", "-P INPUT ACCEPT");
                 * DoIptablesShell("iptables", "-P FORWARD ACCEPT");
                 * DoIptablesShell("iptables", "-P OUTPUT ACCEPT");
                 * DoIptablesShell("iptables", "-t nat -F", false);
                 * DoIptablesShell("iptables", "-t mangle -F", false);
                 * DoIptablesShell("iptables", "-F");
                 * DoIptablesShell("iptables", "-X");
                 */

                // Restore backup - Exception: ShellCmd because ip6tables-restore accept only stdin
                SystemShell.ShellCmd(Platform.Instance.LocateExecutable("iptables-restore") + " <\"" + SystemShell.EscapePath(rulesBackupSessionV4) + "\"");

                Platform.Instance.FileDelete(rulesBackupSessionV4);
            }

            // IPv6
            string rulesBackupSessionV6 = GetBackupPath("6");

            if (Platform.Instance.FileExists(rulesBackupSessionV6))
            {
                /* // Removed in 2.17 // TOCLEAN
                 * // Flush
                 * DoIptablesShell("ip6tables", "-P INPUT ACCEPT");
                 * DoIptablesShell("ip6tables", "-P FORWARD ACCEPT");
                 * DoIptablesShell("ip6tables", "-P OUTPUT ACCEPT");
                 * DoIptablesShell("ip6tables", "-t nat -F", false);
                 * DoIptablesShell("ip6tables", "-t mangle -F", false);
                 * DoIptablesShell("ip6tables", "-F");
                 * DoIptablesShell("ip6tables", "-X");
                 */

                // Restore backup - Exception: ShellCmd because ip6tables-restore accept only stdin
                SystemShell.ShellCmd(Platform.Instance.LocateExecutable("ip6tables-restore") + " <\"" + SystemShell.EscapePath(rulesBackupSessionV6) + "\"");

                Platform.Instance.FileDelete(rulesBackupSessionV6);
            }

            // IPS
            m_ipsWhiteListOutgoing.Clear();
        }
Пример #2
0
        public override void Deactivation()
        {
            base.Deactivation();

            string result = Engine.Instance.Elevated.DoCommandSync("netlock-iptables-deactivate");

            if (result != "")
            {
                throw new Exception("Unexpected result: " + result);
            }

            // IPS
            m_ipsWhiteListIncoming.Clear();
            m_ipsWhiteListOutgoing.Clear();
        }
Пример #3
0
        private void ParseXML(XDocument pollXml)
        {
            Answers.Clear();
            IpAddresses.Clear();

            Question = pollXml.Element("poll").Element("question").Attribute("text").Value;
            foreach (var answer in pollXml.Element("poll").Elements("answer"))
            {
                Answers.Add(new AnswerItem(answer.Attribute("text").Value, int.Parse(answer.Value)));
            }
            foreach (var ipaddr in pollXml.Element("poll").Elements("ipaddr"))
            {
                IpAddresses.Add(new IpAddressItem(ipaddr.Value,
                                                  DateTime.ParseExact(ipaddr.Attribute("dateEntered").Value,
                                                                      "yyyy/MM/dd HH:mm",
                                                                      CultureInfo.InvariantCulture)));
            }
        }
Пример #4
0
        public override void Deactivation()
        {
            base.Deactivation();

            foreach (NetworkLockWindowsFirewallProfile profile in Profiles)
            {
                profile.RestorePolicy();
            }

            // Not need, already restored in after import
            // Exec("netsh advfirewall firewall delete rule name=\"Eddie - In - AllowLocal\"");
            // Exec("netsh advfirewall firewall delete rule name=\"Eddie - Out - AllowLocal\"");
            // Exec("netsh advfirewall firewall delete rule name=\"Eddie - Out - AllowVPN\"");
            // Exec("netsh advfirewall firewall delete rule name=\"Eddie - Out - AllowAirIPS\"");
            // Exec("netsh advfirewall firewall delete rule name=\"Eddie - Out - DHCP\"");

            // >2.9.1 edition
            {
                string rulesBackupSession = Engine.Instance.GetPathInData("winfirewall_rules_backup.wfw");
                if (Platform.Instance.FileExists(rulesBackupSession))
                {
                    NetShAdvFirewall("import \"" + SystemShell.EscapePath(rulesBackupSession) + "\"");
                    Platform.Instance.FileDelete(rulesBackupSession);
                }
            }

            // Old <2.8 edition
            {
                string rulesBackupSession = Engine.Instance.GetPathInData("winfirewallrules.wfw");
                if (Platform.Instance.FileExists(rulesBackupSession))
                {
                    NetShAdvFirewall("import \"" + SystemShell.EscapePath(rulesBackupSession) + "\"");
                    Platform.Instance.FileDelete(rulesBackupSession);
                }
            }

            // Old 2.9.0 edition, recover
            {
                string rulesBackupSession = Environment.SystemDirectory + Platform.Instance.DirSep + "winfirewall_rules_original.airvpn";
                if (Platform.Instance.FileExists(rulesBackupSession))
                {
                    NetShAdvFirewall("import \"" + SystemShell.EscapePath(rulesBackupSession) + "\"");
                    Platform.Instance.FileDelete(rulesBackupSession);
                }
            }

            foreach (NetworkLockWindowsFirewallProfile profile in Profiles)
            {
                if (profile.State == false)
                {
                    profile.StateOff();
                }
                // <2.11 Not need, already restored in below import
                // >=2.11 Restored, otherwise are not correctly restored in nt-domain environment.
                if (profile.Notifications == true)
                {
                    profile.NotifyOn();
                }
            }

            // Service
            if (m_serviceStatus == false)
            {
                ServiceController service = null;
                try
                {
                    service = new ServiceController("MpsSvc");
                    TimeSpan timeout = TimeSpan.FromMilliseconds(30000);
                    service.Stop();
                    service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
                }
                finally
                {
                    if (service != null)
                    {
                        service.Dispose();
                    }
                }
            }

            m_lastestIpsWhiteListOutgoing.Clear();
        }