Disable mare api impersonation

This commit is contained in:
Loporrit
2025-08-15 06:04:34 +00:00
parent 997977a978
commit d97c380e67
2 changed files with 27 additions and 12 deletions

View File

@@ -56,11 +56,14 @@ public class IpcProvider : IHostedService, IMediatorSubscriber
_activeGameObjectHandlers.Remove(msg.GameObjectHandler); _activeGameObjectHandlers.Remove(msg.GameObjectHandler);
}); });
/*
_marePluginEnabled = PluginWatcherService.GetInitialPluginState(pi, "MareSynchronos")?.IsLoaded ?? false; _marePluginEnabled = PluginWatcherService.GetInitialPluginState(pi, "MareSynchronos")?.IsLoaded ?? false;
Mediator.SubscribeKeyed<PluginChangeMessage>(this, "MareSynchronos", p => { Mediator.SubscribeKeyed<PluginChangeMessage>(this, "MareSynchronos", p => {
_marePluginEnabled = p.IsLoaded; _marePluginEnabled = p.IsLoaded;
HandleMareImpersonation(automatic: true); HandleMareImpersonation(automatic: true);
}); });
*/
_marePluginEnabled = true;
} }
public Task StartAsync(CancellationToken cancellationToken) public Task StartAsync(CancellationToken cancellationToken)
@@ -101,11 +104,11 @@ public class IpcProvider : IHostedService, IMediatorSubscriber
if (_mareConfig.Current.MareAPI) if (_mareConfig.Current.MareAPI)
{ {
var cancelToken = _registerDelayCts.Token; var cancelToken = _registerDelayCts.Token;
Task.Run(async () => _ = Task.Run(async () =>
{ {
// Wait before registering to reduce the chance of a race condition // Wait before registering to reduce the chance of a race condition
if (automatic) if (automatic)
await Task.Delay(5000); await Task.Delay(5000).ConfigureAwait(false);
if (cancelToken.IsCancellationRequested) if (cancelToken.IsCancellationRequested)
return; return;
@@ -118,7 +121,7 @@ public class IpcProvider : IHostedService, IMediatorSubscriber
_loadFileProviderMare?.RegisterFunc(LoadMcdf); _loadFileProviderMare?.RegisterFunc(LoadMcdf);
_loadFileAsyncProviderMare?.RegisterFunc(LoadMcdfAsync); _loadFileAsyncProviderMare?.RegisterFunc(LoadMcdfAsync);
_handledGameAddressesMare?.RegisterFunc(GetHandledAddresses); _handledGameAddressesMare?.RegisterFunc(MareGetHandledAddresses);
_impersonating = true; _impersonating = true;
_logger.LogDebug("Registered MareSynchronos API"); _logger.LogDebug("Registered MareSynchronos API");
}, cancelToken); }, cancelToken);
@@ -180,6 +183,11 @@ public class IpcProvider : IHostedService, IMediatorSubscriber
} }
private List<nint> GetHandledAddresses() private List<nint> GetHandledAddresses()
{
return _activeGameObjectHandlers.Where(g => g.Address != nint.Zero).Select(g => g.Address).Distinct().ToList();
}
private List<nint> MareGetHandledAddresses()
{ {
if (!_impersonating) if (!_impersonating)
{ {
@@ -191,6 +199,6 @@ public class IpcProvider : IHostedService, IMediatorSubscriber
return []; return [];
} }
return _activeGameObjectHandlers.Where(g => g.Address != nint.Zero).Select(g => g.Address).Distinct().ToList(); return GetHandledAddresses();
} }
} }

View File

@@ -581,7 +581,10 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.BigText("Advanced"); _uiShared.BigText("Advanced");
bool mareApi = _configService.Current.MareAPI; bool mareApi = _configService.Current.MareAPI;
if (ImGui.Checkbox("Enable Mare Synchronos API", ref mareApi)) using (var disabled = ImRaii.Disabled(true))
{
bool dummyFalse = false;
if (ImGui.Checkbox("Enable Mare Synchronos API", ref dummyFalse))
{ {
_configService.Current.MareAPI = mareApi; _configService.Current.MareAPI = mareApi;
_configService.Save(); _configService.Save();
@@ -591,10 +594,13 @@ public class SettingsUi : WindowMediatorSubscriberBase
" - MCDF loading support for other plugins\n" + " - MCDF loading support for other plugins\n" +
" - Blocking Moodles applications to paired users\n\n" + " - Blocking Moodles applications to paired users\n\n" +
"If the Mare Synchronos plugin is loaded while this option is enabled, control of its API will be relinquished."); "If the Mare Synchronos plugin is loaded while this option is enabled, control of its API will be relinquished.");
}
using (_ = ImRaii.PushIndent()) using (_ = ImRaii.PushIndent())
{ {
ImGui.SameLine(300.0f * ImGuiHelpers.GlobalScale); ImGui.SameLine(300.0f * ImGuiHelpers.GlobalScale);
UiSharedService.ColorTextWrapped("Mare API impersonation is currently unavailable", ImGuiColors.DalamudGrey2);
/*
if (_ipcProvider.ImpersonationActive) if (_ipcProvider.ImpersonationActive)
{ {
UiSharedService.ColorTextWrapped("Mare API active!", ImGuiColors.HealerGreen); UiSharedService.ColorTextWrapped("Mare API active!", ImGuiColors.HealerGreen);
@@ -608,6 +614,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
else else
UiSharedService.ColorTextWrapped("Mare API inactive: Unknown reason", ImGuiColors.DalamudRed); UiSharedService.ColorTextWrapped("Mare API inactive: Unknown reason", ImGuiColors.DalamudRed);
} }
*/
} }
bool logEvents = _configService.Current.LogEvents; bool logEvents = _configService.Current.LogEvents;