diff --git a/InternetTest/InternetTest/Classes/DnsCacheInfo.cs b/InternetTest/InternetTest/Classes/DnsCacheInfo.cs new file mode 100644 index 0000000..889d925 --- /dev/null +++ b/InternetTest/InternetTest/Classes/DnsCacheInfo.cs @@ -0,0 +1,78 @@ +/* +MIT License + +Copyright (c) Léo Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +using System.Text.Json.Serialization; +using System.Text.Json; + +namespace InternetTest.Classes; + +public partial class DnsCacheInfo +{ + [JsonPropertyName("TTL")] + public long Ttl { get; set; } + + [JsonPropertyName("Caption")] + public object Caption { get; set; } + + [JsonPropertyName("Description")] + public object Description { get; set; } + + [JsonPropertyName("ElementName")] + public string ElementName { get; set; } + + [JsonPropertyName("InstanceID")] + public object InstanceId { get; set; } + + [JsonPropertyName("Data")] + public string Data { get; set; } + + [JsonPropertyName("DataLength")] + public long DataLength { get; set; } + + [JsonPropertyName("Entry")] + public string Entry { get; set; } + + [JsonPropertyName("Name")] + public string Name { get; set; } + + [JsonPropertyName("Section")] + public long Section { get; set; } + + [JsonPropertyName("Status")] + public long Status { get; set; } + + [JsonPropertyName("TimeToLive")] + public long TimeToLive { get; set; } + + [JsonPropertyName("Type")] + public long Type { get; set; } + + [JsonPropertyName("PSComputerName")] + public object PsComputerName { get; set; } +} + +public partial class DnsCacheInfo +{ + public static DnsCacheInfo[] FromJson(string json) => JsonSerializer.Deserialize(json); +} \ No newline at end of file diff --git a/InternetTest/InternetTest/Classes/Global.cs b/InternetTest/InternetTest/Classes/Global.cs index 8a7ce43..4401de3 100644 --- a/InternetTest/InternetTest/Classes/Global.cs +++ b/InternetTest/InternetTest/Classes/Global.cs @@ -30,6 +30,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using Synethia; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Net.Http; using System.Net.NetworkInformation; @@ -47,10 +48,10 @@ public static class Global #if NIGHTLY private static DateTime Date => System.IO.File.GetLastWriteTime(System.Reflection.Assembly.GetEntryAssembly().Location); - public static string Version => $"8.5.2.2408-nightly{Date:yyMM.dd@HHmm}"; + public static string Version => $"8.6.0.2409-nightly{Date:yyMM.dd@HHmm}"; #else - public static string Version => "8.5.2.2408"; + public static string Version => "8.6.0.2409"; #endif public static string LastVersionLink => "https://raw.githubusercontent.com/Leo-Corporation/LeoCorp-Docs/master/Liens/Update%20System/InternetTest/7.0/Version.txt"; internal static string SynethiaPath => $@"{FileSys.AppDataPath}\Léo Corporation\InternetTest Pro\NewSynethiaConfig.json"; @@ -635,4 +636,40 @@ public static string GetCurrentWifiSSID() return null; } + public static async Task GetDnsCache() + { + // The PowerShell command to execute + string psCommand = "Get-DnsClientCache | ConvertTo-Json -Depth 4"; + + // Capture the JSON output asynchronously + string json = await RunPowerShellCommandAsync(psCommand); + return DnsCacheInfo.FromJson(json); + } + + public static async Task RunPowerShellCommandAsync(string psCommand) + { + // Create a new process to run PowerShell + ProcessStartInfo processInfo = new ProcessStartInfo + { + FileName = "powershell.exe", + Arguments = $"-Command \"{psCommand}\"", + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true + }; + + // Start the PowerShell process + using Process process = Process.Start(processInfo); + + // Asynchronously read the output from the process + string output = await process.StandardOutput.ReadToEndAsync(); + + // Wait for the process to complete asynchronously + await process.WaitForExitAsync(); + + // Return the JSON output + return output; + } + } \ No newline at end of file diff --git a/InternetTest/InternetTest/InternetTest.csproj b/InternetTest/InternetTest/InternetTest.csproj index 7d84147..fb19361 100644 --- a/InternetTest/InternetTest/InternetTest.csproj +++ b/InternetTest/InternetTest/InternetTest.csproj @@ -6,7 +6,7 @@ enable true True - 8.5.2.2408 + 8.6.0.2409 © 2024 Léo Corporation Taking you to another level. InternetTest can locate IP addresses, send ping request, recover your WiFi passwords and more! diff --git a/InternetTest/InternetTest/Pages/DnsPage.xaml b/InternetTest/InternetTest/Pages/DnsPage.xaml index b04da9f..6abde42 100644 --- a/InternetTest/InternetTest/Pages/DnsPage.xaml +++ b/InternetTest/InternetTest/Pages/DnsPage.xaml @@ -17,14 +17,10 @@ - - - - - + @@ -43,98 +39,75 @@ FontWeight="ExtraBold" /> - - - - - + + - + - - + FontSize="11" + FontWeight="ExtraBold" + Text="{x:Static lang:Resources.DNS}" /> - - + + + + + - - - - - - - - - - - - - - - + + + + + + +