From 1d7ea33e70c8a9595d5c0193bbed9a23d858c03c Mon Sep 17 00:00:00 2001
From: tintinhamans <5984296+tintinhamans@users.noreply.github.com>
Date: Thu, 20 Aug 2026 18:27:43 +0200
Subject: [PATCH] chore: standardize on MySqlConnector
---
GenOnlineService/Constants.cs | 3 --
.../CheckLogin/CheckLoginController.cs | 1 -
.../LoginWithTokenController.cs | 1 -
.../Matchmaking/MatchmakingController.cs | 2 -
.../Monitoring/MonitoringController.cs | 1 -
.../Controllers/OID/OIDController.cs | 1 -
GenOnlineService/Discord.cs | 3 +-
GenOnlineService/GenOnlineService.csproj | 3 +-
GenOnlineService/LobbyManager.cs | 3 +-
GenOnlineService/MatchmakingManager.cs | 3 +-
GenOnlineService/Program.cs | 44 ++-----------------
11 files changed, 7 insertions(+), 58 deletions(-)
diff --git a/GenOnlineService/Constants.cs b/GenOnlineService/Constants.cs
index 06f02cc..bd5aabb 100644
--- a/GenOnlineService/Constants.cs
+++ b/GenOnlineService/Constants.cs
@@ -20,8 +20,6 @@
using Amazon.S3.Model;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.EntityFrameworkCore;
-using MySqlX.XDevAPI;
-using Org.BouncyCastle.Tls;
using System;
using System.Collections.Concurrent;
using System.Diagnostics.Metrics;
@@ -32,7 +30,6 @@
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
-using ZstdSharp.Unsafe;
namespace GenOnlineService
{
diff --git a/GenOnlineService/Controllers/CheckLogin/CheckLoginController.cs b/GenOnlineService/Controllers/CheckLogin/CheckLoginController.cs
index d40e629..3875a00 100644
--- a/GenOnlineService/Controllers/CheckLogin/CheckLoginController.cs
+++ b/GenOnlineService/Controllers/CheckLogin/CheckLoginController.cs
@@ -19,7 +19,6 @@
using Database;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
-using MySqlX.XDevAPI.Common;
using System;
using System.Net;
using System.Security.Cryptography;
diff --git a/GenOnlineService/Controllers/LoginWithToken/LoginWithTokenController.cs b/GenOnlineService/Controllers/LoginWithToken/LoginWithTokenController.cs
index e20d2c1..8607b7c 100644
--- a/GenOnlineService/Controllers/LoginWithToken/LoginWithTokenController.cs
+++ b/GenOnlineService/Controllers/LoginWithToken/LoginWithTokenController.cs
@@ -19,7 +19,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
-using MySqlX.XDevAPI.Common;
using System;
using System.Net;
using System.Security.Cryptography;
diff --git a/GenOnlineService/Controllers/Matchmaking/MatchmakingController.cs b/GenOnlineService/Controllers/Matchmaking/MatchmakingController.cs
index 3a9794d..7ba9bcd 100644
--- a/GenOnlineService/Controllers/Matchmaking/MatchmakingController.cs
+++ b/GenOnlineService/Controllers/Matchmaking/MatchmakingController.cs
@@ -22,8 +22,6 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
-using MySqlX.XDevAPI.Common;
-using Org.BouncyCastle.Tls;
using System;
using System.Net;
using System.Net.WebSockets;
diff --git a/GenOnlineService/Controllers/Monitoring/MonitoringController.cs b/GenOnlineService/Controllers/Monitoring/MonitoringController.cs
index 8afd360..05ea320 100644
--- a/GenOnlineService/Controllers/Monitoring/MonitoringController.cs
+++ b/GenOnlineService/Controllers/Monitoring/MonitoringController.cs
@@ -21,7 +21,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
-using Org.BouncyCastle.Security;
using System;
using System.Collections.Concurrent;
using System.Net;
diff --git a/GenOnlineService/Controllers/OID/OIDController.cs b/GenOnlineService/Controllers/OID/OIDController.cs
index 212d2ba..4a4ac50 100644
--- a/GenOnlineService/Controllers/OID/OIDController.cs
+++ b/GenOnlineService/Controllers/OID/OIDController.cs
@@ -20,7 +20,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
-using MySqlX.XDevAPI.Common;
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Net;
diff --git a/GenOnlineService/Discord.cs b/GenOnlineService/Discord.cs
index 6e9c598..66deb6c 100644
--- a/GenOnlineService/Discord.cs
+++ b/GenOnlineService/Discord.cs
@@ -23,7 +23,6 @@
using Discord.Rest;
using Discord.WebSocket;
using GenOnlineService;
-using MySqlX.XDevAPI;
using System;
using System.Collections.Generic;
using System.Net.WebSockets;
@@ -848,4 +847,4 @@ public async Task PushMessage(SocketUser user, ulong channelToUse, string strMes
}
}
-}
\ No newline at end of file
+}
diff --git a/GenOnlineService/GenOnlineService.csproj b/GenOnlineService/GenOnlineService.csproj
index 29a5013..b4f0ccc 100644
--- a/GenOnlineService/GenOnlineService.csproj
+++ b/GenOnlineService/GenOnlineService.csproj
@@ -47,8 +47,7 @@
-
-
+
diff --git a/GenOnlineService/LobbyManager.cs b/GenOnlineService/LobbyManager.cs
index 61e5b79..9be6c4e 100644
--- a/GenOnlineService/LobbyManager.cs
+++ b/GenOnlineService/LobbyManager.cs
@@ -20,7 +20,6 @@
using Discord;
using GenOnlineService.Controllers;
using Microsoft.EntityFrameworkCore;
-using MySqlX.XDevAPI;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -1763,4 +1762,4 @@ public bool IsUserInLobby(Lobby lobby, Int64 user_id)
return member != null;
}
}
-}
\ No newline at end of file
+}
diff --git a/GenOnlineService/MatchmakingManager.cs b/GenOnlineService/MatchmakingManager.cs
index 72c4cab..b88f64d 100644
--- a/GenOnlineService/MatchmakingManager.cs
+++ b/GenOnlineService/MatchmakingManager.cs
@@ -24,7 +24,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
-using Org.BouncyCastle.Tls;
using System;
using System.Collections.Concurrent;
using System.Net;
@@ -1547,4 +1546,4 @@ public static void DeregisterPlayer(UserSession plr)
Console.WriteLine("[Source 4] User {0} Leave Any Lobby", plr.m_UserID);
lobbyManager.LeaveAnyLobby(plr.m_UserID);
}
-}
\ No newline at end of file
+}
diff --git a/GenOnlineService/Program.cs b/GenOnlineService/Program.cs
index b9b823d..185b65f 100644
--- a/GenOnlineService/Program.cs
+++ b/GenOnlineService/Program.cs
@@ -16,7 +16,6 @@
** along with this program. If not, see .
*/
-using Google.Protobuf.WellKnownTypes;
using MaxMind.GeoIP2;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
@@ -27,10 +26,6 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
-using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.OpenSsl;
-using Org.BouncyCastle.Pkcs;
-using Org.BouncyCastle.Security;
using Sentry;
using System.Collections.Concurrent;
using System.Configuration;
@@ -144,37 +139,6 @@ public static bool ValidateKey(string strKey)
return bMatched;
}
}
- public static class CertHelpers
- {
- public static X509Certificate2 LoadPemWithPrivateKey(string certPath, string keyPath)
- {
- using (var certReader = new StreamReader(certPath))
- using (var keyReader = new StreamReader(keyPath))
- {
- var pemCertReader = new PemReader(certReader);
- var pemKeyReader = new PemReader(keyReader);
-
- var certificate = (Org.BouncyCastle.X509.X509Certificate)pemCertReader.ReadObject();
- var privateKey = (AsymmetricKeyParameter)pemKeyReader.ReadObject();
-
- //var store = new Pkcs12Store();
- var store = new Pkcs12StoreBuilder().Build(); // Fix for CS1729
- var certEntry = new X509CertificateEntry(certificate);
- store.SetCertificateEntry("cert", certEntry);
- store.SetKeyEntry("key", new AsymmetricKeyEntry(privateKey), new[] { certEntry });
-
- using (var ms = new MemoryStream())
- {
- store.Save(ms, new char[0], new SecureRandom());
-#pragma warning disable SYSLIB0057 // Type or member is obsolete
- return new X509Certificate2(ms.ToArray(), string.Empty);
-#pragma warning restore SYSLIB0057 // Type or member is obsolete
- }
- }
- }
- }
-
-
public class BasicAuthenticationHandler : AuthenticationHandler
{
public BasicAuthenticationHandler(
@@ -400,7 +364,7 @@ private static async Task InitializeDatabase(WebApplicationBuilder builder)
string? password = dbSettings.GetValue("db_password");
UInt16? port = dbSettings.GetValue("db_port");
- // Fall back to MySql.Data's own defaults when a key is absent, rather than silently
+ // Fall back to MySqlConnector's own defaults when a key is absent, rather than silently
// disabling pooling / zeroing the pool size for deployments predating these settings.
int db_min_poolsize = dbSettings.GetValue("db_min_poolsize") ?? 0;
int db_max_poolsize = dbSettings.GetValue("db_max_poolsize") ?? 100;
@@ -444,7 +408,7 @@ private static async Task InitializeDatabase(WebApplicationBuilder builder)
{
//var builder = WebApplication.CreateBuilder(args);
- var csb = new MySql.Data.MySqlClient.MySqlConnectionStringBuilder
+ var csb = new MySqlConnector.MySqlConnectionStringBuilder
{
Server = hostname,
Port = (uint)port,
@@ -453,7 +417,7 @@ private static async Task InitializeDatabase(WebApplicationBuilder builder)
Password = password,
ConnectionTimeout = (uint)db_connect_timeout,
DefaultCommandTimeout = (uint)db_command_timeout,
- SslMode = MySql.Data.MySqlClient.MySqlSslMode.Preferred,
+ SslMode = MySqlConnector.MySqlSslMode.Preferred,
Pooling = db_use_pooling,
MinimumPoolSize = (uint)db_min_poolsize,
MaximumPoolSize = (uint)db_max_poolsize,
@@ -1091,8 +1055,6 @@ public static async Task Main(string[] args)
}
else
{
- //X509Certificate2 = CertHelpers.LoadPemWithPrivateKey(cert_pem_path, cert_key_path);
-
X509Certificate2 = X509Certificate2.CreateFromPemFile(cert_pem_path, cert_key_path);