Features: - Version dropdown in single/ZIP upload (9.3.0, 9.2.0, etc.) - Patch-compatible matching (9.3.x assets work with 9.3.0) - manifest.json/xml support for automatic metadata detection - Smart category auto-detection from folder structure - Version field stored in GameAssets table Manifest support: - JSON format with gameVersion, category, assets array - Per-file metadata overrides (type, required, description) - Auto-detect falls back if no manifest present - See ASSET-MANIFEST-SPECIFICATION.md for full spec Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
101 lines
3.4 KiB
C#
101 lines
3.4 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
using RR3CommunityServer.Data;
|
|
using RR3CommunityServer.Services;
|
|
using RR3CommunityServer.Middleware;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container
|
|
builder.Services.AddControllers();
|
|
builder.Services.AddRazorPages(); // Add Razor Pages support
|
|
|
|
// Add cookie authentication
|
|
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
|
.AddCookie(options =>
|
|
{
|
|
options.LoginPath = "/Login";
|
|
options.LogoutPath = "/Logout";
|
|
options.AccessDeniedPath = "/Login";
|
|
options.ExpireTimeSpan = TimeSpan.FromDays(30);
|
|
options.SlidingExpiration = true;
|
|
});
|
|
|
|
builder.Services.AddAuthorization();
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
// Database
|
|
builder.Services.AddDbContext<RR3DbContext>(options =>
|
|
options.UseSqlite("Data Source=rr3community.db"));
|
|
|
|
// Custom services
|
|
builder.Services.AddScoped<ISessionService, SessionService>();
|
|
builder.Services.AddScoped<IUserService, UserService>();
|
|
builder.Services.AddScoped<ICatalogService, CatalogService>();
|
|
builder.Services.AddScoped<IDrmService, DrmService>();
|
|
builder.Services.AddScoped<IAuthService, AuthService>();
|
|
builder.Services.AddScoped<AssetExtractionService>();
|
|
|
|
// Add HttpClient for URL downloads
|
|
builder.Services.AddHttpClient();
|
|
|
|
// CORS for cross-origin requests
|
|
builder.Services.AddCors(options =>
|
|
{
|
|
options.AddDefaultPolicy(policy =>
|
|
{
|
|
policy.AllowAnyOrigin()
|
|
.AllowAnyMethod()
|
|
.AllowAnyHeader();
|
|
});
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
// Initialize database
|
|
using (var scope = app.Services.CreateScope())
|
|
{
|
|
var db = scope.ServiceProvider.GetRequiredService<RR3DbContext>();
|
|
db.Database.EnsureCreated();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseCors();
|
|
|
|
// Authentication & Authorization
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
|
|
// Custom middleware
|
|
app.UseMiddleware<SynergyHeadersMiddleware>();
|
|
app.UseMiddleware<SessionValidationMiddleware>();
|
|
|
|
app.MapControllers();
|
|
app.MapRazorPages(); // Add Razor Pages routing
|
|
|
|
// Redirect root to login page
|
|
app.MapGet("/", () => Results.Redirect("/Login"));
|
|
|
|
Console.WriteLine("╔══════════════════════════════════════════════════════════╗");
|
|
Console.WriteLine("║ Real Racing 3 Community Server - RUNNING ║");
|
|
Console.WriteLine("╠══════════════════════════════════════════════════════════╣");
|
|
Console.WriteLine("║ Server is ready to accept connections ║");
|
|
Console.WriteLine("║ Ensure DNS/hosts file points EA servers to this IP ║");
|
|
Console.WriteLine("╚══════════════════════════════════════════════════════════╝");
|
|
Console.WriteLine();
|
|
Console.WriteLine("Listening on: https://localhost:5001");
|
|
Console.WriteLine("Director endpoint: /director/api/android/getDirectionByPackage");
|
|
Console.WriteLine();
|
|
|
|
app.Run();
|
|
|