fix warning

I had two identical LoggingMiddleware instances, and since one was unused, I deleted it.
This commit is contained in:
Kei-Luna
2026-04-20 15:21:24 +09:00
parent 0212f7e397
commit 8a8b0b9f5d
6 changed files with 8 additions and 42 deletions

View File

@@ -80,7 +80,7 @@ public class ProxyOptions
{
public bool Enabled { get; set; } = true;
public int Port { get; set; } = 8888;
public int ServerHttpPort { get; set; } = 8080;
public int ServerHttpPort { get; set; } = 21500;
public bool InstallRootCertificate { get; set; } = true;
public bool ManageSystemProxy { get; set; } = true;
public bool RestoreSystemProxyOnStop { get; set; } = true;

View File

@@ -33,7 +33,7 @@ class IntDictionaryConverter : JsonConverter<Dictionary<int, int>>
public override void WriteJson(JsonWriter writer, Dictionary<int, int>? value, JsonSerializer serializer)
{
writer.WriteStartObject();
foreach (var kv in value)
foreach (var kv in value!)
{
writer.WritePropertyName(kv.Key.ToString());
writer.WriteValue(kv.Value);

View File

@@ -1,34 +0,0 @@
using MikuSB.Util;
using Microsoft.AspNetCore.Http;
namespace MikuSB.SdkServer.Utils;
public class RequestLoggingMiddleware(RequestDelegate next)
{
public async Task InvokeAsync(HttpContext context, Logger logger)
{
var request = context.Request;
var method = request.Method;
var path = request.Path + request.QueryString;
await next(context);
var statusCode = context.Response.StatusCode;
if (path.StartsWith("/report") || path.Contains("/log/") || path == "/alive")
return;
if (statusCode == 200)
{
logger.Info($"{method} {path} => {statusCode}");
}
else if (statusCode == 404)
{
logger.Warn($"{method} {path} => {statusCode}");
}
else
{
logger.Error($"{method} {path} => {statusCode}");
}
}
}

View File

@@ -47,7 +47,7 @@ public sealed class ProxyCertificateAuthority
if (File.Exists(pfxPath))
{
var existing = new X509Certificate2(
var existing = X509CertificateLoader.LoadPkcs12(
File.ReadAllBytes(pfxPath),
Password,
X509KeyStorageFlags.Exportable | X509KeyStorageFlags.UserKeySet);
@@ -70,7 +70,7 @@ public sealed class ProxyCertificateAuthority
request.CertificateExtensions.Add(new X509SubjectKeyIdentifierExtension(request.PublicKey, false));
var root = request.CreateSelfSigned(DateTimeOffset.UtcNow.AddDays(-1), DateTimeOffset.UtcNow.AddYears(10));
var exportable = new X509Certificate2(
var exportable = X509CertificateLoader.LoadPkcs12(
root.Export(X509ContentType.Pfx, Password),
Password,
X509KeyStorageFlags.Exportable | X509KeyStorageFlags.UserKeySet);
@@ -104,9 +104,9 @@ public sealed class ProxyCertificateAuthority
DateTimeOffset.UtcNow.AddYears(2),
serial);
return new X509Certificate2(
return X509CertificateLoader.LoadPkcs12(
certificate.CopyWithPrivateKey(rsa).Export(X509ContentType.Pfx),
(string?)null,
null,
X509KeyStorageFlags.Exportable | X509KeyStorageFlags.UserKeySet);
}

View File

@@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="3.0.0-preview3-19153-02" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>

View File

@@ -80,7 +80,7 @@ public class SocketConnection
{
return !((Socket.Poll(1000, SelectMode.SelectRead) && (Socket.Available == 0)) || !Socket.Connected);
}
catch (Exception e)
catch (Exception)
{
return false;
}