Try to fix boardcasting with Antigravity.

This commit is contained in:
Creeper Lv
2026-06-01 17:11:09 +10:00
parent 78a99dc279
commit 9decde570f
5 changed files with 197 additions and 123 deletions
+5 -7
View File
@@ -50,25 +50,23 @@ public static class AuthHelper
public static bool IsServerTokenValid(HttpContext context, PeerCache peerCache)
{
var serverUrl = context.Request.Headers["X-Server-Url"].ToString().Trim().TrimEnd('/');
var serverId = context.Request.Headers["X-Server-Id"].ToString().Trim();
var serverToken = context.Request.Headers["X-Server-Token"].ToString();
if (string.IsNullOrEmpty(serverUrl) || string.IsNullOrEmpty(serverToken))
if (string.IsNullOrEmpty(serverId) || string.IsNullOrEmpty(serverToken))
{
return false;
}
// 1. Verify if it's a handshaked downstream peer calling us (upstream verification)
if (peerCache.VerifySessionToken(serverUrl, serverToken))
if (peerCache.VerifySessionToken(serverId, serverToken))
{
return true;
}
// 2. Verify if it's our configured upstream calling us (downstream verification)
var configuration = context.RequestServices.GetRequiredService<IConfiguration>();
var destUrl = (configuration["Sync:DestinationServerUrl"] ?? "").Trim().TrimEnd('/');
if (!string.IsNullOrEmpty(destUrl) && string.Equals(serverUrl, destUrl, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrEmpty(SyncEndpoints.UpstreamServerGuid) &&
string.Equals(serverId, SyncEndpoints.UpstreamServerGuid, StringComparison.OrdinalIgnoreCase))
{
// The request is coming from our upstream. Verify the token matches the one we received during handshake!
if (!string.IsNullOrEmpty(SyncEndpoints.UpstreamSessionToken) &&