/// <summary> /// /// </summary> private DomainFacade(IPAccountingConfig pConfig, IPlugin pPlugin) { cPlugin = pPlugin; cRecordList = new List <AccountingItem>(); cObserverList = new List <IObserver>(); cInfrastructure = InfrastructureFacade.getInstance(pConfig, pPlugin, ref cRecordList); }
/// <summary> /// Create single instance /// </summary> /// <returns></returns> public static InfrastructureFacade getInstance(IPAccountingConfig pConfig, IPlugin pPlugin, ref List <AccountingItem> pRecordList) { if (cInstance == null) { cInstance = new InfrastructureFacade(pConfig, pPlugin, pRecordList); } return(cInstance); }
/// <summary> /// Create single instance /// </summary> /// <returns></returns> public static DomainFacade getInstance(IPAccountingConfig pConfig, IPlugin pPlugin) { if (cInstance == null) { cInstance = new DomainFacade(pConfig, pPlugin); } return(cInstance); }
/// <summary> /// /// </summary> public PluginIPAccountingUC(PluginParameters pPluginParams) { InitializeComponent(); /* * Set DGV double buffer on */ Type dgvType = DGV_TrafficData.GetType(); PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic); pi.SetValue(DGV_TrafficData, true, null); /* * Plugin configuration */ cPluginParams = 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 = "IP accounting", PluginDescription = "Listing data traffic statistics.", PluginVersion = "0.8", Ports = "", IsActive = true }; /* * Initialisation */ RB_Service_Click(null, null); cAccountingRecords = new BindingList <AccountingItem>(); DGV_TrafficData.DataSource = cAccountingRecords; IPAccountingConfig lConfig = new IPAccountingConfig() { BasisDirectory = Config.BaseDir, isDebuggingOn = false, //cPluginParams.HostApplication.IsDebuggingOn(), Interface = null, //cPluginParams.HostApplication.GetInterface(), onUpdateList = update, onIPAccountingExit = null }; cTask = TaskFacade.getInstance(lConfig, this); DomainFacade.getInstance(lConfig, this).addObserver(this); }
/// <summary> /// /// </summary> /// <param name="pConfig"></param> private void init(IPAccountingConfig pConfig) { if (cAccountingConfig == null) { cAccountingConfig = new IPAccountingConfig(); } if (pConfig != null) { cAccountingConfig.BasisDirectory = pConfig.BasisDirectory != null ? pConfig.BasisDirectory : cAccountingConfig.BasisDirectory; cAccountingConfig.Interface = pConfig.Interface != null ? pConfig.Interface : cAccountingConfig.Interface; cAccountingConfig.isDebuggingOn = pConfig.isDebuggingOn; cAccountingConfig.onIPAccountingExit = pConfig.onIPAccountingExit != null ? pConfig.onIPAccountingExit : cAccountingConfig.onIPAccountingExit; cAccountingConfig.onUpdateList = pConfig.onUpdateList != null ? pConfig.onUpdateList : cAccountingConfig.onUpdateList; cAccountingConfig.StructureParameter = pConfig.StructureParameter != null ? pConfig.StructureParameter : cAccountingConfig.StructureParameter; } }
public void onStartAttack() { if (Config.IsActive) { if (InvokeRequired) { BeginInvoke(new onStartAttackDelegate(onStartAttack), new object[] { }); return; } // if (InvokeRequired) /* * Start accounting application. */ try { cTask.onInit(); // setGUIInactive(); IPAccountingConfig lConfig = new IPAccountingConfig { BasisDirectory = Config.BaseDir, isDebuggingOn = cPluginParams.HostApplication.IsDebuggingOn(), onUpdateList = update, onIPAccountingExit = onIPAccountingExited, Interface = cPluginParams.HostApplication.GetInterface(), StructureParameter = cAccountingBasis }; cTask.onStart(lConfig); cPluginParams.HostApplication.PluginSetStatus(this, "green"); } catch (Exception lEx) { cTask.onStop(); cPluginParams.HostApplication.PluginSetStatus(this, "red"); cPluginParams.HostApplication.LogMessage(String.Format("{0}: {1}", Config.PluginName, lEx.Message)); } } // if (cIsActi... }
/// <summary> /// /// </summary> /// <param name="pConfig"></param> private InfrastructureFacade(IPAccountingConfig pAccountingConfig, IPlugin pPlugin, List <AccountingItem> pRecords) { cAccountingConfig = pAccountingConfig; cPlugin = pPlugin; cAccountingRecords = pRecords; cIPAccountingPath = String.Format(@"{0}{1}", cAccountingConfig.BasisDirectory, cIPAccountingBin); init(pAccountingConfig); // Create Session directory if it doesn't exist try { if (!Directory.Exists(cPlugin.Config.SessionDir)) { Directory.CreateDirectory(cPlugin.Config.SessionDir); } } catch (Exception lEx) { } }
/// <summary> /// /// </summary> public void onStart(IPAccountingConfig pConfig) { /* * Reassign configuration parameters */ init(pConfig); /* * Check binary */ if (!File.Exists(cIPAccountingPath)) { throw new Exception("The IPAccounting binary was not found."); } else if (String.IsNullOrEmpty(pConfig.Interface)) { throw new Exception("There was no interface defined."); } /* * Create process objects */ cAccountingRecords.Clear(); var lProcStartInfo = new ProcessStartInfo(); cIPAccountingProc = new Process(); lProcStartInfo.WorkingDirectory = cAccountingConfig.BasisDirectory; cIPAccountingProc.StartInfo = lProcStartInfo; cIPAccountingProc.StartInfo.FileName = cIPAccountingPath; cIPAccountingProc.StartInfo.Arguments = String.Format("-i {0} -x {1}", pConfig.Interface, cAccountingConfig.StructureParameter); cIPAccountingProc.StartInfo.UseShellExecute = false; cIPAccountingProc.StartInfo.CreateNoWindow = pConfig.isDebuggingOn ? false : true; cIPAccountingProc.StartInfo.WindowStyle = ProcessWindowStyle.Normal; // set up output redirection cIPAccountingProc.StartInfo.RedirectStandardOutput = true; // cIPAccountingProc.StartInfo.RedirectStandardError = true; cIPAccountingProc.EnableRaisingEvents = true; // Set the data received handlers //cIPAccountingProc.ErrorDataReceived += OnDataRecived; cIPAccountingProc.OutputDataReceived += onDataRecived; // Configure the process exited event cIPAccountingProc.Exited += new EventHandler(onIPAccountingExited); cIPAccountingProc.Start(); //cIPAccountingProc.BeginErrorReadLine(); cIPAccountingProc.BeginOutputReadLine(); Thread.Sleep(100); try { if (!cAccountingConfig.isDebuggingOn) { ShowWindow(cIPAccountingProc.MainWindowHandle, 0); } } catch (Exception) { } }
/// <summary> /// /// </summary> public void onStart(IPAccountingConfig pConfig) { cInfrastructure.onStart(pConfig); }
/// <summary> /// /// </summary> private TaskFacade(IPAccountingConfig pConfig, IPlugin pPlugin) { cPlugin = pPlugin; cDomain = DomainFacade.getInstance(pConfig, pPlugin); }
/// <summary> /// /// </summary> public void onStart(IPAccountingConfig pConfig) { cDomain.onStart(pConfig); }