Esempio n. 1
0
        /// <summary>
        /// Create single instance
        /// </summary>
        /// <returns></returns>
        public static TaskFacade getInstance(IPlugin pPlugin)
        {
            if (cInstance == null)
            cInstance = new TaskFacade(pPlugin);

              return (cInstance);
        }
Esempio n. 2
0
        public PluginFirewallUC(PluginParameters pPluginParams)
        {
            InitializeComponent();

              #region DATAGRID HEADER

              DataGridViewTextBoxColumn cID = new DataGridViewTextBoxColumn();
              cID.DataPropertyName = "ID";
              cID.Name = "ID";
              cID.HeaderText = "ID";
              cID.ReadOnly = true;
              cID.Width = 0;
              cID.Visible = false;
              DGV_FWRules.Columns.Add(cID);

              DataGridViewTextBoxColumn cProtocolCol = new DataGridViewTextBoxColumn();
              cProtocolCol.DataPropertyName = "Protocol";
              cProtocolCol.Name = "Protocol";
              cProtocolCol.HeaderText = "Prot.";
              cProtocolCol.ReadOnly = true;
              cProtocolCol.Width = 50;
              DGV_FWRules.Columns.Add(cProtocolCol);

              DataGridViewTextBoxColumn cSrcIPCol = new DataGridViewTextBoxColumn();
              cSrcIPCol.DataPropertyName = "SrcIP";
              cSrcIPCol.Name = "SrcIP";
              cSrcIPCol.HeaderText = "Source IP";
              cSrcIPCol.ReadOnly = true;
              cSrcIPCol.Width = 95;
              DGV_FWRules.Columns.Add(cSrcIPCol);

              DataGridViewTextBoxColumn cSrcPortLowerCol = new DataGridViewTextBoxColumn();
              cSrcPortLowerCol.DataPropertyName = "SrcPortLower";
              cSrcPortLowerCol.Name = "SrcPortLower";
              cSrcPortLowerCol.HeaderText = "Src. port (lower)";
              cSrcPortLowerCol.ReadOnly = true;
              cSrcPortLowerCol.Width = 125;
              DGV_FWRules.Columns.Add(cSrcPortLowerCol);

              DataGridViewTextBoxColumn cSrcPortUpperCol = new DataGridViewTextBoxColumn();
              cSrcPortUpperCol.DataPropertyName = "SrcPortUpper";
              cSrcPortUpperCol.Name = "SrcPortUpper";
              cSrcPortUpperCol.HeaderText = "Src. port (upper)";
              cSrcPortUpperCol.ReadOnly = true;
              cSrcPortUpperCol.Width = 125;
              DGV_FWRules.Columns.Add(cSrcPortUpperCol);

              DataGridViewTextBoxColumn cDstIPCol = new DataGridViewTextBoxColumn();
              cDstIPCol.DataPropertyName = "DstIP";
              cDstIPCol.Name = "DstIP";
              cDstIPCol.HeaderText = "Dest. IP";
              cDstIPCol.ReadOnly = true;
              cDstIPCol.Width = 95;
              DGV_FWRules.Columns.Add(cDstIPCol);

              DataGridViewTextBoxColumn cDstPortLowerCol = new DataGridViewTextBoxColumn();
              cDstPortLowerCol.DataPropertyName = "DstPortLower";
              cDstPortLowerCol.Name = "DstPortLower";
              cDstPortLowerCol.HeaderText = "Dst. port (lower)";
              cDstPortLowerCol.ReadOnly = true;
              cDstPortLowerCol.Width = 125;
              DGV_FWRules.Columns.Add(cDstPortLowerCol);

              DataGridViewTextBoxColumn cDstPortUpperCol = new DataGridViewTextBoxColumn();
              cDstPortUpperCol.DataPropertyName = "DstPortUpper";
              cDstPortUpperCol.Name = "DstPortUpper";
              cDstPortUpperCol.HeaderText = "Dst. port (upper)";
              cDstPortUpperCol.ReadOnly = true;
              cDstPortUpperCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
              //      cDstPortUpperCol.Width = 127;
              DGV_FWRules.Columns.Add(cDstPortUpperCol);

              cFWRules = new BindingList<FWRule>();
              DGV_FWRules.DataSource = cFWRules;

              #endregion

              /*
               * Plugin configuration
               */
              PluginParameters = pPluginParams;
              String lBaseDir = String.Format(@"{0}\", (pPluginParams != null) ? pPluginParams.PluginDirectoryFullPath : Directory.GetCurrentDirectory());
              String lSessionDir = (pPluginParams != null) ? pPluginParams.SessionDirectoryFullPath : String.Format("{0}sessions", lBaseDir);

              Config = new PluginProperties()
              {
            BaseDir = lBaseDir,
            SessionDir = lSessionDir,
            PluginName = "Firewall",
            PluginDescription = "Letting pass or blocking client systems data packets.",
            PluginVersion = "0.5",
            Ports = "",
            IsActive = true
              };

              // Populate Protocol combobox
              CB_Protocol.Items.Add("TCP");
              CB_Protocol.Items.Add("UDP");
              CB_Protocol.SelectedIndex = 0;

              cTask = TaskFacade.getInstance(this);
              cDomain = DomainFacade.getInstance(this);
              cDomain.addObserver(this);

              cSrcTargetList = new List<String>();
              cDstTargetList = new List<String>();
        }