* Fix typo * Fix typos * Fix typos * Fix typo * Clarify error message * Fix reachable and ipleak test (#47) * Fix reachable check Fixes failing reachable checks when Basic Authentication is enabled in Sonarr, Radarr, etc. * Add option to disable IP leak test --------- Co-authored-by: Jonas F <github@pcjones.de> * Add IpLeakTest environment variable to docker compose --------- Co-authored-by: akuntsch <github@akuntsch.de>
57 lines
2.3 KiB
C#
57 lines
2.3 KiB
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace UmlautAdaptarr.Utilities;
|
|
|
|
public static class Helper
|
|
{
|
|
public static void ShowLogo()
|
|
{
|
|
Console.WriteLine(
|
|
"\r\n _ _ _ _ ___ _ _ \r\n| | | | | | | | / _ \\ | | | | \r\n| | | |_ __ ___ | | __ _ _ _| |_/ /_\\ \\ __| | __ _ _ __ | |_ __ _ _ __ _ __ \r\n| | | | '_ ` _ \\| |/ _` | | | | __| _ |/ _` |/ _` | '_ \\| __/ _` | '__| '__|\r\n| |_| | | | | | | | (_| | |_| | |_| | | | (_| | (_| | |_) | || (_| | | | | \r\n \\___/|_| |_| |_|_|\\__,_|\\__,_|\\__\\_| |_/\\__,_|\\__,_| .__/ \\__\\__,_|_| |_| \r\n | | \r\n |_| \r\n");
|
|
}
|
|
|
|
public static async Task ShowInformation()
|
|
{
|
|
Console.WriteLine("--------------------------[IP Leak Test]-----------------------------");
|
|
var ipInfo = await GetPublicIpAddressInfoAsync();
|
|
|
|
if (ipInfo != null)
|
|
{
|
|
Console.WriteLine($"Your Public IP Address is '{ipInfo.Ip}'");
|
|
Console.WriteLine($"Hostname: {ipInfo.Hostname}");
|
|
Console.WriteLine($"City: {ipInfo.City}");
|
|
Console.WriteLine($"Region: {ipInfo.Region}");
|
|
Console.WriteLine($"Country: {ipInfo.Country}");
|
|
Console.WriteLine($"Provider: {ipInfo.Org}");
|
|
}
|
|
else
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
Console.WriteLine("Error: Could not retrieve public IP information.");
|
|
Console.ResetColor();
|
|
}
|
|
|
|
Console.WriteLine("--------------------------------------------------------------------");
|
|
}
|
|
|
|
|
|
private static async Task<IpInfo?> GetPublicIpAddressInfoAsync()
|
|
{
|
|
using var client = new HttpClient();
|
|
client.Timeout = TimeSpan.FromSeconds(10);
|
|
|
|
try
|
|
{
|
|
var response = await client.GetAsync("https://ipinfo.io/json");
|
|
response.EnsureSuccessStatusCode();
|
|
var content = await response.Content.ReadAsStringAsync();
|
|
return JsonSerializer.Deserialize<IpInfo>(content);
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|