Code cleanup

This commit is contained in:
pcjones
2024-09-04 19:30:31 +02:00
parent 4db26e374f
commit 238bd9cc60
6 changed files with 15 additions and 44 deletions

View File

@@ -11,8 +11,6 @@ internal class Program
{ {
private static void Main(string[] args) private static void Main(string[] args)
{ {
Helper.ShowLogo(); Helper.ShowLogo();
Helper.ShowInformation(); Helper.ShowInformation();
// TODO: // TODO:
@@ -26,11 +24,10 @@ internal class Program
.WriteTo.Console(outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}") .WriteTo.Console(outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")
.Filter.ByExcluding(Matching.FromSource("System.Net.Http.HttpClient")) .Filter.ByExcluding(Matching.FromSource("System.Net.Http.HttpClient"))
.Filter.ByExcluding(Matching.FromSource("Microsoft.Extensions.Http.DefaultHttpClientFactory")) .Filter.ByExcluding(Matching.FromSource("Microsoft.Extensions.Http.DefaultHttpClientFactory"))
//.Enrich.With(new ApiKeyMaskingEnricher("appsettings.json")) // Not Work currently //.Enrich.With(new ApiKeyMaskingEnricher("appsettings.json")) // TODO - Not working currently
.CreateLogger(); .CreateLogger();
builder.Services.AddSerilog(); builder.Services.AddSerilog();
// Add services to the container. // Add services to the container.

View File

@@ -10,7 +10,7 @@ namespace UmlautAdaptarr.Services
private readonly ILogger<HttpProxyService> _logger; private readonly ILogger<HttpProxyService> _logger;
private readonly int _proxyPort = 5006; // TODO move to appsettings.json private readonly int _proxyPort = 5006; // TODO move to appsettings.json
private readonly IHttpClientFactory _clientFactory; private readonly IHttpClientFactory _clientFactory;
private HashSet<string> _knownHosts = []; private readonly HashSet<string> _knownHosts = [];
private readonly object _hostsLock = new object(); private readonly object _hostsLock = new object();
@@ -34,7 +34,7 @@ namespace UmlautAdaptarr.Services
{ {
using var clientStream = new NetworkStream(clientSocket, ownsSocket: true); using var clientStream = new NetworkStream(clientSocket, ownsSocket: true);
var buffer = new byte[8192]; var buffer = new byte[8192];
var bytesRead = await clientStream.ReadAsync(buffer, 0, buffer.Length); var bytesRead = await clientStream.ReadAsync(buffer);
var requestString = Encoding.ASCII.GetString(buffer, 0, bytesRead); var requestString = Encoding.ASCII.GetString(buffer, 0, bytesRead);
if (requestString.StartsWith("CONNECT")) if (requestString.StartsWith("CONNECT"))
@@ -129,8 +129,8 @@ namespace UmlautAdaptarr.Services
var colonIndex = line.IndexOf(':'); var colonIndex = line.IndexOf(':');
if (colonIndex > 0) if (colonIndex > 0)
{ {
var key = line.Substring(0, colonIndex).Trim(); var key = line[..colonIndex].Trim();
var value = line.Substring(colonIndex + 1).Trim(); var value = line[(colonIndex + 1)..].Trim();
headers[key] = value; headers[key] = value;
} }
} }

View File

@@ -225,9 +225,9 @@ namespace UmlautAdaptarr.Services
} }
} }
private static string[] MissingGermanTagReleaseGroups = ["tvr"]; private static readonly string[] MissingGermanTagReleaseGroups = ["tvr"];
private static string[] HEVCInsteadOfx265TagReleaseGroups = ["eisbaer"]; private static readonly string[] HEVCInsteadOfx265TagReleaseGroups = ["eisbaer"];
private static string[] WrongTagsReleaseGroups = ["eisbaer"]; private static readonly string[] WrongTagsReleaseGroups = ["eisbaer"];
private static string FixBadReleaseNaming(string title, string seperator, ILogger<TitleMatchingService> logger) private static string FixBadReleaseNaming(string title, string seperator, ILogger<TitleMatchingService> logger)
{ {
var releaseGroup = GetReleaseGroup(title); var releaseGroup = GetReleaseGroup(title);

View File

@@ -9,13 +9,13 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.1" /> <PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.2" />
<PackageReference Include="IL.FluentValidation.Extensions.Options" Version="11.0.2" /> <PackageReference Include="IL.FluentValidation.Extensions.Options" Version="11.0.2" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" /> <PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" /> <PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -56,33 +56,3 @@ public static class Helper
} }
} }
} }
public class IpInfo
{
[JsonPropertyName("ip")]
public string Ip { get; set; }
[JsonPropertyName("hostname")]
public string Hostname { get; set; }
[JsonPropertyName("city")]
public string City { get; set; }
[JsonPropertyName("region")]
public string Region { get; set; }
[JsonPropertyName("country")]
public string Country { get; set; }
[JsonPropertyName("loc")]
public string Loc { get; set; }
[JsonPropertyName("org")]
public string Org { get; set; }
[JsonPropertyName("postal")]
public string Postal { get; set; }
[JsonPropertyName("timezone")]
public string Timezone { get; set; }
}

4
build_linux.bat Normal file
View File

@@ -0,0 +1,4 @@
@echo off
dotnet publish -c Release -r linux-x64 --self-contained
'dotnet publish -c Release -r linux-x64 --self-contained -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true
pause