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