Make PreparedStatements static for each database.

This commit is contained in:
hondacrx
2023-02-04 20:55:14 -05:00
parent e0e20b6b1c
commit 149fadccab
90 changed files with 922 additions and 923 deletions
+6 -6
View File
@@ -72,7 +72,7 @@ namespace BNetServer.Networking
}
}
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetAuthentication);
PreparedStatement stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SelBnetAuthentication);
stmt.AddValue(0, login);
SQLResult result = DB.Login.Query(stmt);
@@ -93,7 +93,7 @@ namespace BNetServer.Networking
loginTicket = "TC-" + ticket.ToHexString();
}
stmt = DB.Login.GetPreparedStatement(LoginStatements.UpdBnetAuthentication);
stmt = LoginDatabase.GetPreparedStatement(LoginStatements.UpdBnetAuthentication);
stmt.AddValue(0, loginTicket);
stmt.AddValue(1, Time.UnixTime + 3600);
stmt.AddValue(2, accountId);
@@ -111,7 +111,7 @@ namespace BNetServer.Networking
if (maxWrongPassword != 0)
{
SQLTransaction trans = new();
stmt = DB.Login.GetPreparedStatement(LoginStatements.UpdBnetFailedLogins);
stmt = LoginDatabase.GetPreparedStatement(LoginStatements.UpdBnetFailedLogins);
stmt.AddValue(0, accountId);
trans.Append(stmt);
@@ -126,19 +126,19 @@ namespace BNetServer.Networking
if (banType == BanMode.Account)
{
stmt = DB.Login.GetPreparedStatement(LoginStatements.InsBnetAccountAutoBanned);
stmt = LoginDatabase.GetPreparedStatement(LoginStatements.InsBnetAccountAutoBanned);
stmt.AddValue(0, accountId);
}
else
{
stmt = DB.Login.GetPreparedStatement(LoginStatements.InsIpAutoBanned);
stmt = LoginDatabase.GetPreparedStatement(LoginStatements.InsIpAutoBanned);
stmt.AddValue(0, request.Host);
}
stmt.AddValue(1, banTime);
trans.Append(stmt);
stmt = DB.Login.GetPreparedStatement(LoginStatements.UpdBnetResetFailedLogins);
stmt = LoginDatabase.GetPreparedStatement(LoginStatements.UpdBnetResetFailedLogins);
stmt.AddValue(0, accountId);
trans.Append(stmt);
}
@@ -55,7 +55,7 @@ namespace BNetServer.Networking
if (verifyWebCredentialsRequest.WebCredentials.IsEmpty)
return BattlenetRpcErrorCode.Denied;
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetAccountInfo);
PreparedStatement stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SelBnetAccountInfo);
stmt.AddValue(0, verifyWebCredentialsRequest.WebCredentials.ToStringUtf8());
SQLResult result = DB.Login.Query(stmt);
@@ -67,7 +67,7 @@ namespace BNetServer.Networking
if (accountInfo.LoginTicketExpiry < Time.UnixTime)
return BattlenetRpcErrorCode.TimedOut;
stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_CHARACTER_COUNTS_BY_BNET_ID);
stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SEL_BNET_CHARACTER_COUNTS_BY_BNET_ID);
stmt.AddValue(0, accountInfo.Id);
SQLResult characterCountsResult = DB.Login.Query(stmt);
@@ -81,7 +81,7 @@ namespace BNetServer.Networking
} while (characterCountsResult.NextRow());
}
stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetLastPlayerCharacters);
stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SelBnetLastPlayerCharacters);
stmt.AddValue(0, accountInfo.Id);
SQLResult lastPlayerCharactersResult = DB.Login.Query(stmt);
@@ -177,7 +177,7 @@ namespace BNetServer.Networking
return BattlenetRpcErrorCode.BadProgram;
}
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_EXISTING_AUTHENTICATION_BY_ID);
PreparedStatement stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SEL_BNET_EXISTING_AUTHENTICATION_BY_ID);
stmt.AddValue(0, accountInfo.Id);
queryProcessor.AddCallback(DB.Login.AsyncQuery(stmt).WithCallback(result =>
@@ -108,7 +108,7 @@ namespace BNetServer.Networking
if (!clientInfoOk)
return BattlenetRpcErrorCode.WowServicesDeniedRealmListTicket;
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UpdBnetLastLoginInfo);
PreparedStatement stmt = LoginDatabase.GetPreparedStatement(LoginStatements.UpdBnetLastLoginInfo);
stmt.AddValue(0, GetRemoteIpEndPoint().ToString());
stmt.AddValue(1, (byte)locale.ToEnum<Locale>());
stmt.AddValue(2, os);
+2 -2
View File
@@ -45,9 +45,9 @@ namespace BNetServer.Networking
Log.outInfo(LogFilter.Network, $"{GetClientInfo()} Connection Accepted.");
// Verify that this IP is not in the ip_banned table
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.DelExpiredIpBans));
DB.Login.Execute(LoginDatabase.GetPreparedStatement(LoginStatements.DelExpiredIpBans));
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SelIpInfo);
PreparedStatement stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SelIpInfo);
stmt.AddValue(0, ipAddress);
stmt.AddValue(1, BitConverter.ToUInt32(GetRemoteIpEndPoint().Address.GetAddressBytes(), 0));
+3 -3
View File
@@ -89,9 +89,9 @@ namespace BNetServer
static void BanExpiryCheckTimer_Elapsed(object sender, ElapsedEventArgs e)
{
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.DelExpiredIpBans));
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.UpdExpiredAccountBans));
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.DelBnetExpiredAccountBanned));
DB.Login.Execute(LoginDatabase.GetPreparedStatement(LoginStatements.DelExpiredIpBans));
DB.Login.Execute(LoginDatabase.GetPreparedStatement(LoginStatements.UpdExpiredAccountBans));
DB.Login.Execute(LoginDatabase.GetPreparedStatement(LoginStatements.DelBnetExpiredAccountBanned));
}
static Timer _banExpiryCheckTimer;