From 8f8940b00b8518193852d465e6926254dc4244ab Mon Sep 17 00:00:00 2001 From: eqbot Date: Thu, 28 Aug 2025 16:39:42 -0700 Subject: [PATCH] replay changes for cleaning up remote configuration and no snap services --- .../Factories/PairHandlerFactory.cs | 6 +- .../PlayerData/Handlers/PairHandler.cs | 28 +-- MareSynchronos/PlayerData/Pairs/Pair.cs | 5 - MareSynchronos/Plugin.cs | 3 - .../CharaData/CharaDataCharacterHandler.cs | 25 +- MareSynchronos/Services/NoSnapService.cs | 226 ------------------ .../Services/RemoteConfigurationService.cs | 83 ------- MareSynchronos/UI/UISharedService.cs | 10 - .../WebAPI/AccountRegistrationService.cs | 18 +- MareSynchronos/WebAPI/SignalR/HubFactory.cs | 14 +- .../WebAPI/SignalR/TokenProvider.cs | 18 +- 11 files changed, 9 insertions(+), 427 deletions(-) delete mode 100644 MareSynchronos/Services/NoSnapService.cs delete mode 100644 MareSynchronos/Services/RemoteConfigurationService.cs diff --git a/MareSynchronos/PlayerData/Factories/PairHandlerFactory.cs b/MareSynchronos/PlayerData/Factories/PairHandlerFactory.cs index 145889a..0fadae8 100644 --- a/MareSynchronos/PlayerData/Factories/PairHandlerFactory.cs +++ b/MareSynchronos/PlayerData/Factories/PairHandlerFactory.cs @@ -27,14 +27,13 @@ public class PairHandlerFactory private readonly PluginWarningNotificationService _pluginWarningNotificationManager; private readonly PairAnalyzerFactory _pairAnalyzerFactory; private readonly VisibilityService _visibilityService; - private readonly NoSnapService _noSnapService; public PairHandlerFactory(ILoggerFactory loggerFactory, GameObjectHandlerFactory gameObjectHandlerFactory, IpcManager ipcManager, FileDownloadManagerFactory fileDownloadManagerFactory, DalamudUtilService dalamudUtilService, PluginWarningNotificationService pluginWarningNotificationManager, IHostApplicationLifetime hostApplicationLifetime, FileCacheManager fileCacheManager, MareMediator mareMediator, PlayerPerformanceService playerPerformanceService, ServerConfigurationManager serverConfigManager, PairAnalyzerFactory pairAnalyzerFactory, - MareConfigService configService, VisibilityService visibilityService, NoSnapService noSnapService) + MareConfigService configService, VisibilityService visibilityService) { _loggerFactory = loggerFactory; _gameObjectHandlerFactory = gameObjectHandlerFactory; @@ -50,13 +49,12 @@ public class PairHandlerFactory _pairAnalyzerFactory = pairAnalyzerFactory; _configService = configService; _visibilityService = visibilityService; - _noSnapService = noSnapService; } public PairHandler Create(Pair pair) { return new PairHandler(_loggerFactory.CreateLogger(), pair, _pairAnalyzerFactory.Create(pair), _gameObjectHandlerFactory, _ipcManager, _fileDownloadManagerFactory.Create(), _pluginWarningNotificationManager, _dalamudUtilService, _hostApplicationLifetime, - _fileCacheManager, _mareMediator, _playerPerformanceService, _serverConfigManager, _configService, _visibilityService, _noSnapService); + _fileCacheManager, _mareMediator, _playerPerformanceService, _serverConfigManager, _configService, _visibilityService); } } \ No newline at end of file diff --git a/MareSynchronos/PlayerData/Handlers/PairHandler.cs b/MareSynchronos/PlayerData/Handlers/PairHandler.cs index d12a347..26e3aee 100644 --- a/MareSynchronos/PlayerData/Handlers/PairHandler.cs +++ b/MareSynchronos/PlayerData/Handlers/PairHandler.cs @@ -32,7 +32,6 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase private readonly ServerConfigurationManager _serverConfigManager; private readonly PluginWarningNotificationService _pluginWarningNotificationManager; private readonly VisibilityService _visibilityService; - private readonly NoSnapService _noSnapService; private CancellationTokenSource? _applicationCancellationTokenSource = new(); private Guid _applicationId; private Task? _applicationTask; @@ -55,8 +54,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase FileCacheManager fileDbManager, MareMediator mediator, PlayerPerformanceService playerPerformanceService, ServerConfigurationManager serverConfigManager, - MareConfigService configService, VisibilityService visibilityService, - NoSnapService noSnapService) : base(logger, mediator) + MareConfigService configService, VisibilityService visibilityService) : base(logger, mediator) { Pair = pair; PairAnalyzer = pairAnalyzer; @@ -70,7 +68,6 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase _serverConfigManager = serverConfigManager; _configService = configService; _visibilityService = visibilityService; - _noSnapService = noSnapService; _visibilityService.StartTracking(Pair.Ident); @@ -319,24 +316,6 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase }); } - private void RegisterGposeClones() - { - var name = PlayerName; - if (name == null) - return; - _ = _dalamudUtil.RunOnFrameworkThread(() => - { - foreach (var actor in _dalamudUtil.GetGposeCharactersFromObjectTable()) - { - if (actor == null) continue; - var gposeName = actor.Name.TextValue; - if (!name.Equals(gposeName, StringComparison.Ordinal)) - continue; - _noSnapService.AddGposer(actor.ObjectIndex); - } - }); - } - private async Task UndoApplicationAsync(Guid applicationId = default) { Logger.LogDebug($"Undoing application of {Pair.UserPair}"); @@ -353,7 +332,6 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase { await _ipcManager.Penumbra.RemoveTemporaryCollectionAsync(Logger, applicationId, _penumbraCollection).ConfigureAwait(false); _penumbraCollection = Guid.Empty; - RegisterGposeClones(); } if (_dalamudUtil is { IsZoning: false, IsInCutscene: false } && !string.IsNullOrEmpty(name)) @@ -385,10 +363,6 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase } } } - else if (_dalamudUtil.IsInCutscene && !string.IsNullOrEmpty(name)) - { - _noSnapService.AddGposerNamed(name); - } } catch (Exception ex) { diff --git a/MareSynchronos/PlayerData/Pairs/Pair.cs b/MareSynchronos/PlayerData/Pairs/Pair.cs index b867564..1ca50bc 100644 --- a/MareSynchronos/PlayerData/Pairs/Pair.cs +++ b/MareSynchronos/PlayerData/Pairs/Pair.cs @@ -171,11 +171,6 @@ public class Pair : DisposableMediatorSubscriberBase if (_serverConfigurationManager.IsUidBlacklisted(UserData.UID)) HoldApplication("Blacklist", maxValue: 1); - if (NoSnapService.AnyLoaded) - HoldApplication("NoSnap", maxValue: 1); - else - UnholdApplication("NoSnap", skipApplication: true); - CachedPlayer.ApplyCharacterData(Guid.NewGuid(), RemoveNotSyncedFiles(LastReceivedCharacterData.DeepClone())!, forced); } diff --git a/MareSynchronos/Plugin.cs b/MareSynchronos/Plugin.cs index 8f4c101..a2486a1 100644 --- a/MareSynchronos/Plugin.cs +++ b/MareSynchronos/Plugin.cs @@ -142,7 +142,6 @@ public sealed class Plugin : IDalamudPlugin collection.AddSingleton(); collection.AddSingleton(); collection.AddSingleton(); - collection.AddSingleton(); collection.AddSingleton((s) => new MareConfigService(pluginInterface.ConfigDirectory.FullName)); collection.AddSingleton((s) => new ServerConfigService(pluginInterface.ConfigDirectory.FullName)); @@ -168,7 +167,6 @@ public sealed class Plugin : IDalamudPlugin collection.AddSingleton>(s => s.GetRequiredService()); collection.AddSingleton(); collection.AddSingleton(); - collection.AddSingleton(); collection.AddSingleton(); @@ -209,7 +207,6 @@ public sealed class Plugin : IDalamudPlugin collection.AddHostedService(p => p.GetRequiredService()); collection.AddHostedService(p => p.GetRequiredService()); collection.AddHostedService(p => p.GetRequiredService()); - collection.AddHostedService(p => p.GetRequiredService()); }) .Build(); diff --git a/MareSynchronos/Services/CharaData/CharaDataCharacterHandler.cs b/MareSynchronos/Services/CharaData/CharaDataCharacterHandler.cs index 21e390f..2b76ddf 100644 --- a/MareSynchronos/Services/CharaData/CharaDataCharacterHandler.cs +++ b/MareSynchronos/Services/CharaData/CharaDataCharacterHandler.cs @@ -13,20 +13,18 @@ public sealed class CharaDataCharacterHandler : DisposableMediatorSubscriberBase private readonly GameObjectHandlerFactory _gameObjectHandlerFactory; private readonly DalamudUtilService _dalamudUtilService; private readonly IpcManager _ipcManager; - private readonly NoSnapService _noSnapService; private readonly Dictionary _handledCharaData = new(StringComparer.Ordinal); public IReadOnlyDictionary HandledCharaData => _handledCharaData; public CharaDataCharacterHandler(ILogger logger, MareMediator mediator, GameObjectHandlerFactory gameObjectHandlerFactory, DalamudUtilService dalamudUtilService, - IpcManager ipcManager, NoSnapService noSnapService) + IpcManager ipcManager) : base(logger, mediator) { _gameObjectHandlerFactory = gameObjectHandlerFactory; _dalamudUtilService = dalamudUtilService; _ipcManager = ipcManager; - _noSnapService = noSnapService; mediator.Subscribe(this, msg => { foreach (var chara in _handledCharaData) @@ -94,7 +92,6 @@ public sealed class CharaDataCharacterHandler : DisposableMediatorSubscriberBase _handledCharaData.Remove(handled.Name); await _dalamudUtilService.RunOnFrameworkThread(async () => { - RemoveGposer(handled); await RevertChara(handled.Name, handled.CustomizePlus).ConfigureAwait(false); }).ConfigureAwait(false); return true; @@ -103,7 +100,6 @@ public sealed class CharaDataCharacterHandler : DisposableMediatorSubscriberBase internal void AddHandledChara(HandledCharaDataEntry handledCharaDataEntry) { _handledCharaData.Add(handledCharaDataEntry.Name, handledCharaDataEntry); - _ = _dalamudUtilService.RunOnFrameworkThread(() => AddGposer(handledCharaDataEntry)); } public void UpdateHandledData(Dictionary newData) @@ -134,23 +130,4 @@ public sealed class CharaDataCharacterHandler : DisposableMediatorSubscriberBase if (handler.Address == nint.Zero) return null; return handler; } - - private int GetGposerObjectIndex(string name) - { - return _dalamudUtilService.GetGposeCharacterFromObjectTableByName(name, _dalamudUtilService.IsInGpose)?.ObjectIndex ?? -1; - } - - private void AddGposer(HandledCharaDataEntry handled) - { - int objectIndex = GetGposerObjectIndex(handled.Name); - if (objectIndex > 0) - _noSnapService.AddGposer(objectIndex); - } - - private void RemoveGposer(HandledCharaDataEntry handled) - { - int objectIndex = GetGposerObjectIndex(handled.Name); - if (objectIndex > 0) - _noSnapService.RemoveGposer(objectIndex); - } } diff --git a/MareSynchronos/Services/NoSnapService.cs b/MareSynchronos/Services/NoSnapService.cs deleted file mode 100644 index 226fab3..0000000 --- a/MareSynchronos/Services/NoSnapService.cs +++ /dev/null @@ -1,226 +0,0 @@ -using Dalamud.Plugin; -using MareSynchronos.Interop.Ipc; -using MareSynchronos.MareConfiguration.Models; -using MareSynchronos.Services.Mediator; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System.Text.Json.Serialization; - -namespace MareSynchronos.Services; - -public sealed class NoSnapService : IHostedService, IMediatorSubscriber -{ - private record NoSnapConfig - { - [JsonPropertyName("listOfPlugins")] - public string[]? ListOfPlugins { get; set; } - } - - private readonly ILogger _logger; - private readonly IDalamudPluginInterface _pluginInterface; - private readonly Dictionary _listOfPlugins = new(StringComparer.Ordinal) - { - ["Snapper"] = false, - ["Snappy"] = false, - ["Meddle.Plugin"] = false, - }; - private static readonly HashSet _gposers = new(); - private static readonly HashSet _gposersNamed = new(StringComparer.Ordinal); - private readonly IHostApplicationLifetime _hostApplicationLifetime; - private readonly DalamudUtilService _dalamudUtilService; - private readonly IpcManager _ipcManager; - private readonly RemoteConfigurationService _remoteConfig; - - public static bool AnyLoaded { get; private set; } = false; - public static string ActivePlugins { get; private set; } = string.Empty; - - public MareMediator Mediator { get; init; } - - public NoSnapService(ILogger logger, IDalamudPluginInterface pluginInterface, MareMediator mediator, - IHostApplicationLifetime hostApplicationLifetime, DalamudUtilService dalamudUtilService, IpcManager ipcManager, - RemoteConfigurationService remoteConfig) - { - _logger = logger; - _pluginInterface = pluginInterface; - Mediator = mediator; - _hostApplicationLifetime = hostApplicationLifetime; - _dalamudUtilService = dalamudUtilService; - _ipcManager = ipcManager; - _remoteConfig = remoteConfig; - - Mediator.Subscribe(this, msg => ClearGposeList()); - Mediator.Subscribe(this, msg => ClearGposeList()); - } - - public void AddGposer(int objectIndex) - { - if (AnyLoaded || _hostApplicationLifetime.ApplicationStopping.IsCancellationRequested) - { - _logger.LogTrace("Immediately reverting object index {id}", objectIndex); - RevertAndRedraw(objectIndex); - return; - } - - _logger.LogTrace("Registering gposer object index {id}", objectIndex); - lock (_gposers) - _gposers.Add(objectIndex); - } - - public void RemoveGposer(int objectIndex) - { - _logger.LogTrace("Un-registering gposer object index {id}", objectIndex); - lock (_gposers) - _gposers.Remove(objectIndex); - } - - public void AddGposerNamed(string name) - { - if (AnyLoaded || _hostApplicationLifetime.ApplicationStopping.IsCancellationRequested) - { - _logger.LogTrace("Immediately reverting {name}", name); - RevertAndRedraw(name); - return; - } - - _logger.LogTrace("Registering gposer {name}", name); - lock (_gposers) - _gposersNamed.Add(name); - } - - private void ClearGposeList() - { - if (_gposers.Count > 0 || _gposersNamed.Count > 0) - _logger.LogTrace("Clearing gposer list"); - lock (_gposers) - _gposers.Clear(); - lock (_gposersNamed) - _gposersNamed.Clear(); - } - - private void RevertAndRedraw(int objIndex, Guid applicationId = default) - { - if (applicationId == default) - applicationId = Guid.NewGuid(); - - try - { - _ipcManager.Glamourer.RevertNow(_logger, applicationId, objIndex); - _ipcManager.Penumbra.RedrawNow(_logger, applicationId, objIndex); - } - catch { } - } - - private void RevertAndRedraw(string name, Guid applicationId = default) - { - if (applicationId == default) - applicationId = Guid.NewGuid(); - - try - { - _ipcManager.Glamourer.RevertByNameNow(_logger, applicationId, name); - var addr = _dalamudUtilService.GetPlayerCharacterFromCachedTableByName(name); - if (addr != 0) - { - var obj = _dalamudUtilService.CreateGameObject(addr); - if (obj != null) - _ipcManager.Penumbra.RedrawNow(_logger, applicationId, obj.ObjectIndex); - } - } - catch { } - } - - private void RevertGposers() - { - List? gposersList = null; - List? gposersList2 = null; - - lock (_gposers) - { - if (_gposers.Count > 0) - { - gposersList = _gposers.ToList(); - _gposers.Clear(); - } - } - - lock (_gposersNamed) - { - if (_gposersNamed.Count > 0) - { - gposersList2 = _gposersNamed.ToList(); - _gposersNamed.Clear(); - } - } - - if (gposersList == null && gposersList2 == null) - return; - - _logger.LogInformation("Reverting gposers"); - - _dalamudUtilService.RunOnFrameworkThread(() => - { - Guid applicationId = Guid.NewGuid(); - - foreach (var gposer in gposersList ?? []) - RevertAndRedraw(gposer, applicationId); - - foreach (var gposerName in gposersList2 ?? []) - RevertAndRedraw(gposerName, applicationId); - }).GetAwaiter().GetResult(); - } - - public async Task StartAsync(CancellationToken cancellationToken) - { - var config = await _remoteConfig.GetConfigAsync("noSnap").ConfigureAwait(false) ?? new(); - - if (config.ListOfPlugins != null) - { - _listOfPlugins.Clear(); - foreach (var pluginName in config.ListOfPlugins) - _listOfPlugins.TryAdd(pluginName, value: false); - } - - foreach (var pluginName in _listOfPlugins.Keys) - { - _listOfPlugins[pluginName] = PluginWatcherService.GetInitialPluginState(_pluginInterface, pluginName)?.IsLoaded ?? false; - Mediator.SubscribeKeyed(this, pluginName, (msg) => - { - _listOfPlugins[pluginName] = msg.IsLoaded; - _logger.LogDebug("{pluginName} isLoaded = {isLoaded}", pluginName, msg.IsLoaded); - Update(); - }); - } - - Update(); - } - - public Task StopAsync(CancellationToken cancellationToken) - { - RevertGposers(); - return Task.CompletedTask; - } - - private void Update() - { - bool anyLoadedNow = _listOfPlugins.Values.Any(p => p); - - if (AnyLoaded != anyLoadedNow) - { - AnyLoaded = anyLoadedNow; - Mediator.Publish(new RecalculatePerformanceMessage(null)); - - if (AnyLoaded) - { - RevertGposers(); - var pluginList = string.Join(", ", _listOfPlugins.Where(p => p.Value).Select(p => p.Key)); - Mediator.Publish(new NotificationMessage("Incompatible plugin loaded", $"Synced player appearances will not apply until incompatible plugins are disabled: {pluginList}.", - NotificationType.Error)); - ActivePlugins = pluginList; - } - else - { - ActivePlugins = string.Empty; - } - } - } -} \ No newline at end of file diff --git a/MareSynchronos/Services/RemoteConfigurationService.cs b/MareSynchronos/Services/RemoteConfigurationService.cs deleted file mode 100644 index b99c4f8..0000000 --- a/MareSynchronos/Services/RemoteConfigurationService.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Chaos.NaCl; -using MareSynchronos.MareConfiguration; -using Microsoft.Extensions.Logging; -using System.Net; -using System.Net.Http.Headers; -using System.Reflection; -using System.Text; -using System.Text.Json; -using System.Text.Json.Nodes; - -namespace MareSynchronos.Services; - -public sealed class RemoteConfigurationService -{ - // private readonly static Dictionary ConfigPublicKeys = new(StringComparer.Ordinal) - // { - // { "", "" }, - // }; - - private readonly static string[] ConfigSources = [ - "https://snowcloak-sync.com/config.json", - ]; - - private readonly ILogger _logger; - private readonly RemoteConfigCacheService _configService; - private readonly Task _initTask; - - public RemoteConfigurationService(ILogger logger, RemoteConfigCacheService configService) - { - _logger = logger; - _configService = configService; - _initTask = Task.Run(DownloadConfig); - } - - public async Task GetConfigAsync(string sectionName) - { - await _initTask.ConfigureAwait(false); - if (!_configService.Current.Configuration.TryGetPropertyValue(sectionName, out var section)) - section = null; - return (section as JsonObject) ?? new(); - } - - public async Task GetConfigAsync(string sectionName) - { - try - { - var json = await GetConfigAsync(sectionName).ConfigureAwait(false); - return JsonSerializer.Deserialize(json); - } - catch (JsonException ex) - { - _logger.LogWarning(ex, "Invalid JSON in remote config: {sectionName}", sectionName); - return default; - } - } - - private async Task DownloadConfig() - { - // Removed Lop's remote config code. Function exists purely to keep things clean. - LoadConfig(); - - } - - private static bool VerifySignature(string message, ulong ts, string signature, string pubKey) - { - byte[] msg = [.. BitConverter.GetBytes(ts), .. Encoding.UTF8.GetBytes(message)]; - byte[] sig = Convert.FromBase64String(signature); - byte[] pub = Convert.FromBase64String(pubKey); - return Ed25519.Verify(sig, msg, pub); - } - - private void LoadConfig() - { - ulong ts = 1755859494; - - var configString = "{\"mainServer\":{\"api_url\":\"wss://hub.snowcloak-sync.com/\",\"hub_url\":\"wss://hub.snowcloak-sync.com/mare\"},\"noSnap\":{\"listOfPlugins\":[\"Snapper\",\"Snappy\",\"Meddle.Plugin\"]}}"; - - - _configService.Current.Configuration = JsonNode.Parse(configString)!.AsObject(); - _configService.Current.Timestamp = ts; - _configService.Save(); - } -} diff --git a/MareSynchronos/UI/UISharedService.cs b/MareSynchronos/UI/UISharedService.cs index 02c6f07..ac9e9b8 100644 --- a/MareSynchronos/UI/UISharedService.cs +++ b/MareSynchronos/UI/UISharedService.cs @@ -851,16 +851,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase ImGui.TextColored(ImGuiColors.DalamudRed, "You need to install both Penumbra and Glamourer and keep them up to date to use Snowcloak."); return false; } - else if (NoSnapService.AnyLoaded) - { - IconText(FontAwesomeIcon.ExclamationTriangle, ImGuiColors.DalamudYellow); - ImGui.SameLine(); - var cursorX = ImGui.GetCursorPosX(); - ImGui.TextColored(ImGuiColors.DalamudYellow, "Synced player appearances will not apply until incompatible plugins are disabled:"); - ImGui.SetCursorPosX(cursorX + 16.0f); - ImGui.TextColored(ImGuiColors.DalamudYellow, NoSnapService.ActivePlugins); - return false; - } return true; } diff --git a/MareSynchronos/WebAPI/AccountRegistrationService.cs b/MareSynchronos/WebAPI/AccountRegistrationService.cs index 86fe8ac..4b5d81b 100644 --- a/MareSynchronos/WebAPI/AccountRegistrationService.cs +++ b/MareSynchronos/WebAPI/AccountRegistrationService.cs @@ -17,18 +17,16 @@ public sealed class AccountRegistrationService : IDisposable private readonly HttpClient _httpClient; private readonly ILogger _logger; private readonly ServerConfigurationManager _serverManager; - private readonly RemoteConfigurationService _remoteConfig; private string GenerateSecretKey() { return Convert.ToHexString(SHA256.HashData(RandomNumberGenerator.GetBytes(64))); } - public AccountRegistrationService(ILogger logger, ServerConfigurationManager serverManager, RemoteConfigurationService remoteConfig) + public AccountRegistrationService(ILogger logger, ServerConfigurationManager serverManager) { _logger = logger; _serverManager = serverManager; - _remoteConfig = remoteConfig; _httpClient = new( new HttpClientHandler { @@ -47,22 +45,10 @@ public sealed class AccountRegistrationService : IDisposable public async Task RegisterAccount(CancellationToken token) { - var authApiUrl = _serverManager.CurrentApiUrl; - - // Override the API URL used for auth from remote config, if one is available - if (authApiUrl.Equals(ApiController.SnowcloakServiceUri, StringComparison.Ordinal)) - { - var config = await _remoteConfig.GetConfigAsync("mainServer").ConfigureAwait(false) ?? new(); - if (!string.IsNullOrEmpty(config.ApiUrl)) - authApiUrl = config.ApiUrl; - else - authApiUrl = ApiController.SnowcloakServiceApiUri; - } - var secretKey = GenerateSecretKey(); var hashedSecretKey = secretKey.GetHash256(); - Uri postUri = MareAuth.AuthRegisterV2FullPath(new Uri(authApiUrl + Uri postUri = MareAuth.AuthRegisterV2FullPath(new Uri(_serverManager.CurrentApiUrl .Replace("wss://", "https://", StringComparison.OrdinalIgnoreCase) .Replace("ws://", "http://", StringComparison.OrdinalIgnoreCase))); diff --git a/MareSynchronos/WebAPI/SignalR/HubFactory.cs b/MareSynchronos/WebAPI/SignalR/HubFactory.cs index 66cb188..0c6b3bb 100644 --- a/MareSynchronos/WebAPI/SignalR/HubFactory.cs +++ b/MareSynchronos/WebAPI/SignalR/HubFactory.cs @@ -19,7 +19,6 @@ public class HubFactory : MediatorSubscriberBase { private readonly ILoggerProvider _loggingProvider; private readonly ServerConfigurationManager _serverConfigurationManager; - private readonly RemoteConfigurationService _remoteConfig; private readonly TokenProvider _tokenProvider; private HubConnection? _instance; private string _cachedConfigFor = string.Empty; @@ -27,11 +26,10 @@ public class HubFactory : MediatorSubscriberBase private bool _isDisposed = false; public HubFactory(ILogger logger, MareMediator mediator, - ServerConfigurationManager serverConfigurationManager, RemoteConfigurationService remoteConfig, + ServerConfigurationManager serverConfigurationManager, TokenProvider tokenProvider, ILoggerProvider pluginLog) : base(logger, mediator) { _serverConfigurationManager = serverConfigurationManager; - _remoteConfig = remoteConfig; _tokenProvider = tokenProvider; _loggingProvider = pluginLog; } @@ -87,16 +85,6 @@ public class HubFactory : MediatorSubscriberBase }; } - if (_serverConfigurationManager.CurrentApiUrl.Equals(ApiController.SnowcloakServiceUri, StringComparison.Ordinal)) - { - var mainServerConfig = await _remoteConfig.GetConfigAsync("mainServer").ConfigureAwait(false) ?? new(); - defaultConfig = mainServerConfig; - if (string.IsNullOrEmpty(mainServerConfig.ApiUrl)) - defaultConfig.ApiUrl = ApiController.SnowcloakServiceApiUri; - if (string.IsNullOrEmpty(mainServerConfig.HubUrl)) - defaultConfig.HubUrl = ApiController.SnowcloakServiceHubUri; - } - string jsonResponse; if (stapledWellKnown != null) diff --git a/MareSynchronos/WebAPI/SignalR/TokenProvider.cs b/MareSynchronos/WebAPI/SignalR/TokenProvider.cs index db5d598..4867239 100644 --- a/MareSynchronos/WebAPI/SignalR/TokenProvider.cs +++ b/MareSynchronos/WebAPI/SignalR/TokenProvider.cs @@ -20,16 +20,14 @@ public sealed class TokenProvider : IDisposable, IMediatorSubscriber private readonly HttpClient _httpClient; private readonly ILogger _logger; private readonly ServerConfigurationManager _serverManager; - private readonly RemoteConfigurationService _remoteConfig; private readonly ConcurrentDictionary _tokenCache = new(); private readonly ConcurrentDictionary _wellKnownCache = new(StringComparer.Ordinal); - public TokenProvider(ILogger logger, ServerConfigurationManager serverManager, RemoteConfigurationService remoteConfig, + public TokenProvider(ILogger logger, ServerConfigurationManager serverManager, DalamudUtilService dalamudUtil, MareMediator mareMediator) { _logger = logger; _serverManager = serverManager; - _remoteConfig = remoteConfig; _dalamudUtil = dalamudUtil; _httpClient = new( new HttpClientHandler @@ -70,23 +68,11 @@ public sealed class TokenProvider : IDisposable, IMediatorSubscriber Uri tokenUri; HttpResponseMessage result; - var authApiUrl = _serverManager.CurrentApiUrl; - - // Override the API URL used for auth from remote config, if one is available - if (authApiUrl.Equals(ApiController.SnowcloakServiceUri, StringComparison.Ordinal)) - { - var config = await _remoteConfig.GetConfigAsync("mainServer").ConfigureAwait(false) ?? new(); - if (!string.IsNullOrEmpty(config.ApiUrl)) - authApiUrl = config.ApiUrl; - else - authApiUrl = ApiController.SnowcloakServiceApiUri; - } - try { _logger.LogDebug("GetNewToken: Requesting"); - tokenUri = MareAuth.AuthV2FullPath(new Uri(authApiUrl + tokenUri = MareAuth.AuthV2FullPath(new Uri(_serverManager.CurrentApiUrl .Replace("wss://", "https://", StringComparison.OrdinalIgnoreCase) .Replace("ws://", "http://", StringComparison.OrdinalIgnoreCase))); var secretKey = _serverManager.GetSecretKey(out _)!;