From 0e38da4b583f0227beca3a3f870c395f152c507a Mon Sep 17 00:00:00 2001 From: vnugent Date: Sat, 14 Jan 2023 16:33:37 -0500 Subject: Utils updates --- lib/VNLib.Plugins.Extensions.VNCache/src/VnCacheClient.cs | 2 +- plugins/CacheBroker/src/Endpoints/BrokerRegistrationEndpoint.cs | 4 +++- plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs | 4 ++-- plugins/ObjectCacheServer/src/ObjectCacheServerEntry.cs | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/VNLib.Plugins.Extensions.VNCache/src/VnCacheClient.cs b/lib/VNLib.Plugins.Extensions.VNCache/src/VnCacheClient.cs index a34e611..bfab83e 100644 --- a/lib/VNLib.Plugins.Extensions.VNCache/src/VnCacheClient.cs +++ b/lib/VNLib.Plugins.Extensions.VNCache/src/VnCacheClient.cs @@ -105,7 +105,7 @@ namespace VNLib.Plugins.Extensions.VNCache Uri brokerUri = new(brokerAddress); //Init the client with default settings - FBMClientConfig conf = FBMDataCacheExtensions.GetDefaultConfig(ClientHeap ?? Memory.Shared, maxMessageSize, DebugLog); + FBMClientConfig conf = FBMDataCacheExtensions.GetDefaultConfig(ClientHeap ?? MemoryUtil.Shared, maxMessageSize, DebugLog); _client = new(conf); diff --git a/plugins/CacheBroker/src/Endpoints/BrokerRegistrationEndpoint.cs b/plugins/CacheBroker/src/Endpoints/BrokerRegistrationEndpoint.cs index 7867e97..c2e0b84 100644 --- a/plugins/CacheBroker/src/Endpoints/BrokerRegistrationEndpoint.cs +++ b/plugins/CacheBroker/src/Endpoints/BrokerRegistrationEndpoint.cs @@ -200,8 +200,10 @@ namespace VNLib.Plugins.Cache.Broker.Endpoints { //get a buffer to store data in using VnMemoryStream buffer = new(); + //Copy input stream to buffer - await inputStream.CopyToAsync(buffer, 4096, Memory.Shared); + await inputStream.CopyToAsync(buffer, 4096, MemoryUtil.Shared); + //Parse jwt return JsonWebToken.ParseRaw(buffer.AsSpan()); } diff --git a/plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs b/plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs index 2fe0994..15cc086 100644 --- a/plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs +++ b/plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs @@ -171,7 +171,7 @@ namespace VNLib.Plugins.Essentials.Sessions.Server.Endpoints auth.WriteHeader(cert.JwtHeader); auth.InitPayloadClaim() .AddClaim("aud", AudienceLocalServerId) - .AddClaim("exp", DateTimeOffset.UtcNow.Add(AuthTokenExpiration).ToUnixTimeSeconds()) + .AddClaim("exp", entity.RequestedTimeUtc.Add(AuthTokenExpiration).ToUnixTimeSeconds()) .AddClaim("nonce", RandomHash.GetRandomBase32(8)) .AddClaim("chl", challenge!) //Set the ispeer flag if the request was signed by a cache server @@ -279,7 +279,7 @@ namespace VNLib.Plugins.Essentials.Sessions.Server.Endpoints } if (!doc.RootElement.TryGetProperty("exp", out JsonElement expEl) - || DateTimeOffset.FromUnixTimeSeconds(expEl.GetInt64()) < DateTimeOffset.UtcNow) + || DateTimeOffset.FromUnixTimeSeconds(expEl.GetInt64()) < entity.RequestedTimeUtc) { entity.CloseResponse(HttpStatusCode.Unauthorized); return VfReturnType.VirtualSkip; diff --git a/plugins/ObjectCacheServer/src/ObjectCacheServerEntry.cs b/plugins/ObjectCacheServer/src/ObjectCacheServerEntry.cs index 85a7996..7b7b9fb 100644 --- a/plugins/ObjectCacheServer/src/ObjectCacheServerEntry.cs +++ b/plugins/ObjectCacheServer/src/ObjectCacheServerEntry.cs @@ -74,7 +74,7 @@ namespace VNLib.Plugins.Essentials.Sessions.Server protected override void OnLoad() { //Create default heap - IUnmangedHeap CacheHeap = Memory.InitializeNewHeapForProcess(); + IUnmangedHeap CacheHeap = MemoryUtil.InitializeNewHeapForProcess(); try { IReadOnlyDictionary clusterConf = this.GetConfig("cluster"); -- cgit