Skip to content

Commit 50a05ea

Browse files
authored
Fixed ffmpeg version not beeing evaluated on test data get
Added Reverse proxy lookup support
1 parent 4cd76c3 commit 50a05ea

File tree

6 files changed

+49
-7
lines changed

6 files changed

+49
-7
lines changed

.vscode/launch.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "blazorwasm",
77
"request": "launch",
88
"hosted": true,
9-
"preLaunchTask": "build dotnet",
9+
"preLaunchTask": "build",
1010
"program": "${workspaceFolder}/Jellyfin.HardwareVisualizer/Server/bin/Debug/net8.0/Jellyfin.HardwareVisualizer.Server.dll",
1111
"cwd": "${workspaceFolder}/Jellyfin.HardwareVisualizer",
1212
"internalConsoleOptions": "openOnSessionStart",
@@ -16,7 +16,8 @@
1616
"PG_PASSWORD": "jellyfin",
1717
"PG_HOST": "localhost",
1818
"PG_PORT": "5432",
19-
"PG_DATABASE": "Jellyfin.HardwareVisualizer"
19+
"PG_DATABASE": "Jellyfin.HardwareVisualizer",
20+
"HOSTING_KnownProxies__0": "172.18.0.2"
2021
},
2122
"url": "https://localhost:5001"
2223
},

.vscode/tasks.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424
"/consoleloggerparameters:NoSummary;ForceNoAlign"
2525
],
2626
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"type": "dotnet",
30+
"task": "build",
31+
"group": {
32+
"kind": "build",
33+
"isDefault": true
34+
},
35+
"problemMatcher": [],
36+
"label": "dotnet: build"
2737
}
2838
],
2939
"options": {

Jellyfin.HardwareVisualizer/Server/Configuration/EFCoreOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@ public class EFCoreOptions
1010
public string Host { get; set; }
1111
public int Port { get; set; }
1212
public string Database { get; set; }
13+
}
14+
15+
[FromConfig("HOSTING")]
16+
public class HostingOptions
17+
{
18+
public List<string> KnownProxies { get; set; } = new();
1319
}

Jellyfin.HardwareVisualizer/Server/Program.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Octokit;
2020
using Octokit.Internal;
2121
using ProductHeaderValue = Octokit.ProductHeaderValue;
22+
using System.Net;
2223

2324
namespace Jellyfin.HardwareVisualizer.Server;
2425

@@ -30,7 +31,8 @@ public static void Main(string[] args)
3031
builder.Configuration
3132
.AddEnvironmentVariables("PG_")
3233
.AddEnvironmentVariables("JF_")
33-
.AddEnvironmentVariables("GH_");
34+
.AddEnvironmentVariables("GH_")
35+
.AddEnvironmentVariables("HOSTING_");
3436
// Add services to the container.
3537

3638

@@ -71,6 +73,23 @@ string GetConnectionString()
7173
.UsePostgreSqlStorage(f => f.UseNpgsqlConnection(() => GetConnectionString()))
7274
);
7375

76+
builder.Services.Configure<ForwardedHeadersOptions>(options =>
77+
{
78+
var envVar = Environment.GetEnvironmentVariables();
79+
var hostingOptions = builder.Configuration.Get<HostingOptions>();
80+
81+
options.ForwardLimit = 2;
82+
foreach(var proxy in hostingOptions.KnownProxies ?? [])
83+
{
84+
options.KnownProxies.Add(IPAddress.Parse(proxy));
85+
}
86+
87+
// options.KnownProxies.Add(IPAddress.Parse("172.18.0.2"));
88+
// options.KnownProxies.Add(IPAddress.Parse("172.19.0.9"));
89+
options.ForwardedForHeaderName = "X-Forwarded-For";
90+
});
91+
92+
7493
builder.Services.AddRateLimiter(_ => _.AddFixedWindowLimiter("fixed_submit", options =>
7594
{
7695
options.PermitLimit = 1;
@@ -191,7 +210,8 @@ string GetConnectionString()
191210
});
192211

193212
var app = builder.Build();
194-
213+
app.UseForwardedHeaders();
214+
195215
using (var scope = app.Services.CreateScope())
196216
{
197217
var services = scope.ServiceProvider;

Jellyfin.HardwareVisualizer/Server/Properties/launchSettings.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"PG_PASSWORD": "jellyfin",
1010
"PG_HOST": "localhost",
1111
"PG_PORT": "5432",
12-
"PG_DATABASE": "Jellyfin.HardwareVisualizer"
12+
"PG_DATABASE": "Jellyfin.HardwareVisualizer",
13+
"HOSTING_KnownProxies__0": "172.18.0.2"
1314
},
1415
"dotnetRunMessages": true,
1516
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
@@ -24,7 +25,8 @@
2425
"PG_PASSWORD": "jellyfin",
2526
"PG_HOST": "localhost",
2627
"PG_PORT": "5432",
27-
"PG_DATABASE": "Jellyfin.HardwareVisualizer"
28+
"PG_DATABASE": "Jellyfin.HardwareVisualizer",
29+
"HOSTING_KnownProxies": "172.18.0.2"
2830
},
2931
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
3032
},

Jellyfin.HardwareVisualizer/Server/Services/TestData/TestDataService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ public async Task<Platform[]> GetPlatforms(CancellationToken stopToken)
4040
}
4141

4242
var testFiles = await db.MediaTestFiles.Include(e => e.TestCases).ToArrayAsync(cancellationToken);
43-
var testArguments = await db.TestCaseArguments.Include(testCaseArgument => testCaseArgument.HardwareCodec).ToArrayAsync(cancellationToken);
43+
var testArguments = await db.TestCaseArguments
44+
.Include(testCaseArgument => testCaseArgument.HardwareCodec)
45+
.Where(e => e.FfmpegVersionGroupId == ffmpegForPlatform.VersionGroup)
46+
.ToArrayAsync(cancellationToken);
4447

4548
var model = new TestDataRequestModel();
4649
model.Ffmpeg = _mapperService.ViewModelMapper.Map<FfmpegModel>(ffmpegForPlatform);

0 commit comments

Comments
 (0)