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)
{
Helper.ShowLogo();
Helper.ShowInformation();
// TODO:
@@ -26,11 +24,10 @@ internal class Program
.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("Microsoft.Extensions.Http.DefaultHttpClientFactory"))
//.Enrich.With(new ApiKeyMaskingEnricher("appsettings.json")) // Not Work currently
//.Enrich.With(new ApiKeyMaskingEnricher("appsettings.json")) // TODO - Not working currently
.CreateLogger();
builder.Services.AddSerilog();
// Add services to the container.

View File

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

View File

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

View File

@@ -9,13 +9,13 @@
</PropertyGroup>
<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="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
</ItemGroup>
</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