diff --git a/Common/Configuration/ConfigContainer.cs b/Common/Configuration/ConfigContainer.cs index 2ed2718..457e576 100644 --- a/Common/Configuration/ConfigContainer.cs +++ b/Common/Configuration/ConfigContainer.cs @@ -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; diff --git a/Common/Data/Config/DictionaryConverter.cs b/Common/Data/Config/DictionaryConverter.cs index cccb4e4..10843df 100644 --- a/Common/Data/Config/DictionaryConverter.cs +++ b/Common/Data/Config/DictionaryConverter.cs @@ -33,7 +33,7 @@ class IntDictionaryConverter : JsonConverter> public override void WriteJson(JsonWriter writer, Dictionary? value, JsonSerializer serializer) { writer.WriteStartObject(); - foreach (var kv in value) + foreach (var kv in value!) { writer.WritePropertyName(kv.Key.ToString()); writer.WriteValue(kv.Value); diff --git a/Common/Util/LoggingMiddleware.cs b/Common/Util/LoggingMiddleware.cs deleted file mode 100644 index 5e5563f..0000000 --- a/Common/Util/LoggingMiddleware.cs +++ /dev/null @@ -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}"); - } - } -} \ No newline at end of file diff --git a/Proxy/ProxyCertificateAuthority.cs b/Proxy/ProxyCertificateAuthority.cs index 99cf144..1c92295 100644 --- a/Proxy/ProxyCertificateAuthority.cs +++ b/Proxy/ProxyCertificateAuthority.cs @@ -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); } diff --git a/SdkServer/SdkServer.csproj b/SdkServer/SdkServer.csproj index c968bc8..d7d4a54 100644 --- a/SdkServer/SdkServer.csproj +++ b/SdkServer/SdkServer.csproj @@ -8,7 +8,7 @@ - + diff --git a/TcpSharp/SocketConnection.cs b/TcpSharp/SocketConnection.cs index 97a7ea2..e63f8fa 100644 --- a/TcpSharp/SocketConnection.cs +++ b/TcpSharp/SocketConnection.cs @@ -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; }