Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
64e025d9f7 | |||
09bc23a739 |
@@ -1,3 +1,4 @@
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using VirtualDDNSRouter.Server.Interfaces;
|
||||
using VirtualDDNSRouter.Server.Services;
|
||||
using Route = VirtualDDNSRouter.Server.Models.Route;
|
||||
@@ -12,6 +13,12 @@ builder.Services.AddOpenApi();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions
|
||||
{
|
||||
ForwardedHeaders = ForwardedHeaders.XForwardedFor |
|
||||
ForwardedHeaders.XForwardedProto
|
||||
});
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
@@ -35,12 +42,21 @@ app.MapGet("/setip/{path}/{port}/{apiKey}", async (IYamlParser yamlParser ,HttpC
|
||||
app.Logger.LogInformation($"Could not get the client ip address for {path} with port {port}.");
|
||||
return Results.BadRequest("Could not get the client ip address");
|
||||
}
|
||||
routes.Add(new Route
|
||||
var existingRoute = routes.FirstOrDefault(r => r.path == path);
|
||||
if (existingRoute is not null)
|
||||
{
|
||||
ipAddress = clientIp,
|
||||
path = path,
|
||||
port = port
|
||||
});
|
||||
existingRoute.ipAddress = clientIp;
|
||||
existingRoute.port = port;
|
||||
}
|
||||
else
|
||||
{
|
||||
routes.Add(new Route
|
||||
{
|
||||
ipAddress = clientIp,
|
||||
path = path,
|
||||
port = port
|
||||
});
|
||||
}
|
||||
return Results.Ok($"goto/{path}");
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user