Skip to content

Commit

Permalink
Merge pull request #615 from Leo-Corporation/vNext
Browse files Browse the repository at this point in the history
Version 8.6.0.2409
  • Loading branch information
lpeyr authored Sep 16, 2024
2 parents fd616f7 + c35b114 commit 6520111
Show file tree
Hide file tree
Showing 15 changed files with 883 additions and 191 deletions.
78 changes: 78 additions & 0 deletions InternetTest/InternetTest/Classes/DnsCacheInfo.cs
Original file line number Diff line number Diff line change
@@ -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; }

Check warning on line 36 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Caption' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 36 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Caption' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[JsonPropertyName("Description")]
public object Description { get; set; }

Check warning on line 39 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Description' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 39 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Description' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[JsonPropertyName("ElementName")]
public string ElementName { get; set; }

Check warning on line 42 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'ElementName' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 42 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'ElementName' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[JsonPropertyName("InstanceID")]
public object InstanceId { get; set; }

Check warning on line 45 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'InstanceId' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 45 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'InstanceId' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[JsonPropertyName("Data")]
public string Data { get; set; }

Check warning on line 48 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Data' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

Check warning on line 48 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Data' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[JsonPropertyName("DataLength")]
public long DataLength { get; set; }

[JsonPropertyName("Entry")]
public string Entry { get; set; }

Check warning on line 54 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Entry' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[JsonPropertyName("Name")]
public string Name { get; set; }

Check warning on line 57 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[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<DnsCacheInfo[]>(json);

Check warning on line 77 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 77 in InternetTest/InternetTest/Classes/DnsCacheInfo.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.
}
41 changes: 39 additions & 2 deletions InternetTest/InternetTest/Classes/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -635,4 +636,40 @@ public static string GetCurrentWifiSSID()
return null;
}

public static async Task<DnsCacheInfo[]> 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<string> 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;
}

}
2 changes: 1 addition & 1 deletion InternetTest/InternetTest/InternetTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<UseWindowsForms>True</UseWindowsForms>
<Version>8.5.2.2408</Version>
<Version>8.6.0.2409</Version>
<Copyright>© 2024</Copyright>
<Company>Léo Corporation</Company>
<Description>Taking you to another level. InternetTest can locate IP addresses, send ping request, recover your WiFi passwords and more!</Description>
Expand Down
Loading

0 comments on commit 6520111

Please sign in to comment.