improve voice chat security by implementing join validation
This commit is contained in:
parent
2ca092b017
commit
1915198d82
7 changed files with 392 additions and 9 deletions
|
|
@ -13,6 +13,29 @@ public class Program
|
|||
public static async Task Main(string[] args)
|
||||
{
|
||||
await LoadEnv();
|
||||
|
||||
// Voice ticket sweeper: issued tickets live for 60s; remove expired
|
||||
// ones a minute later so nothing lingers in memory. Also prunes stale
|
||||
// per-IP auth rate-limit counters (they are written pre-HMAC-check,
|
||||
// so without pruning any scanner could grow the map forever).
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
await Task.Delay(30000);
|
||||
long cutoff = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - 120;
|
||||
foreach (var entry in VoiceTickets)
|
||||
{
|
||||
if (entry.Value.Exp < cutoff) VoiceTickets.TryRemove(entry.Key, out _);
|
||||
}
|
||||
long nowSec = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||
foreach (var entry in VoiceAuthLimits)
|
||||
{
|
||||
if (entry.Value.resetAt <= nowSec) VoiceAuthLimits.TryRemove(entry.Key, out _);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddHostedService<BackgroundDelete>();
|
||||
builder.Logging.ClearProviders();
|
||||
|
|
@ -95,6 +118,9 @@ public class Program
|
|||
context.Response.StatusCode = StatusCodes.Status400BadRequest;
|
||||
}
|
||||
return;
|
||||
case "/_larpix/voice/auth":
|
||||
await LarpixServer.Room.Shared.InternalVoiceAuth(context);
|
||||
return;
|
||||
case "/_larpix/serverinfo":
|
||||
ServerInfo serverInfo = new ServerInfo();
|
||||
serverInfo.domain = DOMAIN;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue