Esempio n. 1
0
        public FirewallLogList()
        {
            InitializeComponent();

            //this.grpLog.Header = Translate.fmt("gtp_con_log");

            /*this.grpLogTools.Header = Translate.fmt("grp_tools");
             * this.grpLogView.Header = Translate.fmt("grp_view");
             *
             * this.btnMkRule.Content = Translate.fmt("btn_mk_rule");
             * this.btnClearLog.Content = Translate.fmt("btn_clear_log");
             * this.lblShowCons.Content = Translate.fmt("lbl_show_cons");
             * this.chkNoLocal.Content = Translate.fmt("chk_hide_local");
             * this.chkNoLAN.Content = Translate.fmt("chk_hide_lan");
             * this.lblFilterCons.Content = Translate.fmt("lbl_filter_cons");*/

            this.txtConFilter.LabelText = Translate.fmt("lbl_text_filter");
            this.cmbAll.Content         = Translate.fmt("str_all_events");
            this.cmbAllow.Content       = Translate.fmt("str_allowed");
            this.cmbBlock.Content       = Translate.fmt("str_blocked");
            this.chkNoINet.ToolTip      = Translate.fmt("str_no_inet");
            this.chkNoLAN.ToolTip       = Translate.fmt("str_no_lan");
            this.chkNoMulti.ToolTip     = Translate.fmt("str_no_multi");
            this.chkNoLocal.ToolTip     = Translate.fmt("str_no_local");

            WpfFunc.CmbAdd(sockType, Translate.fmt("filter_protocols_any"), FirewallPage.FilterPreset.Socket.Any);
            WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_web"), FirewallPage.FilterPreset.Socket.Web).Background       = new SolidColorBrush(Colors.DodgerBlue);
            WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_tcp"), FirewallPage.FilterPreset.Socket.TCP).Background       = new SolidColorBrush(Colors.Turquoise);
            WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_client"), FirewallPage.FilterPreset.Socket.Client).Background = new SolidColorBrush(Colors.Gold);
            WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_server"), FirewallPage.FilterPreset.Socket.Server).Background = new SolidColorBrush(Colors.DarkOrange);
            WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_udp"), FirewallPage.FilterPreset.Socket.UDP).Background       = new SolidColorBrush(Colors.Violet);
            WpfFunc.CmbAdd(sockType, Translate.fmt("filter_protocols_other"), FirewallPage.FilterPreset.Socket.Other).Background = new SolidColorBrush(Colors.LightGray);

            int i = 0;

            this.logGrid.Columns[++i].Header = Translate.fmt("lbl_name");
            this.logGrid.Columns[++i].Header = Translate.fmt("lbl_time_stamp");
            this.logGrid.Columns[++i].Header = Translate.fmt("lbl_action");
            this.logGrid.Columns[++i].Header = Translate.fmt("lbl_direction");
            this.logGrid.Columns[++i].Header = Translate.fmt("lbl_protocol");
            this.logGrid.Columns[++i].Header = Translate.fmt("lbl_remote_ip");
            this.logGrid.Columns[++i].Header = Translate.fmt("lbl_remote_port");
            this.logGrid.Columns[++i].Header = Translate.fmt("lbl_local_ip");
            this.logGrid.Columns[++i].Header = Translate.fmt("lbl_local_port");
            this.logGrid.Columns[++i].Header = Translate.fmt("lbl_program");

            LogList             = new ObservableCollection <LogItem>();
            logGrid.ItemsSource = LogList;

            logGridExt = new DataGridExt(logGrid);
            logGridExt.Restore(App.GetConfig("FwLog", "Columns", ""));


            UwpFunc.AddBinding(logGrid, new KeyGesture(Key.F, ModifierKeys.Control), (s, e) => { this.txtConFilter.Focus(); });

            try
            {
                textFilter                = App.GetConfig("FwLog", "Filter", "");
                txtConFilter.Text         = textFilter;
                cmbConTypes.SelectedIndex = App.GetConfigInt("FwLog", "Events", 0);

                WpfFunc.CmbSelect(sockType, ((FirewallPage.FilterPreset.Socket)App.GetConfigInt("FwLog", "Types", 0)).ToString());

                //this.chkAllowed.IsChecked = App.GetConfigInt("FwLog", "ShowAllowed", 1) == 1;
                //this.chkBlocked.IsChecked = App.GetConfigInt("FwLog", "ShowBlocked", 1) == 1;
                this.chkNoLocal.IsChecked = App.GetConfigInt("FwLog", "NoLocal", 0) == 1;
                this.chkNoMulti.IsChecked = App.GetConfigInt("FwLog", "NoMulti", 0) == 1;
                this.chkNoLAN.IsChecked   = App.GetConfigInt("FwLog", "NoLan", 0) == 1;
                this.chkNoINet.IsChecked  = App.GetConfigInt("FwLog", "NoINet", 0) == 1;
            }
            catch { }

            //mConLimit = App.engine.programs.MaxLogLength * 10; // todo
            logLimit = App.GetConfigInt("GUI", "LogLimit", 1000);

            CheckLogLines();
        }
Esempio n. 2
0
        public void HideWnd()
        {
            WpfFunc.StoreWnd(this, "Notify");

            Hide();
        }
Esempio n. 3
0
        public MainWindow()
        {
            InitializeComponent();

            //if (!MiscFunc.IsRunningAsUwp())
            this.Title = string.Format("{0} v{1} by David Xanatos", App.mName, App.mVersion);
            if (!App.lic.CommercialUse)
            {
                this.Title += " - for Private non Commercial Use";
            }

            WpfFunc.LoadWnd(this, "Main");

            mPages.Add("Overview", new OverviewPage());
            mPages.Add("Privacy", new PrivacyPage());
            if (App.client.IsConnected())
            {
                mPages.Add("Firewall", new FirewallPage());
            }
            else
            {
                mPages.Add("Firewall", null);
            }
            //mPages.Add("VPN", new VPNPage());
            mPages.Add("Settings", new SettingsPage());
            mPages.Add("About", new AboutPage());

            foreach (UserControl page in mPages.Values)
            {
                if (page == null)
                {
                    continue;
                }
                page.Visibility = Visibility.Collapsed;
                this.Main.Children.Add(page);
            }

            Brush brushOn  = (TryFindResource("SidePanel.on") as Brush);
            Brush brushOff = (TryFindResource("SidePanel.off") as Brush);

            foreach (string name in mPages.Keys)
            {
                /*TabItem item = new TabItem();
                 * item.KeyDown += SidePanel_Click;
                 * item.MouseLeftButtonUp += SidePanel_Click;
                 * item.Name = "PanelItem_" + name;
                 * item.Style = (TryFindResource("SidePanelItem") as Style);
                 *
                 * StackPanel panel = new StackPanel();
                 *
                 * Image image = new Image();
                 * image.Width = 32;
                 * image.Height = 32;
                 * image.Name = "PanelItem_" + name + "_Image";
                 *
                 * panel.Children.Add(image);
                 * item.Content = panel;
                 * this.SidePanel.Items.Add(item);*/

                Geometry geometry = (TryFindResource("Icon_" + name) as Geometry);
                Image    image    = (FindName("PanelItem_" + name + "_Image") as Image);
                image.Tag = new Tuple <DrawingImage, DrawingImage>(new DrawingImage(new GeometryDrawing(brushOn, null, geometry)), new DrawingImage(new GeometryDrawing(brushOff, null, geometry)));
            }

            SwitchPage(App.GetConfig("GUI", "CurPage", "Overview"));
        }
Esempio n. 4
0
        private void UpdatePorts()
        {
            cmbRemotePorts.Items.Clear();
            cmbLocalPorts.Items.Clear();

            if (curProtocol == (int)FirewallRule.KnownProtocols.TCP || curProtocol == (int)FirewallRule.KnownProtocols.UDP)
            {
                cmbRemotePorts.Items.Add(new ContentControl()
                {
                    Content = Translate.fmt("port_any"), Tag = "*"
                });
                cmbLocalPorts.Items.Add(new ContentControl()
                {
                    Content = Translate.fmt("port_any"), Tag = "*"
                });

                if (Rule.Direction == FirewallRule.Directions.Outbound)
                {
                    if (curProtocol == (int)FirewallRule.KnownProtocols.TCP)
                    {
                        cmbRemotePorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordIpTlsOut, Tag = FirewallRule.PortKeywordIpTlsOut
                        });
                    }
                }
                else if (Rule.Direction == FirewallRule.Directions.Inbound)
                {
                    if (curProtocol == (int)FirewallRule.KnownProtocols.TCP)
                    {
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordIpTlsIn, Tag = FirewallRule.PortKeywordIpTlsIn
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordRpcEp, Tag = FirewallRule.PortKeywordRpcEp
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordRpc, Tag = FirewallRule.PortKeywordRpc
                        });
                    }
                    else if (curProtocol == (int)FirewallRule.KnownProtocols.UDP)
                    {
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordTeredo, Tag = FirewallRule.PortKeywordTeredo
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordPly2Disc, Tag = FirewallRule.PortKeywordPly2Disc
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordMDns, Tag = FirewallRule.PortKeywordMDns
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordDhcp, Tag = FirewallRule.PortKeywordDhcp
                        });
                    }
                }

                //if (!WpfFunc.CmbSelect(cmbRemotePorts, Rule.RemotePorts) && Rule.RemotePorts != null)
                //    cmbRemotePorts.Text = Rule.RemotePorts;
                viewModel.RemotePort = WpfFunc.CmbPick(cmbRemotePorts, FirewallRule.IsEmptyOrStar(Rule.RemotePorts) ? "*" : Rule.RemotePorts);
                if (viewModel.RemotePort == null)
                {
                    viewModel.RemotePortTxt = Rule.RemotePorts;
                }

                //if (!WpfFunc.CmbSelect(cmbLocalPorts, Rule.LocalPorts) && Rule.LocalPorts != null)
                //    cmbLocalPorts.Text = Rule.LocalPorts;
                viewModel.LocalPort = WpfFunc.CmbPick(cmbLocalPorts, FirewallRule.IsEmptyOrStar(Rule.LocalPorts) ? "*" : Rule.LocalPorts);
                if (viewModel.LocalPort == null)
                {
                    viewModel.LocalPortTxt = Rule.LocalPorts;
                }
            }
        }
Esempio n. 5
0
        private void LoadCurrent(bool bUpdate = false)
        {
            if (!bUpdate)
            {
                ProgramSet.Config.AccessLevels NetAccess = ProgramSet.Config.AccessLevels.Unconfigured;

                cmbAccess.Background = ProgramControl.GetAccessColor(NetAccess);
                WpfFunc.CmbSelect(cmbAccess, NetAccess.ToString());

                btnApply.IsEnabled = false;
            }

            ProgramID id = mEventList.ElementAt(curIndex);
            Tuple <Program, List <Priv10Engine.FwEventArgs> > list = mEvents[id];

            //int PID = list.Item2.Count > 0 ? list.Item2.First().FwEvent.ProcessId : 0;
            string FilePath = list.Item2.Count > 0 ? list.Item2.First().entry.FwEvent.ProcessFileName : "";

            imgIcon.Source = ImgFunc.GetIcon(FilePath, imgIcon.Width); // todo: use .progSet.GetIcon instead?
            //lblName.Text = id.GetDisplayName(false);
            grpBox.Header = list.Item1.Description;
            //lblPID.Text = string.Format("{0} ({1})", System.IO.Path.GetFileName(id.Path), PID);
            lblPID.Text = System.IO.Path.GetFileName(id.Path);

            List <string> services = new List <string>();

            btnIgnore.IsEnabled = true;
            consGrid.Items.Clear();
            foreach (Priv10Engine.FwEventArgs args in list.Item2)
            {
                consGrid.Items.Insert(0, new ConEntry(args.entry));

                if (args.services != null)
                {
                    foreach (var service in args.services)
                    {
                        if (!services.Contains(service))
                        {
                            services.Add(service);
                        }
                    }
                }
            }

            if (services.Count > 0)
            {
                cmbService.Visibility = Visibility.Visible;
                cmbService.Items.Clear();
                foreach (var service in services)
                {
                    cmbService.Items.Add(service);
                }
                cmbService.SelectedIndex = -1;
                cmbService.Text          = Translate.fmt("msg_pick_svc");
            }
            else
            {
                cmbService.Visibility = Visibility.Collapsed;
                switch (id.Type)
                {
                //case ProgramList.Types.Program: lblSubName.Text = ""; break;
                case ProgramID.Types.Service: lblSubName.Text = id.GetServiceId(); break;

                case ProgramID.Types.App: lblSubName.Text = id.GetPackageName(); break;

                default: lblSubName.Text = ""; break;
                }
            }
            lblPath.Text = id.Path;
        }
Esempio n. 6
0
        private void CheckRules()
        {
            int SelectedCount = 0;
            int EnabledCount  = 0;
            int DisabledCount = 0;
            int AllowingCount = 0;
            int BlockingCount = 0;
            int ChangedCount  = 0;
            int ChangedWBack  = 0;

            foreach (RuleItem item in rulesGrid.SelectedItems)
            {
                SelectedCount++;
                if (item.Rule.Enabled)
                {
                    EnabledCount++;
                }
                else
                {
                    DisabledCount++;
                }
                if (item.Rule.Action == FirewallRule.Actions.Allow)
                {
                    AllowingCount++;
                }
                if (item.Rule.Action == FirewallRule.Actions.Block)
                {
                    BlockingCount++;
                }

                if (item.Rule.State != FirewallRuleEx.States.Approved)
                {
                    ChangedCount++;
                    if (item.Rule.Backup != null)
                    {
                        ChangedWBack++;
                    }
                }
            }

            menuEnableRule.IsEnabled  = DisabledCount >= 1;
            menuDisableRule.IsEnabled = EnabledCount >= 1;
            menuRemoveRule.IsEnabled  = SelectedCount >= 1;
            menuBlockRule.IsEnabled   = AllowingCount >= 1;
            menuAllowRule.IsEnabled   = BlockingCount >= 1;
            menuEditRule.IsEnabled    = SelectedCount == 1;
            menuCloneRule.IsEnabled   = SelectedCount >= 1;
            menuApproveRule.IsEnabled = ChangedCount >= 1;
            menuRestoreRule.IsEnabled = ChangedCount >= 1;
            menuRedoRule.IsEnabled    = ChangedWBack >= 1;

            if (firewallPage == null)
            {
                return;
            }
            firewallPage.btnEnableRule.IsEnabled  = DisabledCount >= 1;
            firewallPage.btnDisableRule.IsEnabled = EnabledCount >= 1;
            firewallPage.btnRemoveRule.IsEnabled  = SelectedCount >= 1;
            firewallPage.btnBlockRule.IsEnabled   = AllowingCount >= 1;
            firewallPage.btnAllowRule.IsEnabled   = BlockingCount >= 1;
            firewallPage.btnEditRule.IsEnabled    = SelectedCount == 1;
            firewallPage.btnCloneRule.IsEnabled   = SelectedCount >= 1;

            var btnApprove = WpfFunc.FindChild <RibbonButton>(firewallPage.btnApprove);
            var btnRestore = WpfFunc.FindChild <RibbonButton>(firewallPage.btnRestore);
            var btnApply   = WpfFunc.FindChild <RibbonButton>(firewallPage.btnApply);

            if (btnApprove != null && btnRestore != null && btnApply != null)
            {
                btnRestore.IsEnabled = btnApprove.IsEnabled = ChangedCount >= 1;
                btnApply.IsEnabled   = ChangedWBack >= 1;
            }
        }
Esempio n. 7
0
        private void UpdatePorts()
        {
            cmbRemotePorts.Items.Clear();
            cmbLocalPorts.Items.Clear();

            if (curProtocol == (int)FirewallRule.KnownProtocols.TCP || curProtocol == (int)FirewallRule.KnownProtocols.UDP)
            {
                cmbRemotePorts.Items.Add(new ContentControl()
                {
                    Content = Translate.fmt("port_any"), Tag = "*"
                });
                cmbLocalPorts.Items.Add(new ContentControl()
                {
                    Content = Translate.fmt("port_any"), Tag = "*"
                });

                if (Rule.Direction == Firewall.Directions.Outboun)
                {
                    if (curProtocol == (int)FirewallRule.KnownProtocols.TCP)
                    {
                        cmbRemotePorts.Items.Add(new ContentControl()
                        {
                            Content = "IPHTTPS", Tag = "IPHTTPS"
                        });
                    }
                }
                else if (Rule.Direction == Firewall.Directions.Inbound)
                {
                    if (curProtocol == (int)FirewallRule.KnownProtocols.TCP)
                    {
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = "IPHTTPS", Tag = "IPHTTPS"
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = "RPC-EPMap", Tag = "RPC-EPMap"
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = "RPC", Tag = "RPC"
                        });
                    }
                    else if (curProtocol == (int)FirewallRule.KnownProtocols.UDP)
                    {
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = "Teredo", Tag = "Teredo"
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = "Ply2Disc", Tag = "Ply2Disc"
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = "mDNS", Tag = "mDNS"
                        });
                    }
                }

                //if (!WpfFunc.CmbSelect(cmbRemotePorts, Rule.RemotePorts) && Rule.RemotePorts != null)
                //    cmbRemotePorts.Text = Rule.RemotePorts;
                viewModel.RemotePort = WpfFunc.CmbPick(cmbRemotePorts, Rule.RemotePorts == null ? "*" : Rule.RemotePorts);
                if (viewModel.RemotePort == null)
                {
                    viewModel.RemotePortTxt = Rule.RemotePorts;
                }

                //if (!WpfFunc.CmbSelect(cmbLocalPorts, Rule.LocalPorts) && Rule.LocalPorts != null)
                //    cmbLocalPorts.Text = Rule.LocalPorts;
                viewModel.LocalPort = WpfFunc.CmbPick(cmbLocalPorts, Rule.LocalPorts == null ? "*" : Rule.LocalPorts);
                if (viewModel.LocalPort == null)
                {
                    viewModel.LocalPortTxt = Rule.LocalPorts;
                }
            }
        }
Esempio n. 8
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     WpfFunc.StoreWnd(this, "Notify");
     App.SetConfig("GUI", "consGrid_Columns", consGridExt.Save());
 }
Esempio n. 9
0
        public NotificationWnd()
        {
            InitializeComponent();

            this.Title                      = Translate.fmt("wnd_notify");
            this.btnPrev.Content            = Translate.fmt("lbl_prev");
            this.btnNext.Content            = Translate.fmt("lbl_next");
            this.lblRemember.Content        = Translate.fmt("lbl_remember");
            this.btnIgnore.Content          = Translate.fmt("lbl_ignore");
            this.btnApply.Content           = Translate.fmt("lbl_apply");
            this.consGrid.Columns[0].Header = Translate.fmt("lbl_protocol");
            this.consGrid.Columns[1].Header = Translate.fmt("lbl_ip_port");
            this.consGrid.Columns[2].Header = Translate.fmt("lbl_remote_host");
            this.consGrid.Columns[3].Header = Translate.fmt("lbl_time_stamp");
            this.consGrid.Columns[4].Header = Translate.fmt("lbl_pid");

            consGridExt = new DataGridExt(consGrid);
            consGridExt.Restore(App.GetConfig("GUI", "consGrid_Columns", ""));

            this.Topmost = true;

            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_none"), Tag = ProgramSet.Config.AccessLevels.Unconfigured
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_silence"), Tag = ProgramSet.Config.AccessLevels.StopNotify
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_allow"), Tag = ProgramSet.Config.AccessLevels.FullAccess
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_edit"), Tag = ProgramSet.Config.AccessLevels.CustomConfig
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_lan"), Tag = ProgramSet.Config.AccessLevels.LocalOnly
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_block"), Tag = ProgramSet.Config.AccessLevels.BlockAccess
            });
            foreach (ComboBoxItem item in cmbAccess.Items)
            {
                item.Background = ProgramControl.GetAccessColor((ProgramSet.Config.AccessLevels)item.Tag);
            }

#if DEBUG
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "1 min"), Tag = 60
            });
#endif
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "5 min"), Tag = 5 * 60
            });
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "15 min"), Tag = 15 * 60
            });
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "1 h"), Tag = 60 * 60
            });
            cmbRemember.SelectedIndex = cmbRemember.Items.Count - 1; // default is 1h
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "24 h"), Tag = 24 * 60 * 60
            });
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_permanent"), Tag = 0
            });

            if (!WpfFunc.LoadWnd(this, "Notify"))
            {
                this.Left = SystemParameters.WorkArea.Width - this.Width - 4.0;
                this.Top  = SystemParameters.WorkArea.Height - this.Height - 4.0;
            }
        }
Esempio n. 10
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     WpfFunc.StoreWnd(this, "Notify");
 }
Esempio n. 11
0
        public NotificationWnd()
        {
            InitializeComponent();

            this.Title                      = Translate.fmt("wnd_notify");
            this.btnPrev.Content            = Translate.fmt("lbl_prev");
            this.btnNext.Content            = Translate.fmt("lbl_next");
            this.lblRemember.Content        = Translate.fmt("lbl_remember");
            this.btnIgnore.Content          = Translate.fmt("lbl_ignore");
            this.btnApply.Content           = Translate.fmt("lbl_apply");
            this.consGrid.Columns[0].Header = Translate.fmt("lbl_protocol");
            this.consGrid.Columns[1].Header = Translate.fmt("lbl_ip_port");
            this.consGrid.Columns[2].Header = Translate.fmt("lbl_time_stamp");

            this.Topmost = true;

            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_none"), Tag = Program.Config.AccessLevels.Unconfigured
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_silence"), Tag = Program.Config.AccessLevels.StopNotify
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_allow"), Tag = Program.Config.AccessLevels.FullAccess
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_edit"), Tag = Program.Config.AccessLevels.CustomConfig
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_lan"), Tag = Program.Config.AccessLevels.LocalOnly
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_block"), Tag = Program.Config.AccessLevels.BlockAccess
            });
            foreach (ComboBoxItem item in cmbAccess.Items)
            {
                item.Background = ProgramControl.GetAccessColor((Program.Config.AccessLevels)item.Tag);
            }

            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_permanent"), Tag = 0
            });
#if DEBUG
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "1 min"), Tag = 60
            });
#endif
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "5 min"), Tag = 5 * 60
            });
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "15 min"), Tag = 15 * 60
            });
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "1 h"), Tag = 60 * 60
            });
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "24 h"), Tag = 24 * 60 * 60
            });
            cmbRemember.SelectedIndex = 0;

            WpfFunc.LoadWnd(this, "Notify");
        }
Esempio n. 12
0
        public void DoUpdate(ProgramSet progSet)
        {
            this.progSet = progSet;

            SuspendChange++;

            string iconStr = progSet.GetIcon();

            if (ImgFunc.IsImageFileName(iconStr))
            {
                iconBG.Background = new SolidColorBrush(Colors.DodgerBlue);
            }

            ImgFunc.GetIconAsync(iconStr, iconBG.Width, (ImageSource src) => {
                if (Application.Current != null)
                {
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        icon.Source = src;
                    }));
                }
                return(0);
            });

            //name.Content = process.Name;
            if (name.IsReadOnly)
            {
                name.Text = progSet.config.Name;
            }

            var Presets = App.presets.GetProgPins(progSet.guid);

            chkPin.IsChecked = Presets.Count > 0;
            chkPin.ToolTip   = string.Join("\r\n", Presets);

            int    blockedConnections = 0;
            int    allowedConnections = 0;
            int    socketCount        = 0;
            UInt64 uploadRate         = 0;
            UInt64 downloadRate       = 0;

            foreach (Program prog in progSet.Programs.Values)
            {
                blockedConnections += prog.BlockedCount;
                allowedConnections += prog.AllowedCount;

                socketCount += prog.SocketCount;

                uploadRate   += prog.UploadRate;
                downloadRate += prog.DownloadRate;
            }
            info.Content = Translate.fmt("lbl_prog_info", blockedConnections, allowedConnections, socketCount,
                                         FileOps.FormatSize((decimal)uploadRate), FileOps.FormatSize((decimal)downloadRate));

            WpfFunc.CmbSelect(category, progSet.config.Category == null ? "" : progSet.config.Category);

            WpfFunc.CmbSelect(cmbAccess, progSet.config.GetAccess().ToString());
            if (progSet.config.NetAccess != ProgramConfig.AccessLevels.Unconfigured && progSet.config.NetAccess != progSet.config.CurAccess)
            {
                cmbAccess.Background /*grid.Background*/ = FindResource("Stripes") as DrawingBrush;
            }
            else
            {
                cmbAccess.Background = GetAccessColor(progSet.config.GetAccess());
            }

            chkNotify.IsChecked = progSet.config.GetNotify();

            progGrid.Items.Clear();

            foreach (Program prog in progSet.Programs.Values)
            {
                progGrid.Items.Insert(0, new ProgEntry(prog));
            }

            btnSplit.IsEnabled = progSet.Programs.Count > 1;
            SuspendChange--;
        }
Esempio n. 13
0
        public void DoUpdate()
        {
            SuspendChange++;

            ImgFunc.GetIconAsync(progSet.GetIcon(), icon.Width, (ImageSource src) => {
                if (Application.Current != null)
                {
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        icon.Source = src;
                    }));
                }
                return(0);
            });

            //name.Content = process.Name;
            name.Text = progSet.config.Name;

            int    blockedConnections = 0;
            int    allowedConnections = 0;
            int    socketCount        = 0;
            UInt64 uploadRate         = 0;
            UInt64 downloadRate       = 0;

            foreach (Program prog in progSet.Programs.Values)
            {
                blockedConnections += prog.BlockedCount;
                allowedConnections += prog.AllowedCount;

                socketCount += prog.SocketCount;

                uploadRate   += prog.UploadRate;
                downloadRate += prog.DownloadRate;
            }
            info.Content = Translate.fmt("lbl_prog_info", blockedConnections, allowedConnections, socketCount,
                                         FileOps.FormatSize((decimal)uploadRate), FileOps.FormatSize((decimal)downloadRate));

            WpfFunc.CmbSelect(category, progSet.config.Category == null ? "" : progSet.config.Category);

            WpfFunc.CmbSelect(cmbAccess, progSet.config.GetAccess().ToString());
            if (progSet.config.NetAccess != ProgramSet.Config.AccessLevels.Unconfigured && progSet.config.NetAccess != progSet.config.CurAccess)
            {
                cmbAccess.Background /*grid.Background*/ = FindResource("Stripes") as DrawingBrush;
            }
            else
            {
                cmbAccess.Background = GetAccessColor(progSet.config.GetAccess());
            }

            chkNotify.IsChecked = progSet.config.GetNotify();

            progGrid.Items.Clear();

            foreach (Program prog in progSet.Programs.Values)
            {
                progGrid.Items.Insert(0, new ProgEntry(prog));
            }

            btnSplit.IsEnabled = progSet.Programs.Count > 1;
            SuspendChange--;
        }
Esempio n. 14
0
        public MainWindow()
        {
            InitializeComponent();

            this.Title = string.Format("{0} v{1} by David Xanatos", App.Title, App.Version);
            if (App.lic.LicenseStatus != QLicense.LicenseStatus.VALID)
            {
                if (!App.lic.CommercialUse)
                {
                    this.Title += " - Freeware for Private NOT Commercial Use";
                }
                else if (App.IsEvaluationExpired())
                {
                    this.Title += " - Evaluation license EXPIRED";
                }
                else
                {
                    this.Title += " - Evaluation license for Commercial Use";
                }
            }

            /*else
             * {
             *  if (App.lic.CommercialUse)
             *      this.Title += " - Business Edition";
             * }*/

            WpfFunc.LoadWnd(this, "Main");

            bool HasEngine = App.client.IsConnected();

            notificationWnd = new NotificationWnd(HasEngine);
            //notificationWnd.Closed += NotificationClosed;

            mPages.Add("Overview", new PageItem(new OverviewPage()));
            mPages.Add("Privacy", new PageItem(new PrivacyPage()));
            mPages.Add("Firewall", new PageItem(HasEngine ? new FirewallPage() : null));
            mPages.Add("Dns", new PageItem(new DnsPage()));
            //mPages.Add("Terminator", new PageItem(null));
            //mPages.Add("VPN", new PageItem(new VPNPage()));
            mPages.Add("Settings", new PageItem(new SettingsPage()));
            mPages.Add("About", new PageItem(new AboutPage()));

            foreach (var page in mPages.Values)
            {
                if (page.ctrl != null)
                {
                    page.ctrl.Visibility = Visibility.Collapsed;
                    this.Main.Children.Add(page.ctrl);
                }
            }

            Brush brushOn  = (TryFindResource("SidePanel.on") as Brush);
            Brush brushOff = (TryFindResource("SidePanel.off") as Brush);

            foreach (var val in mPages)
            {
                string name = val.Key;

                TabItem item = new TabItem();
                val.Value.tab = item;
                this.SidePanel.Items.Add(item);

                item.KeyDown           += SidePanel_Click;
                item.MouseLeftButtonUp += SidePanel_Click;
                item.Name  = "PanelItem_" + name;
                item.Style = (TryFindResource("SidePanelItem") as Style);

                StackPanel panel = new StackPanel();
                item.Header   = panel;
                panel.ToolTip = Translate.fmt("lbl_" + name.ToLower());

                Image image = new Image();
                image.Width  = 32;
                image.Height = 32;
                image.SnapsToDevicePixels = true;
                image.Name = "PanelItem_" + name + "_Image";
                panel.Children.Add(image);

                Path pin = new Path();
                pin.Width            = 4;
                pin.Height           = 24;
                pin.Margin           = new Thickness(-43, -32, 0, 0);
                pin.Fill             = TryFindResource("SidePanel.Pin") as SolidColorBrush;
                pin.IsHitTestVisible = false;
                pin.Name             = "PanelItem_" + name + "_Pin";
                pin.Data             = new RectangleGeometry(new Rect(new Point(0, 0), new Point(4, 24)));
                panel.Children.Add(pin);

                Geometry geometry = (TryFindResource("Icon_" + name) as Geometry);
                image.Tag = new Tuple <DrawingImage, DrawingImage>(new DrawingImage(new GeometryDrawing(brushOn, null, geometry)), new DrawingImage(new GeometryDrawing(brushOff, null, geometry)));
            }

            //Main.Loaded += (sender, e) =>{
            SwitchPage(App.GetConfig("GUI", "CurPage", "Overview"));
            //};

            FullyLoaded = true;

            UpdateEnabled();
        }
Esempio n. 15
0
        public void Refresh()
        {
            bHold = true;

            chkTray.IsChecked      = App.GetConfigInt("Startup", "Tray") != 0;
            chkAutoStart.IsChecked = App.IsAutoStart();
            chkService.IsChecked   = Priv10Service.IsInstalled();
            chkNoUAC.IsChecked     = AdminFunc.IsSkipUac(App.Key);

            chkTweakCheck.IsChecked = App.GetConfigInt("TweakGuard", "AutoCheck", 1) != 0;
            chkTweakFix.IsEnabled   = chkTweakCheck.IsChecked == true;
            chkTweakFix.IsChecked   = App.GetConfigInt("TweakGuard", "AutoFix", 0) != 0;

            chkUseFW.IsChecked = App.GetConfigInt("Firewall", "Enabled", 0) != 0;

            if (App.client.IsConnected())
            {
                var mode = App.client.GetFilteringMode();

                radWhitelist.IsChecked = mode == FirewallManager.FilteringModes.WhiteList;
                radBlacklist.IsChecked = mode == FirewallManager.FilteringModes.BlackList;
                radDisabled.IsChecked  = mode == FirewallManager.FilteringModes.NoFiltering;

                var pol = App.client.GetAuditPolicy();
                switch (pol)
                {
                case FirewallMonitor.Auditing.All: cmbAudit.SelectedItem = lblAuditAll; break;

                case FirewallMonitor.Auditing.Blocked: cmbAudit.SelectedItem = lblAuditBlock; break;

                default: cmbAudit.SelectedItem = lblAuditNone; break;
                }

                chkGuardFW.IsEnabled = chkUseFW.IsChecked == true;
                chkGuardFW.IsChecked = App.client.IsFirewallGuard();

                chkEnableDNS.IsChecked = App.GetConfigInt("DnsProxy", "Enabled", 0) != 0;
            }
            else
            {
                chkUseFW.IsEnabled = false;

                radWhitelist.IsEnabled = false;
                radBlacklist.IsEnabled = false;
                radDisabled.IsEnabled  = false;
                cmbAudit.IsEnabled     = false;

                chkGuardFW.IsEnabled = false;

                chkEnableDNS.IsEnabled = false;
            }

            var fix_mode = App.GetConfigInt("Firewall", "GuardMode", 0);

            radFix.IsChecked     = fix_mode == (int)FirewallGuard.Mode.Fix;
            radDisable.IsChecked = fix_mode == (int)FirewallGuard.Mode.Disable;
            radAlert.IsChecked   = fix_mode == (int)FirewallGuard.Mode.Alert;

            radFix.IsEnabled = radDisable.IsEnabled = radAlert.IsEnabled = (chkGuardFW.IsChecked != false && chkGuardFW.IsEnabled);


            chkNotifyFW.IsEnabled = chkUseFW.IsChecked == true;
            chkNotifyFW.IsChecked = App.GetConfigInt("Firewall", "NotifyBlocked", 1) != 0;

            chkDnsInspector.IsChecked = App.GetConfigInt("DnsInspector", "Enabled", 0) != 0;

            chkReverseDNS.IsChecked = App.GetConfigInt("DnsInspector", "UseReverseDNS", 0) != 0;

            // DNS
            chkLocalDNS.IsChecked = App.GetConfigInt("DnsProxy", "SetLocal", 0) != 0;
            string UpstreamDNS = App.GetConfig("DNSProxy", "UpstreamDNS", "8.8.8.8");

            if (!WpfFunc.CmbSelect(cmbRootDNS, UpstreamDNS))
            {
                cmbRootDNS.Text = UpstreamDNS;
            }
            CheckDNS();

            //this.btnBackup.IsEnabled = this.btnRestore.IsEnabled = !App.isPortable;

            bHold = false;
        }
Esempio n. 16
0
        private void cmbProtocol_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ContentControl protocol = (cmbProtocol.SelectedItem as ContentControl);
            int?           protType;

            if (protocol == null)
            {
                protType = ParseProtocol(cmbProtocol.Text);
            }
            else
            {
                protType = (int)protocol.Tag;
            }

            if (curProtocol == protType)
            {
                return;
            }
            curProtocol = protType;
            if (curProtocol == null)
            {
                return;
            }

            if (protType == (int)FirewallRule.KnownProtocols.TCP || protType == (int)FirewallRule.KnownProtocols.UDP)
            {
                tabParams.SelectedItem = tabPorts;
            }
            else if (protType == (int)FirewallRule.KnownProtocols.ICMP || protType == (int)FirewallRule.KnownProtocols.ICMPv6)
            {
                tabParams.SelectedItem = tabICMP;

                cmbICMP.Items.Clear();
                cmbICMP.Items.Add(new ContentControl()
                {
                    Content = Translate.fmt("icmp_all"), Tag = "*"
                });
                bool v6 = (protType == (int)FirewallRule.KnownProtocols.ICMPv6);
                Dictionary <int, string> types = (v6 ? NetFunc.KnownIcmp6Types : NetFunc.KnownIcmp4Types);
                foreach (int type in types.Keys)
                {
                    cmbICMP.Items.Add(new ContentControl()
                    {
                        Content = type.ToString() + ":* (" + types[type] + ")", Tag = type.ToString() + ":*"
                    });
                }
                cmbICMP.Items.Add(new ContentControl()
                {
                    Content = "3:4 (Type 3, Code 4)", Tag = "3:4"
                });                                                                                        // why does windows firewall has this explicitly
                if (!WpfFunc.CmbSelect(cmbICMP, Rule.GetIcmpTypesAndCodes()) && Rule.IcmpTypesAndCodes != null)
                {
                    cmbICMP.Text = Rule.GetIcmpTypesAndCodes();
                }
            }
            else
            {
                tabParams.SelectedItem = tabNone;
            }

            UpdatePorts();
            someThing_Changed(sender, e);
        }
Esempio n. 17
0
        public ProgramTreeControl()
        {
            InitializeComponent();

            this.hdrDescr.Content     = Translate.fmt("lbl_descr");
            this.hdrCat.Content       = Translate.fmt("lbl_log_type");
            this.hdrAccess.Content    = Translate.fmt("lbl_access");
            this.hdrRules.Content     = Translate.fmt("lbl_rules");
            this.hdrAllowed.Content   = Translate.fmt("filter_recent_allowed");
            this.hdrBlocked.Content   = Translate.fmt("filter_recent_blocked");
            this.hdrActivity.Content  = Translate.fmt("sort_act");
            this.hdrSockets.Content   = Translate.fmt("lbl_socks");
            this.hdrUpRate.Content    = Translate.fmt("lbl_upload");
            this.hdrDownRate.Content  = Translate.fmt("lbl_download");
            this.hdrUpTotal.Content   = Translate.fmt("lbl_uploaded");
            this.hdrDownTotal.Content = Translate.fmt("lbl_downloaded");
            this.hdrProg.Content      = Translate.fmt("lbl_program");

            treeView.Loaded += (sender, e) => {
                headerPresenter = WpfFunc.FindChild <GridViewHeaderRowPresenter>(treeView);
                if (headerPresenter == null)
                {
                    return;
                }

                allColumns = headerPresenter.Columns.Cast <GridViewColumn>().ToArray();

                Restore(App.GetConfig("GUI", "progTree_Columns", ""));

                headerMenu = new ContextMenu();
                ContextMenuService.SetContextMenu(headerPresenter, headerMenu);

                if (headerMenu.Items.Count == 0)
                {
                    CreateHeaderMenu();
                }
            };

            treeView.Root      = root = new ProgTreeRoot("");
            treeView.ShowRoot  = false;
            treeView.ShowLines = false;

            treeView.PreviewKeyDown += TreeView_KeyDown;


            var contextMenu = new ContextMenu();


            menuAdd    = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_add_prog"), null, TryFindResource("Icon_Plus"));
            menuAddSub = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_add_to_set"), null, TryFindResource("Icon_Plus"));
            contextMenu.Items.Add(new Separator());
            menuRemove = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_del_progs"), null, TryFindResource("Icon_Remove"));
            contextMenu.Items.Add(new Separator());
            menuMerge = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_merge_progs"), null, TryFindResource("Icon_Merge"));
            menuSplit = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_split_progs"), null, TryFindResource("Icon_Split"));
            contextMenu.Items.Add(new Separator());

            menuAccess       = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_access_prog"), null, TryFindResource("Icon_NetAccess"));
            menuAccessNone   = WpfFunc.AddMenu(menuAccess, Translate.fmt("acl_none"), null, null, ProgramSet.Config.AccessLevels.Unconfigured);
            menuAccessAllow  = WpfFunc.AddMenu(menuAccess, Translate.fmt("acl_allow"), null, null, ProgramSet.Config.AccessLevels.FullAccess);
            menuAccessCustom = WpfFunc.AddMenu(menuAccess, Translate.fmt("acl_edit"), null, null, ProgramSet.Config.AccessLevels.CustomConfig);
            menuAccessLan    = WpfFunc.AddMenu(menuAccess, Translate.fmt("acl_lan"), null, null, ProgramSet.Config.AccessLevels.LocalOnly);
            menuAccessBlock  = WpfFunc.AddMenu(menuAccess, Translate.fmt("acl_block"), null, null, ProgramSet.Config.AccessLevels.BlockAccess);
            foreach (MenuItem item in menuAccess.Items)
            {
                item.Background = ProgramControl.GetAccessColor((ProgramSet.Config.AccessLevels)item.Tag);
                //item.IsCheckable = true;
            }

            menuNotify             = WpfFunc.AddMenu(contextMenu, Translate.fmt("lbl_notify"), null);
            menuNotify.IsCheckable = true;

            contextMenu.Items.Add(new Separator());
            menuRename   = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_rename_prog"), null, TryFindResource("Icon_Rename"));
            menuSetIcon  = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_icon_prog"), null, TryFindResource("Icon_SetIcon"));
            menuCategory = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_cat_prog"), null, TryFindResource("Icon_Category"));

            treeView.ContextMenu = contextMenu;
        }
Esempio n. 18
0
        public RuleWindow(List <Program> progs, FirewallRuleEx rule)
        {
            InitializeComponent();

            this.Title = Translate.fmt("wnd_rule");

            this.grpRule.Header = Translate.fmt("lbl_rule");
            this.lblName.Text   = Translate.fmt("lbl_name");
            this.lblGroup.Text  = Translate.fmt("lbl_group");

            this.grpProgram.Header  = Translate.fmt("lbl_program");
            this.lblProgram.Text    = Translate.fmt("lbl_program");
            this.lblExecutable.Text = Translate.fmt("lbl_exe");
            this.lblService.Text    = Translate.fmt("lbl_svc");
            this.lblApp.Text        = Translate.fmt("lbl_app");

            this.grpAction.Header = Translate.fmt("grp_action");
            this.lblAction.Text   = Translate.fmt("lbl_action");

            this.radProfileAll.Content    = Translate.fmt("lbl_prof_all");
            this.radProfileCustom.Content = Translate.fmt("lbl_prof_sel");
            this.chkPublic.Content        = Translate.fmt("lbl_prof_pub");
            this.chkDomain.Content        = Translate.fmt("lbl_prof_dmn");
            this.chkPrivate.Content       = Translate.fmt("lbl_prof_priv");

            this.radNicAll.Content    = Translate.fmt("lbl_itf_all");
            this.radNicCustom.Content = Translate.fmt("lbl_itf_select");
            this.chkLAN.Content       = Translate.fmt("lbl_itf_lan");
            this.chkVPN.Content       = Translate.fmt("lbl_itf_vpn");
            this.chkWiFi.Content      = Translate.fmt("lbl_itf_wifi");

            this.grpNetwork.Header = Translate.fmt("grp_network");
            this.lblDirection.Text = Translate.fmt("lbl_direction");
            this.lblProtocol.Text  = Translate.fmt("lbl_protocol");

            this.lblLocalPorts.Text  = Translate.fmt("lbl_local_port");
            this.lblRemotePorts.Text = Translate.fmt("lbl_remote_port");

            this.lblICMP.Text = Translate.fmt("lbl_icmp");

            this.lblLocalIP.Text  = Translate.fmt("lbl_local_ip");
            this.lblRemoteIP.Text = Translate.fmt("lbl_remote_ip");

            this.btnOK.Content     = Translate.fmt("lbl_ok");
            this.btnCancel.Content = Translate.fmt("lbl_cancel");

            Rule = rule;
            bool bNew = Rule.guid == null;

            viewModel   = new RuleWindowViewModel();
            DataContext = viewModel;

            //txtName.Text = Rule.Name;
            viewModel.RuleName   = Rule.Name;
            cmbGroup.ItemsSource = GroupModel.GetInstance().GetGroups();
            if (!WpfFunc.CmbSelect(cmbGroup, Rule.Grouping))
            {
                cmbGroup.Text = Rule.Grouping;
            }
            txtInfo.Text = Rule.Description;

            if (progs != null)
            {
                foreach (Program prog in progs)
                {
                    ContentControl program = new ContentControl()
                    {
                        Content = prog.Description, Tag = prog.ID
                    };
                    cmbProgram.Items.Add(program);
                    if (Rule.ProgID != null && prog.ID.CompareTo(Rule.ProgID) == 0)
                    {
                        cmbProgram.SelectedItem = program;
                    }
                }
            }
            else
            {
                ContentControl program = new ContentControl()
                {
                    Content = ProgramControl.FormatProgID(Rule.ProgID), Tag = Rule.ProgID
                };
                cmbProgram.Items.Add(program);
                cmbProgram.SelectedItem = program;
            }

            txtPath.Text    = rule.BinaryPath ?? "";
            txtService.Text = rule.ServiceTag ?? "";
            txtApp.Text     = rule.AppSID != null?AppModel.GetInstance().GetAppPkgBySid(rule.AppSID)?.ID ?? rule.AppSID : "";

            cmbAction.Items.Add(new ContentControl()
            {
                Content = Translate.fmt("str_allow"), Tag = FirewallRule.Actions.Allow
            });
            cmbAction.Items.Add(new ContentControl()
            {
                Content = Translate.fmt("str_block"), Tag = FirewallRule.Actions.Block
            });
            //WpfFunc.CmbSelect(cmbAction, Rule.Action.ToString());
            viewModel.RuleAction = WpfFunc.CmbPick(cmbAction, Rule.Action.ToString());

            if (Rule.Profile == (int)FirewallRule.Profiles.All)
            {
                radProfileAll.IsChecked = true;
                chkPrivate.IsChecked    = true;
                chkDomain.IsChecked     = true;
                chkPublic.IsChecked     = true;
            }
            else
            {
                radProfileCustom.IsChecked = true;
                chkPrivate.IsChecked       = ((Rule.Profile & (int)FirewallRule.Profiles.Private) != 0);
                chkDomain.IsChecked        = ((Rule.Profile & (int)FirewallRule.Profiles.Domain) != 0);
                chkPublic.IsChecked        = ((Rule.Profile & (int)FirewallRule.Profiles.Public) != 0);
            }

            if (Rule.Interface == (int)FirewallRule.Interfaces.All)
            {
                radNicAll.IsChecked = true;
                chkLAN.IsChecked    = true;
                chkVPN.IsChecked    = true;
                chkWiFi.IsChecked   = true;
            }
            else
            {
                radNicCustom.IsChecked = true;
                chkLAN.IsChecked       = ((Rule.Interface & (int)FirewallRule.Interfaces.Lan) != 0);
                chkVPN.IsChecked       = ((Rule.Interface & (int)FirewallRule.Interfaces.RemoteAccess) != 0);
                chkWiFi.IsChecked      = ((Rule.Interface & (int)FirewallRule.Interfaces.Wireless) != 0);
            }

            if (bNew)
            {
                cmbDirection.Items.Add(new ContentControl()
                {
                    Content = Translate.fmt("str_inandout"), Tag = FirewallRule.Directions.Bidirectiona
                });
            }
            cmbDirection.Items.Add(new ContentControl()
            {
                Content = Translate.fmt("str_outbound"), Tag = FirewallRule.Directions.Outbound
            });
            cmbDirection.Items.Add(new ContentControl()
            {
                Content = Translate.fmt("str_inbound"), Tag = FirewallRule.Directions.Inbound
            });
            WpfFunc.CmbSelect(cmbDirection, Rule.Direction.ToString());

            cmbProtocol.Items.Add(new ContentControl()
            {
                Content = Translate.fmt("pro_any"), Tag = (int)NetFunc.KnownProtocols.Any
            });
            for (int i = (int)NetFunc.KnownProtocols.Min; i <= (int)NetFunc.KnownProtocols.Max; i++)
            {
                string name = NetFunc.Protocol2Str((UInt32)i);
                if (name != null)
                {
                    cmbProtocol.Items.Add(new ContentControl()
                    {
                        Content = i.ToString() + " - " + name, Tag = i
                    });
                }
            }
            //if (!WpfFunc.CmbSelect(cmbProtocol, Rule.Protocol.ToString()))
            //    cmbProtocol.Text = Rule.Protocol.ToString();
            viewModel.Protocol = WpfFunc.CmbPick(cmbProtocol, Rule.Protocol.ToString());
            if (viewModel.Protocol == null)
            {
                viewModel.ProtocolTxt = Rule.Protocol.ToString();
            }

            UpdatePorts();

            addrDest.Address = Rule.RemoteAddresses;
            addrSrc.Address  = Rule.LocalAddresses;

            App.LoadWnd(this, "Rule");
        }
Esempio n. 19
0
        public FirewallRuleList()
        {
            InitializeComponent();

            /*this.grpRules.Header = Translate.fmt("grp_firewall");
             * this.grpRuleTools.Header = Translate.fmt("grp_tools");
             * this.grpRuleView.Header = Translate.fmt("grp_view");
             *
             * this.btnCreateRule.Content = Translate.fmt("btn_mk_rule");
             * this.btnEnableRule.Content = Translate.fmt("btn_enable_rule");
             * this.btnDisableRule.Content = Translate.fmt("btn_disable_rule");
             * this.btnRemoveRule.Content = Translate.fmt("btn_remove_rule");
             * this.btnBlockRule.Content = Translate.fmt("btn_block_rule");
             * this.btnAllowRule.Content = Translate.fmt("btn_allow_rule");
             * this.btnEditRule.Content = Translate.fmt("btn_edit_rule");
             * this.btnCloneRule.Content = Translate.fmt("btn_clone_rule");*/

            //this.chkNoDisabled.Content = Translate.fmt("chk_hide_disabled");
            //this.lblFilterRules.Content = Translate.fmt("lbl_filter_rules");

            //this.lblFilter.Content = Translate.fmt("lbl_filter");
            this.txtRuleFilter.LabelText = Translate.fmt("lbl_text_filter");
            this.cmbAll.Content          = Translate.fmt("str_all_actions");
            this.cmbAllow.Content        = Translate.fmt("str_allow");
            this.cmbBlock.Content        = Translate.fmt("str_block");
            this.cmbBooth.Content        = Translate.fmt("str_all_rules");
            this.cmbIn.Content           = Translate.fmt("str_inbound");
            this.cmbOut.Content          = Translate.fmt("str_outbound");
            this.chkNoDisabled.ToolTip   = Translate.fmt("str_no_disabled");

            int i = 0;

            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_name");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_group");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_index");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_status");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_count");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_profiles");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_action");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_direction");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_protocol");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_remote_ip");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_local_ip");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_remote_port");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_local_port");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_icmp");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_interfaces");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_edge");
            this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_program");


            RulesList             = new ObservableCollection <RuleItem>();
            rulesGrid.ItemsSource = RulesList;

            var contextMenu = new ContextMenu();


            WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_mk_rule"), btnCreateRule_Click, TryFindResource("Icon_Plus"));
            contextMenu.Items.Add(new Separator());
            menuEnableRule  = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_enable_rule"), btnEnableRule_Click, TryFindResource("Icon_Enable"));
            menuDisableRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_disable_rule"), btnDisableRule_Click, TryFindResource("Icon_Disable"));
            contextMenu.Items.Add(new Separator());
            menuBlockRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_block_rule"), btnBlockRule_Click, TryFindResource("Icon_Deny"));
            menuAllowRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_allow_rule"), btnAllowRule_Click, TryFindResource("Icon_Check"));
            contextMenu.Items.Add(new Separator());
            menuRemoveRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_remove_rule"), btnRemoveRule_Click, TryFindResource("Icon_Remove"));
            menuEditRule   = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_edit_rule"), btnEditRule_Click, TryFindResource("Icon_Edit"));
            menuCloneRule  = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_clone_rule"), btnCloneRule_Click, TryFindResource("Icon_Clone"));
            contextMenu.Items.Add(new Separator());
            menuApproveRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_approve_rule"), btnApproveRule_Click, TryFindResource("Icon_Approve"));
            menuRestoreRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_restore_rule"), btnRestoreRule_Click, TryFindResource("Icon_Undo"));
            menuRedoRule    = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_redo_rule"), btnRedoRule_Click, TryFindResource("Icon_Redo"));

            rulesGrid.ContextMenu = contextMenu;

            rulesGridExt = new DataGridExt(rulesGrid);
            rulesGridExt.Restore(App.GetConfig("GUI", "rulesGrid_Columns", ""));

            UwpFunc.AddBinding(rulesGrid, new KeyGesture(Key.F, ModifierKeys.Control), (s, e) => { this.txtRuleFilter.Focus(); });
            UwpFunc.AddBinding(rulesGrid, new KeyGesture(Key.Delete), btnRemoveRule_Click);

            try
            {
                textFilter                   = App.GetConfig("FwRules", "Filter", "");
                txtRuleFilter.Text           = textFilter;
                cmbAction.SelectedIndex      = App.GetConfigInt("FwRules", "Actions", 0);
                cmbDirection.SelectedIndex   = App.GetConfigInt("FwRules", "Directions", 0);
                this.chkNoDisabled.IsChecked = App.GetConfigInt("FwRules", "NoDisabled", 0) == 1;
            }
            catch { }

            CheckRules();
        }
Esempio n. 20
0
 private void Window_Closing(object sender, CancelEventArgs e)
 {
     WpfFunc.StoreWnd(this, "Rule");
 }