Misc code improvements

This commit is contained in:
Archi
2023-02-08 21:18:20 +01:00
parent 738a2c3508
commit b2c34694ae
2 changed files with 10 additions and 10 deletions

View File

@@ -111,10 +111,10 @@ internal static partial class NativeMethods {
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
#if NETFRAMEWORK #if NETFRAMEWORK
[DllImport("user32.dll")] [DllImport("user32.dll")]
internal static extern bool ShowWindow(nint hWnd, int nCmdShow); internal static extern void ShowWindow(nint hWnd, int nCmdShow);
#else #else
[LibraryImport("user32.dll")] [LibraryImport("user32.dll")]
internal static partial bool ShowWindow(nint hWnd, int nCmdShow); internal static partial void ShowWindow(nint hWnd, int nCmdShow);
#endif #endif
[Flags] [Flags]

View File

@@ -31,14 +31,14 @@ using Microsoft.AspNetCore.Mvc;
namespace ArchiSteamFarm.IPC.Controllers.Api; namespace ArchiSteamFarm.IPC.Controllers.Api;
[Route("Api/IPC")] [Route("Api/IPC/Bans")]
public sealed class IPCController : ArchiController { public sealed class IPCBansController : ArchiController {
/// <summary> /// <summary>
/// Clears the list of all IP addresses currently blocked by ASFs IPC module /// Clears the list of all IP addresses currently blocked by ASFs IPC module
/// </summary> /// </summary>
[HttpDelete("Bans")] [HttpDelete]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
public ActionResult<GenericResponse> BansDelete() { public ActionResult<GenericResponse> Delete() {
ApiAuthenticationMiddleware.ClearFailedAuthorizations(); ApiAuthenticationMiddleware.ClearFailedAuthorizations();
return Ok(new GenericResponse(true)); return Ok(new GenericResponse(true));
@@ -47,10 +47,10 @@ public sealed class IPCController : ArchiController {
/// <summary> /// <summary>
/// Removes an IP address from the list of addresses currently blocked by ASFs IPC module /// Removes an IP address from the list of addresses currently blocked by ASFs IPC module
/// </summary> /// </summary>
[HttpDelete("Bans/{ipAddress:required}")] [HttpDelete("{ipAddress:required}")]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
public ActionResult<GenericResponse> BansDeleteSpecific(string ipAddress) { public ActionResult<GenericResponse> DeleteSpecific(string ipAddress) {
if (string.IsNullOrEmpty(ipAddress)) { if (string.IsNullOrEmpty(ipAddress)) {
throw new ArgumentNullException(nameof(ipAddress)); throw new ArgumentNullException(nameof(ipAddress));
} }
@@ -71,7 +71,7 @@ public sealed class IPCController : ArchiController {
/// <summary> /// <summary>
/// Gets all IP addresses currently blocked by ASFs IPC module /// Gets all IP addresses currently blocked by ASFs IPC module
/// </summary> /// </summary>
[HttpGet("Bans")] [HttpGet]
[ProducesResponseType(typeof(GenericResponse<ISet<string>>), (int) HttpStatusCode.OK)] [ProducesResponseType(typeof(GenericResponse<ISet<string>>), (int) HttpStatusCode.OK)]
public ActionResult<GenericResponse<ISet<string>>> BansGet() => Ok(new GenericResponse<ISet<string>>(ApiAuthenticationMiddleware.GetCurrentlyBannedIPs().Select(static ip => ip.ToString()).ToHashSet())); public ActionResult<GenericResponse<ISet<string>>> Get() => Ok(new GenericResponse<ISet<string>>(ApiAuthenticationMiddleware.GetCurrentlyBannedIPs().Select(static ip => ip.ToString()).ToHashSet()));
} }