Separate dashboard port, first-run password setup and default trusted proxies

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-11-14 17:21:49 +01:00
1 parent a34ff96490
commit c22d452720
25 files changed
+654 -109

No files matched your search

@@ -50,13 +50,38 @@ public sealed class ForwardedHeadersTests
ip.ShouldBe(sender);
}
private static async Task<IPAddress?> SendAsync(IPAddress remoteIp, params (string Name, string Value)[] headers)
[Theory]
[InlineData("172.19.0.3")]
[InlineData("10.1.2.3")]
[InlineData("192.168.1.2")]
[InlineData("127.0.0.1")]
[InlineData("fd00::2")]
public async Task Trusts_private_networks_by_default(string proxy)
{
var ip = await SendAsync(IPAddress.Parse(proxy), trustedProxy: null, ("X-Real-IP", Client));
ip.ShouldBe(IPAddress.Parse(Client));
}
[Fact]
public async Task Configured_proxies_replace_the_default_networks()
{
var sender = IPAddress.Parse("192.168.1.2");
var ip = await SendAsync(sender, ("X-Real-IP", Client));
ip.ShouldBe(sender);
}
private static Task<IPAddress?> SendAsync(IPAddress remoteIp, params (string Name, string Value)[] headers) =>
SendAsync(remoteIp, "172.18.0.0/16", headers);
private static async Task<IPAddress?> SendAsync(IPAddress remoteIp, string? trustedProxy, params (string Name, string Value)[] headers)
{
var configuration = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string?>
{
["Flypaper:Http:KnownHosts:0"] = "dashboard.lan",
["Flypaper:Http:TrustedProxies:0"] = "172.18.0.0/16"
["Flypaper:Http:TrustedProxies:0"] = trustedProxy
})
.Build();
@@ -78,6 +103,7 @@ public sealed class ForwardedHeadersTests
var httpContext = new DefaultHttpContext { RequestServices = services };
httpContext.Connection.RemoteIpAddress = remoteIp;
httpContext.Connection.LocalPort = 8081;
httpContext.Request.Host = new HostString("dashboard.lan");
httpContext.Request.Path = "/";
foreach (var (name, value) in headers)