* Merge master in develop (#55)
* Fix reachable and IP leak test (#44)
* Fix reachable check
Fixes failing reachable checks when Basic Authentication is enabled in
Sonarr, Radarr, etc.
* Add option to disable IP leak test
* Revert "Fix reachable and IP leak test (#44)" (#46)
This reverts commit 3f5d7bbef3.
* Release 0.6.1 (#48)
* 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>
* Create Dockerfile.arm64
---------
Co-authored-by: akuntsch <github@akuntsch.de>
* Add configurable cache duration
* Make proxy port configurable
* Make proxy port configurable
* Add API Key auth
* Add default settings to appsettings
---------
Co-authored-by: akuntsch <github@akuntsch.de>
123 lines
4.5 KiB
C#
123 lines
4.5 KiB
C#
using System.Net;
|
|
using Serilog;
|
|
using Serilog.Filters;
|
|
using UmlautAdaptarr.Routing;
|
|
using UmlautAdaptarr.Services;
|
|
using UmlautAdaptarr.Services.Factory;
|
|
using UmlautAdaptarr.Utilities;
|
|
|
|
internal class Program
|
|
{
|
|
private static void Main(string[] args)
|
|
{
|
|
MainAsync(args).Wait();
|
|
}
|
|
|
|
private static async Task MainAsync(string[] args)
|
|
{
|
|
// TODO:
|
|
// add option to sort by nzb age
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
var configuration = builder.Configuration;
|
|
ConfigureLogger(configuration);
|
|
|
|
builder.Services.AddSerilog();
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddHttpClient("HttpClient").ConfigurePrimaryHttpMessageHandler(() =>
|
|
{
|
|
var handler = new HttpClientHandler
|
|
{
|
|
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate |
|
|
DecompressionMethods.Brotli
|
|
};
|
|
|
|
return handler;
|
|
});
|
|
|
|
builder.Services.AddMemoryCache(options =>
|
|
{
|
|
// TODO cache size limit? option?
|
|
//options.SizeLimit = 20000;
|
|
});
|
|
|
|
builder.Services.AllowResolvingKeyedServicesAsDictionary();
|
|
builder.Services.AddControllers();
|
|
builder.AddTitleLookupService();
|
|
builder.Services.AddSingleton<SearchItemLookupService>();
|
|
builder.Services.AddSingleton<TitleMatchingService>();
|
|
await builder.AddSonarrSupport();
|
|
await builder.AddLidarrSupport();
|
|
await builder.AddReadarrSupport();
|
|
builder.Services.AddSingleton<CacheService>();
|
|
builder.Services.AddSingleton<ProxyRequestService>();
|
|
builder.Services.AddSingleton<ArrApplicationFactory>();
|
|
builder.Services.AddHostedService<ArrSyncBackgroundService>();
|
|
builder.Services.AddSingleton<IHostedService, HttpProxyService>();
|
|
|
|
var app = builder.Build();
|
|
|
|
Helper.ShowLogo();
|
|
|
|
if (app.Configuration.GetValue<bool>("IpLeakTest:Enabled"))
|
|
{
|
|
await Helper.ShowInformation();
|
|
}
|
|
|
|
GlobalStaticLogger.Initialize(app.Services.GetService<ILoggerFactory>()!);
|
|
app.UseHttpsRedirection();
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllerRoute("caps",
|
|
"{apiKey}/{*domain}",
|
|
new { controller = "Caps", action = "Caps" },
|
|
new { t = new TRouteConstraint("caps") });
|
|
|
|
app.MapControllerRoute("movie-search",
|
|
"{apiKey}/{*domain}",
|
|
new { controller = "Search", action = "MovieSearch" },
|
|
new { t = new TRouteConstraint("movie") });
|
|
|
|
app.MapControllerRoute("tv-search",
|
|
"{apiKey}/{*domain}",
|
|
new { controller = "Search", action = "TVSearch" },
|
|
new { t = new TRouteConstraint("tvsearch") });
|
|
|
|
app.MapControllerRoute("music-search",
|
|
"{apiKey}/{*domain}",
|
|
new { controller = "Search", action = "MusicSearch" },
|
|
new { t = new TRouteConstraint("music") });
|
|
|
|
app.MapControllerRoute("book-search",
|
|
"{apiKey}/{*domain}",
|
|
new { controller = "Search", action = "BookSearch" },
|
|
new { t = new TRouteConstraint("book") });
|
|
|
|
app.MapControllerRoute("generic-search",
|
|
"{apiKey}/{*domain}",
|
|
new { controller = "Search", action = "GenericSearch" },
|
|
new { t = new TRouteConstraint("search") });
|
|
app.Run();
|
|
}
|
|
|
|
private static void ConfigureLogger(ConfigurationManager configuration)
|
|
{
|
|
Log.Logger = new LoggerConfiguration()
|
|
.ReadFrom.Configuration(configuration)
|
|
.WriteTo.Console(outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")
|
|
|
|
#if RELEASE
|
|
.Filter.ByExcluding(Matching.FromSource("Microsoft.AspNetCore.Mvc"))
|
|
.Filter.ByExcluding(Matching.FromSource("Microsoft.AspNetCore.Routing"))
|
|
.Filter.ByExcluding(Matching.FromSource("Microsoft.AspNetCore.Diagnostics"))
|
|
.Filter.ByExcluding(Matching.FromSource("Microsoft.AspNetCore.Hosting"))
|
|
#endif
|
|
|
|
// TODO workaround to not log api keys
|
|
.Filter.ByExcluding(Matching.FromSource("System.Net.Http.HttpClient"))
|
|
.Filter.ByExcluding(Matching.FromSource("Microsoft.Extensions.Http.DefaultHttpClientFactory"))
|
|
//.Enrich.With(new ApiKeyMaskingEnricher("appsettings.json")) // TODO - Not working currently
|
|
.CreateLogger();
|
|
}
|
|
}
|