public MainWindow() { InitializeComponent(); // Initialize exception logging AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; try { Setup(); SettingsManager.LoadConfig(); ListenerManager = new ListenerManager(); AppWindow = this; MessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(1)); MainSnackbar.MessageQueue = MessageQueue; IsMaximized = SettingsManager.Settings.MainWindowMaximized; WidthWin = SettingsManager.Settings.MainWindowWidth ?? Width; HeightWin = SettingsManager.Settings.MainWindowHeight ?? Height; IsMaximized = !IsMaximized; ToggleWin(this, null); WidthWin = SettingsManager.Settings.MainWindowWidth ?? Width; HeightWin = SettingsManager.Settings.MainWindowHeight ?? Height; SetCurrentView(typeof(StandardView)); // Generate Standard view model to show on startup SetCurrentMaps(SettingsManager.GetLatestCurrentMaps()); // Set currentmap to previously opened map } catch (Exception ex) { ex.Show(); } }
public MainWindow() { try { AppWindow = this; AppCommon = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); AppDataPath = Path.Combine(AppCommon, "Mapping Tools"); ExportPath = Path.Combine(AppDataPath, "Exports"); HttpClient = new HttpClient(); HttpClient.DefaultRequestHeaders.Add("user-agent", "Mapping Tools"); InitializeComponent(); Setup(); SettingsManager.LoadConfig(); ListenerManager = new ListenerManager(); DataContext = new MainWindowVm(); MessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(2)); MainSnackbar.MessageQueue = MessageQueue; if (SettingsManager.Settings.MainWindowRestoreBounds.HasValue) { SetToRect(SettingsManager.Settings.MainWindowRestoreBounds.Value); } SetFullscreen(SettingsManager.Settings.MainWindowMaximized); SetCurrentMaps(SettingsManager.GetLatestCurrentMaps()); // Set currentmap to previously opened map } catch (Exception ex) { ex.Show(); } }
public MainWindow() { // Initialize exception logging AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; try { AppWindow = this; AppCommon = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); AppDataPath = Path.Combine(AppCommon, "Mapping Tools"); ExportPath = Path.Combine(AppDataPath, "Exports"); HttpClient = new HttpClient(); InitializeComponent(); MessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(2)); MainSnackbar.MessageQueue = MessageQueue; Setup(); SettingsManager.LoadConfig(); ListenerManager = new ListenerManager(); if (SettingsManager.Settings.MainWindowRestoreBounds is Rect r) { SetToRect(r); } SetFullscreen(SettingsManager.Settings.MainWindowMaximized); SetCurrentView(typeof(StandardView)); // Generate Standard view model to show on startup SetCurrentMaps(SettingsManager.GetLatestCurrentMaps()); // Set currentmap to previously opened map } catch (Exception ex) { ex.Show(); } }
public void StopSpan(ISpan span) { _stackDepth--; if (_stackDepth == 0) { ListenerManager.NotifyFinish(this); } }
public void StopSpan(ISpan span) { _spans.TryPop(out _); if (_spans.Count == 0) { ListenerManager.NotifyFinish(this); } }
private static void Run(string[] args) { // ignore all certs ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; // parse program flags if (!CommandLineFlagManager.Parse(args)) { return; } AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; _log.Trace($"Initiating {ApplicationDetails.Name} startup - Local: {DateTime.Now.TimeOfDay} UTC: {DateTime.UtcNow.TimeOfDay}"); //load configuration try { Program.Configuration = ClientConfigurationLoader.Config; } catch (Exception e) { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var o = $"Exec path: {path} - configuration 404: {ApplicationDetails.ConfigurationFiles.Application} - exiting. Exception: {e}"; _log.Fatal(o); Console.WriteLine(o, Color.Red); Console.ReadLine(); return; } //linux clients do not catch stray processes or check for job duplication StartupTasks.SetStartup(); _listenerManager = new ListenerManager(); //check id _log.Trace(Comms.CheckId.Id); //connect to command server for updates and sending logs Comms.Updates.Run(); //linux clients do not perform local survey if (Configuration.HealthIsEnabled) { var h = new Health.Check(); h.Run(); } if (Configuration.HandlersIsEnabled) { var o = new Orchestrator(); o.Run(); } new ManualResetEvent(false).WaitOne(); }
public OpsGridManager(string tibcoServer, string tibcoUser, string tibcoPwd, int updateFromCacheTimerInterval, string msgFilter, string inbMsgFilter, List <string> pPermKeyList, bool pIsSuperUser) { try { managedGridList = new List <DevExpress.XtraGrid.GridControl>(); sumDataCache = new List <SummaryData>(); sumDataCacheCopy = new List <SummaryData>(); rqmtDataCache = new List <RqmtData>(); rqmtDataCacheCopy = new List <RqmtData>(); inbDocViewCache = new List <InboundDocsView>(); inbDocViewCacheCopy = new List <InboundDocsView>(); assDocDataCache = new List <AssociatedDoc>(); assDocDataCacheCopy = new List <AssociatedDoc>(); tradeRqmtConfirmCache = new List <TradeRqmtConfirm>(); tradeRqmtConfirmCacheCopy = new List <TradeRqmtConfirm>(); listenerManager = new ListenerManager(tibcoServer, tibcoUser, tibcoPwd, pPermKeyList, pIsSuperUser); Console.WriteLine("Filter Condition: " + msgFilter); listenerManager.AddListner("sempra.ops.opsTracking.summary.update", this.NotifyTradeSummaryArrived, msgFilter); listenerManager.AddListner("sempra.ops.opsTracking.rqmt.update", this.NotifyTradeRqmtArrived, ""); listenerManager.AddListner("sempra.ops.opsTracking.inboundDocs.update", this.NotifyInboundDocsArrived, inbMsgFilter); listenerManager.AddListner("sempra.ops.opsTracking.associatedDocs.update", this.NotifyAssociatedDocsArrived, inbMsgFilter); listenerManager.AddListner("sempra.ops.opsTracking.tradeRqmtConfirm.update", this.NotifyTradeRqmtConfirmArrived, ""); opsTrackingClock = new Timer((updateFromCacheTimerInterval) * 1000); opsTrackingClock.Elapsed += new ElapsedEventHandler(opsClockElapsed); myFireAlarm = new FireAlarm(); myFireHandler = new FireHandlerClass(myFireAlarm); } catch (Exception ex) { myFireAlarm.ActivateFireAlarm("Error in the OpsGridManager constructor. " + ex.Message); string keyListDisplay = string.Empty; if (pPermKeyList.Count > 0) { keyListDisplay = string.Join(",", pPermKeyList.ToArray()); } else { keyListDisplay = "[NONE]"; } throw new Exception("An error occurred while creating a new instance of OpsGridManager using the following values:" + Environment.NewLine + "Message Server: " + tibcoServer + ", Message User: "******", Update From Cache Timer Interval: " + updateFromCacheTimerInterval + Environment.NewLine + "Message Filter: " + msgFilter + ", Inbound Message Filter: " + inbMsgFilter + ", Is User a SuperUser? " + pIsSuperUser + Environment.NewLine + "Permission Keys: " + keyListDisplay + "." + Environment.NewLine + "Error CNF-349 in " + PROJ_FILE_NAME + ".OpsGridManager(): " + ex.Message); } }
private static async Task OpenListener() { await Task.Run(() => { ListenerManager.SetListener(ListenerManager.ListenerChooser.Nancy); var listener = ListenerManager.GetListener(); listener.Start(); UtilCmd.WriteTitle($"Local OS Address: [{listener.GetAddress()}]"); }); }
public void RemoveActiveHotkeyTest() { var listenerManager = new ListenerManager(); listenerManager.AddActiveHotkey("testKey", new ActionHotkey(new Hotkey(Key.A, ModifierKeys.Alt), () => {})); Assert.IsTrue(listenerManager.ActiveHotkeys.ContainsKey("testKey")); listenerManager.RemoveActiveHotkey("testKey"); Assert.IsFalse(listenerManager.ActiveHotkeys.ContainsKey("testKey")); }
//注册默认监听器 private void RegisterListners() { //ListenerManager.Register(new AopListener());//Aop监听器 //ListenerManager.Register(new DisposalListener());//Dispose监听器 //ListenerManager.Register(new InitializationListener());//初始化监听器 //ListenerManager.Register(new SupportInitializeListener());//Support初始化监听器 //ListenerManager.Register(new StartableListener());//启动停止监听器 //ListenerManager.Register(new SubscribeListener());//消息总线的订阅监听器 ListenerManager.Register(new InjectionListener(reinjectionManager));//注入监听器 //ListenerManager.Register(new MemberExportListener());//组件成员导出与注入监听器 //ListenerManager.Register(new AppSettingInjectionListener());//AppSetting注入监听器 }
public async Task <AuthorizeListenerResponse> Authorize(AuthorizeListenerRequest request) { var connectionId = Context.ConnectionId; var instance = ListenerManager.GetInstance(); var tokenManager = TokenManager.GetInstance(); var roomId = tokenManager.GetTokenInfo(request.Token); if (roomId == null) { return new AuthorizeListenerResponse() { IsSuccess = false } } ; tokenManager.RemoveToken(request.Token); //// Broadcasterも立ち入り禁止になる... //using (var db = new ApplicationDbContext()) //{ // var room = await db.Rooms.Where(c => c.Name == roomId).SingleOrDefaultAsync(); // if (room == null || !room.IsLive) // return new AuthorizeListenerResponse() // { // IsSuccess = false // }; //} // OKならDBに登録(IsOpening=True) var result = await instance.RegisterListener(connectionId, roomId); if (result) { await this.Groups.Add(connectionId, roomId); return(new AuthorizeListenerResponse() { IsSuccess = true }); } else { return(new AuthorizeListenerResponse() { IsSuccess = false }); } }
public UpdateCursorRequest GetSessionCursor(GetCursorRequest request) { var connectionId = Context.ConnectionId; var instance = ListenerManager.GetInstance(); if (instance.IsListener(connectionId)) { var info = instance.GetConnectionInfo(connectionId); var roomInstance = RoomManager.GetInstance(); var room = roomInstance.GetRoomInfo(info.RoomId); return(room?.GetSession(request.Id)?.GetCursor() ?? null); } return(null); }
private void Finish() { var finishedSegment = _segment.Finish(IsLimitMechanismWorking()); if (!_segment.HasRef && _segment.IsSingleSpanSegment) { if (!_sampler.TrySampling()) { finishedSegment.IsIgnore = true; } } ListenerManager.NotifyFinish(finishedSegment); }
public UpdateBroadcastStatusNotification GetRoomStatus() { var connectionId = Context.ConnectionId; var instance = ListenerManager.GetInstance(); if (instance.IsListener(connectionId)) { var info = instance.GetConnectionInfo(connectionId); var roomInstance = RoomManager.GetInstance(); var room = roomInstance.GetRoomInfo(info.RoomId); return(room?.GetRoomStatus() ?? null); } return(null); }
public void Dispose() { try { listenerManager.StopListener(); listenerManager = null; } catch (Exception ex) { myFireAlarm.ActivateFireAlarm("Error in OpsGridManager Dispose " + ex.Message); throw new Exception("An error occurred while disposing the trade update Message Listener." + Environment.NewLine + "Error CNF-364 in " + PROJ_FILE_NAME + ".Dispose(): " + ex.Message); } }
public AppendSessionNotification GetSessionInfo(GetSessionRequest request) { var connectionId = Context.ConnectionId; var instance = ListenerManager.GetInstance(); if (instance.IsListener(connectionId)) { var info = instance.GetConnectionInfo(connectionId); var roomInstance = RoomManager.GetInstance(); var room = roomInstance.GetRoomInfo(info.RoomId); return(room?.GetSession(request.Id)?.GetSessionInfo() ?? null); } return(null); }
public void StopSpan(ISpan span) { _spans.TryPop(out _); if (_spans.Count == 0) { ListenerManager.NotifyFinish(this); foreach (var item in Properties) { if (item.Value is IDisposable disposable) { disposable.Dispose(); } } } }
public void StopSpan(ISpan span, string activityId) { _spans.TryRemove(activityId, out _); if (_spans.Count == 0) { ListenerManager.NotifyFinish(this); foreach (var item in Properties) { if (item.Value is IDisposable disposable) { disposable.Dispose(); } } } }
public static void Start() { var processes = Process.GetProcessesByName("jarvis"); var p = Process.GetCurrentProcess(); foreach (var process in processes.Where(process => p.Id != process.Id)) { process.Kill(); } Awake = true; Settings = new Settings(); Pipe = new Pipe(); //Bot.loadSettings(); //Bot.loadAIMLFromFiles(); //Listeners ListenerManager = new ListenerManager(Pipe); //Legacy Command Support typeof(ICommand).Assembly .GetTypes() .Where(o => o.GetInterface(typeof(ICommand).FullName) != null && o.IsClass) .Select(source => (ICommand)Activator.CreateInstance(source)).ToList() .ForEach(o => Brain.Pipe.Listen((input, match, listener) => { foreach (var r in o.Handle(input, match, listener)) { listener.Output(r); } }, o.Regexes)); //Tickers typeof(TickerBase).Assembly .GetTypes() .Where(o => o.BaseType == typeof(TickerBase)) .Where(o => o.GetConstructors().Any(x => x.GetParameters().Length == 0)) .Select(source => (TickerBase)Activator.CreateInstance(source)).ToList() .ForEach(o => o.Start()); foreach (var rss in Brain.Settings.RSS) { new RssTicker(rss).Start(); } }
public static void Main(string[] args) { var testIt = new TestIt(); //Restart check Device Manager //testIt.RestartSystemAndCheckDeviceName(); //Restart check MP+ //testIt.RestartSystemAndCheckDeviceRecognition(); //Console.ReadKey(); //return; var om = OpenListener(); if (!testIt.IsNeededRunCmdDirectly(args)) { testIt.ShowTopMenu(); } Console.ReadKey(); ListenerManager.GetListener().Stop(); }
private void Finish() { var finishedSegment = _segment.Finish(IsLimitMechanismWorking()); if (!_segment.HasRef && _segment.IsSingleSpanSegment) { if (!_sampler.Sampled()) { finishedSegment.IsIgnore = true; } } ListenerManager.NotifyFinish(finishedSegment); foreach (var item in Properties) { if (item.Value is IDisposable disposable) { disposable.Dispose(); } } }
public override Task OnDisconnected(bool stopCalled) { var connectionId = Context.ConnectionId; var instance = ListenerManager.GetInstance(); if (instance.IsListener(connectionId)) { var result = instance.RemoveListener(connectionId); result.Wait(); if (!result.IsCanceled && result.Result != null) { try { this.Groups.Remove(connectionId, result.Result).Wait(); } catch (Exception ex) { // Task Cancel Exception } } } return(base.OnDisconnected(stopCalled)); }
private static void Run(string[] args) { // ignore all certs ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; // parse program flags if (!CommandLineFlagManager.Parse(args)) { return; } AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; _log.Trace($"Initiating Ghosts startup - Local time: {DateTime.Now.TimeOfDay} UTC: {DateTime.UtcNow.TimeOfDay}"); //load configuration try { Program.Configuration = ClientConfigurationLoader.Config; } catch (Exception e) { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var o = $"Exec path: {path} - configuration 404: {ApplicationDetails.ConfigurationFiles.Application} - exiting. Exception: {e}"; _log.Fatal(o); Console.WriteLine(o, Color.Red); Console.ReadLine(); return; } //catch any stray processes running and avoid duplication of jobs running //StartupTasks.CleanupProcesses(); //make sure ghosts starts when machine starts StartupTasks.SetStartup(); ListenerManager.Run(); //check id _log.Trace(Comms.CheckId.Id); ////connect to command server for updates and sending logs Comms.Updates.Run(); //TODO? should these clients do a local survey? //if (Configuration.Survey.IsEnabled) //{ // try // { // Survey.SurveyManager.Run(); // } // catch (Exception exc) // { // _log.Error(exc); // } //} if (Configuration.HealthIsEnabled) { try { var h = new Health.Check(); h.Run(); } catch (Exception exc) { _log.Error(exc); } } if (Configuration.HandlersIsEnabled) { try { var o = new Orchestrator(); o.Run(); } catch (Exception exc) { _log.Error(exc); } } new ManualResetEvent(false).WaitOne(); }
public ServiceAdapter() { listenMgr = new ListenerManager { Owner = this }; }
private static void Run(string[] args) { //handle flags if (args.ToList().Contains("--version")) { //handle version flag and return ghosts and referenced assemblies information Console.WriteLine($"{ApplicationDetails.Name}:{ApplicationDetails.Version}"); foreach (var assemblyName in Assembly.GetExecutingAssembly().GetReferencedAssemblies()) { Console.WriteLine($"{assemblyName.Name}: {assemblyName.Version}"); } return; } #if DEBUG Program.IsDebug = true; #endif if (args.ToList().Contains("--debug") || Program.IsDebug) { Program.IsDebug = true; Console.WriteLine($"GHOSTS ({ApplicationDetails.Name}:{ApplicationDetails.Version}) running in debug mode. Installed path: {ApplicationDetails.InstalledPath}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.Application} == {File.Exists(ApplicationDetails.ConfigurationFiles.Application)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.Dictionary} == {File.Exists(ApplicationDetails.ConfigurationFiles.Dictionary)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.EmailContent} == {File.Exists(ApplicationDetails.ConfigurationFiles.EmailContent)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.EmailReply} == {File.Exists(ApplicationDetails.ConfigurationFiles.EmailReply)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.EmailsDomain} == {File.Exists(ApplicationDetails.ConfigurationFiles.EmailsDomain)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.EmailsOutside} == {File.Exists(ApplicationDetails.ConfigurationFiles.EmailsOutside)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.Health} == {File.Exists(ApplicationDetails.ConfigurationFiles.Health)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.Timeline} == {File.Exists(ApplicationDetails.ConfigurationFiles.Timeline)}"); Console.WriteLine($"{ApplicationDetails.InstanceFiles.Id} == {File.Exists(ApplicationDetails.InstanceFiles.Id)}"); Console.WriteLine($"{ApplicationDetails.InstanceFiles.FilesCreated} == {File.Exists(ApplicationDetails.InstanceFiles.FilesCreated)}"); Console.WriteLine($"{ApplicationDetails.InstanceFiles.SurveyResults} == {File.Exists(ApplicationDetails.InstanceFiles.SurveyResults)}"); Console.WriteLine($"{ApplicationDetails.LogFiles.ClientUpdates} == {File.Exists(ApplicationDetails.LogFiles.ClientUpdates)}"); } else { Console.WriteLine($"GHOSTS ({ApplicationDetails.Name}:{ApplicationDetails.Version}) running in production mode. Installed path: {ApplicationDetails.InstalledPath}"); } // ignore all certs ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; //attach handler for shutdown tasks AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); _log.Trace($"Initiating Ghosts startup - Local time: {DateTime.Now.TimeOfDay} UTC: {DateTime.UtcNow.TimeOfDay}"); //load configuration try { Program.Configuration = ClientConfigurationLoader.Config; } catch (Exception e) { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var o = $"Exec path: {path} - configuration 404: {ApplicationDetails.ConfigurationFiles.Application} - exiting. Exception: {e}"; _log.Fatal(o); Console.WriteLine(o); Console.ReadLine(); return; } StartupTasks.CheckConfigs(); Thread.Sleep(500); //show window if debugging or if --debug flag passed in var handle = GetConsoleWindow(); if (!Program.IsDebug) { ShowWindow(handle, SwHide); //add hook to manage processes running in order to never tip a machine over StartupTasks.CleanupProcesses(); } //add ghosts to startup StartupTasks.SetStartup(); //add listener on a port or ephemeral file watch to handle ad hoc commands ListenerManager.Run(); //do we have client id? or is this first run? _log.Trace(Comms.CheckId.Id); //connect to command server for 1) client id 2) get updates and 3) sending logs/surveys Comms.Updates.Run(); //local survey gathers information such as drives, accounts, logs, etc. if (Configuration.Survey.IsEnabled) { try { Survey.SurveyManager.Run(); } catch (Exception exc) { _log.Error(exc); } } if (Configuration.HealthIsEnabled) { try { var h = new Health.Check(); h.Run(); } catch (Exception exc) { _log.Error(exc); } } //timeline processing if (Configuration.HandlersIsEnabled) { try { var o = new Orchestrator(); o.Run(); } catch (Exception exc) { _log.Error(exc); } } //ghosts singleton new ManualResetEvent(false).WaitOne(); }
public RemoteOS(string ip) { IP = ip; _requestApi = new RequestApi(IP, ListenerManager.GetListener().GetPort()); }
private void Finish() { var finishedSegment = _segment.Finish(); ListenerManager.NotifyFinish(finishedSegment); }
private static void Run(string[] args) { if (args.ToList().Contains("--version")) { Console.WriteLine(ApplicationDetails.Version); return; } #if DEBUG IsDebug = true; #endif if (args.ToList().Contains("--debug")) { Program.IsDebug = true; Console.WriteLine($"GHOSTS running in debug mode. Installed path: {ApplicationDetails.InstalledPath}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.Application} == {File.Exists(ApplicationDetails.ConfigurationFiles.Application)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.Dictionary} == {File.Exists(ApplicationDetails.ConfigurationFiles.Dictionary)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.EmailContent} == {File.Exists(ApplicationDetails.ConfigurationFiles.EmailContent)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.EmailReply} == {File.Exists(ApplicationDetails.ConfigurationFiles.EmailReply)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.EmailsDomain} == {File.Exists(ApplicationDetails.ConfigurationFiles.EmailsDomain)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.EmailsOutside} == {File.Exists(ApplicationDetails.ConfigurationFiles.EmailsOutside)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.Health} == {File.Exists(ApplicationDetails.ConfigurationFiles.Health)}"); Console.WriteLine($"{ApplicationDetails.ConfigurationFiles.Timeline} == {File.Exists(ApplicationDetails.ConfigurationFiles.Timeline)}"); Console.WriteLine($"{ApplicationDetails.InstanceFiles.Id} == {File.Exists(ApplicationDetails.InstanceFiles.Id)}"); Console.WriteLine($"{ApplicationDetails.InstanceFiles.FilesCreated} == {File.Exists(ApplicationDetails.InstanceFiles.FilesCreated)}"); Console.WriteLine($"{ApplicationDetails.InstanceFiles.SurveyResults} == {File.Exists(ApplicationDetails.InstanceFiles.SurveyResults)}"); Console.WriteLine($"{ApplicationDetails.LogFiles.ClientUpdates} == {File.Exists(ApplicationDetails.LogFiles.ClientUpdates)}"); } else { Console.WriteLine($"GHOSTS running in production mode. Installed path: {ApplicationDetails.InstalledPath}"); } AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); _log.Trace($"Initiating Ghosts startup - Local time: {DateTime.Now.TimeOfDay} UTC: {DateTime.UtcNow.TimeOfDay}"); //load configuration try { Program.Configuration = ClientConfigurationLoader.Config; } catch (Exception e) { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var o = $"Exec path: {path} - configuration 404: {ApplicationDetails.ConfigurationFiles.Application} - exiting. Exception: {e}"; _log.Fatal(o); Console.WriteLine(o); Console.ReadLine(); return; } //catch any stray processes running and avoid duplication of jobs running //StartupTasks.CleanupProcesses(); //make sure ghosts starts when machine starts StartupTasks.SetStartup(); ListenerManager.Run(); //check id _log.Trace(Comms.CheckId.Id); ////connect to command server for updates and sending logs Comms.Updates.Run(); //TODO? should these clients do a local survey? //if (Configuration.Survey.IsEnabled) //{ // try // { // Survey.SurveyManager.Run(); // } // catch (Exception exc) // { // _log.Error(exc); // } //} if (Configuration.HealthIsEnabled) { try { var h = new Health.Check(); h.Run(); } catch (Exception exc) { _log.Error(exc); } } if (Configuration.HandlersIsEnabled) { try { var o = new Orchestrator(); o.Run(); } catch (Exception exc) { _log.Error(exc); } } new ManualResetEvent(false).WaitOne(); }
private static void Run(string[] args) { // ignore all certs ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; // parse program flags if (!CommandLineFlagManager.Parse(args)) { return; } //attach handler for shutdown tasks AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; _log.Trace($"Initiating Ghosts startup - Local time: {DateTime.Now.TimeOfDay} UTC: {DateTime.UtcNow.TimeOfDay}"); //load configuration try { Configuration = ClientConfigurationLoader.Config; } catch (Exception e) { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var o = $"Exec path: {path} - configuration 404: {ApplicationDetails.ConfigurationFiles.Application} - exiting. Exception: {e}"; _log.Fatal(o); Console.WriteLine(o); Console.ReadLine(); return; } StartupTasks.CheckConfigs(); Thread.Sleep(500); //show window if debugging or if --debug flag passed in var handle = GetConsoleWindow(); if (!IsDebug) { ShowWindow(handle, SwHide); //add hook to manage processes running in order to never tip a machine over StartupTasks.CleanupProcesses(); } //add ghosts to startup StartupTasks.SetStartup(); //add listener on a port or ephemeral file watch to handle ad hoc commands ListenerManager.Run(); //do we have client id? or is this first run? _log.Trace(Comms.CheckId.Id); //connect to command server for 1) client id 2) get updates and 3) sending logs/surveys Comms.Updates.Run(); //local survey gathers information such as drives, accounts, logs, etc. if (Configuration.Survey.IsEnabled) { try { Survey.SurveyManager.Run(); } catch (Exception exc) { _log.Error(exc); } } if (Configuration.HealthIsEnabled) { try { var h = new Health.Check(); h.Run(); } catch (Exception exc) { _log.Error(exc); } } //timeline processing if (Configuration.HandlersIsEnabled) { try { var o = new Orchestrator(); o.Run(); } catch (Exception exc) { _log.Error(exc); } } //ghosts singleton new ManualResetEvent(false).WaitOne(); }
public HttpEngine() { HttpCharacters.Initialize(); _listenerManager = new ListenerManager(); _listenerManager.CreateListener(new IPEndPoint(IPAddress.Any, 80)); }