Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 8.6.0.2409 #615

Merged
merged 11 commits into from
Sep 16, 2024
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.

[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.

[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.

[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.

[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.

[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; }

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

View workflow job for this annotation

GitHub Actions / build

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

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 @@
using Synethia;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Net.NetworkInformation;
Expand All @@ -45,12 +46,12 @@
{

#if NIGHTLY
private static DateTime Date => System.IO.File.GetLastWriteTime(System.Reflection.Assembly.GetEntryAssembly().Location);

Check warning on line 49 in InternetTest/InternetTest/Classes/Global.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

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 @@
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;
}

}
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -41,7 +41,7 @@
<PackageReference Include="PeyrSharp.Core" Version="2.1.0.2312" />
<PackageReference Include="PeyrSharp.Env" Version="2.1.0.2312" />
<PackageReference Include="QRCoder" Version="1.6.0" />
<PackageReference Include="RestSharp" Version="111.4.1" />
<PackageReference Include="RestSharp" Version="112.0.0" />
<PackageReference Include="Synethia" Version="1.1.1.2302" />
<PackageReference Include="Whois" Version="3.0.1" />
</ItemGroup>
Expand Down
Loading
Loading