Updated Bnet Server.
Port From (https://github.com/TrinityCore/TrinityCore)
This commit is contained in:
@@ -29,7 +29,7 @@ namespace Game.Networking
|
||||
_receiveBuffer = new byte[1024];
|
||||
}
|
||||
|
||||
public void Accept()
|
||||
public void Start()
|
||||
{
|
||||
// wait 1 second for active connections to send negotiation request
|
||||
for (int counter = 0; counter < 10 && _socket.Available == 0; counter++)
|
||||
@@ -46,7 +46,7 @@ namespace Game.Networking
|
||||
}
|
||||
|
||||
Send("Authentication Required\r\n");
|
||||
Send("Email: ");
|
||||
Send("Username: ");
|
||||
string userName = ReadString();
|
||||
if (userName.IsEmpty())
|
||||
{
|
||||
@@ -64,7 +64,7 @@ namespace Game.Networking
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CheckAccessLevelAndPassword(userName, password))
|
||||
if (!CheckAccessLevel(userName) || Global.AccountMgr.CheckPassword(userName, password))
|
||||
{
|
||||
Send("Authentication failed\r\n");
|
||||
CloseSocket();
|
||||
@@ -129,56 +129,29 @@ namespace Game.Networking
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckAccessLevelAndPassword(string email, string password)
|
||||
bool CheckAccessLevel(string user)
|
||||
{
|
||||
//"SELECT a.id, a.username FROM account a LEFT JOIN battlenet_accounts ba ON a.battlenet_account = ba.id WHERE ba.email = ?"
|
||||
PreparedStatement stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SEL_BNET_GAME_ACCOUNT_LIST);
|
||||
stmt.AddValue(0, email);
|
||||
PreparedStatement stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SEL_ACCOUNT_ACCESS);
|
||||
stmt.AddValue(0, user);
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outInfo(LogFilter.CommandsRA, $"User {email} does not exist in database");
|
||||
Log.outInfo(LogFilter.CommandsRA, $"User {user} does not exist in database");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint accountId = result.Read<uint>(0);
|
||||
string username = result.Read<string>(1);
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SEL_ACCOUNT_ACCESS_BY_ID);
|
||||
stmt.AddValue(0, accountId);
|
||||
result = DB.Login.Query(stmt);
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outInfo(LogFilter.CommandsRA, $"User {email} has no privilege to login");
|
||||
return false;
|
||||
}
|
||||
|
||||
//"SELECT SecurityLevel, RealmID FROM account_access WHERE AccountID = ? and (RealmID = ? OR RealmID = -1) ORDER BY SecurityLevel desc");
|
||||
if (result.Read<byte>(0) < ConfigMgr.GetDefaultValue("Ra.MinLevel", (byte)AccountTypes.Administrator))
|
||||
{
|
||||
Log.outInfo(LogFilter.CommandsRA, $"User {email} has no privilege to login");
|
||||
Log.outInfo(LogFilter.CommandsRA, $"User {user} has no privilege to login");
|
||||
return false;
|
||||
}
|
||||
else if (result.Read<int>(1) != -1)
|
||||
{
|
||||
Log.outInfo(LogFilter.CommandsRA, $"User {email} has to be assigned on all realms (with RealmID = '-1')");
|
||||
Log.outInfo(LogFilter.CommandsRA, $"User {user} has to be assigned on all realms (with RealmID = '-1')");
|
||||
return false;
|
||||
}
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LoginStatements.SEL_CHECK_PASSWORD);
|
||||
stmt.AddValue(0, accountId);
|
||||
result = DB.Login.Query(stmt);
|
||||
if (!result.IsEmpty())
|
||||
{
|
||||
var salt = result.Read<byte[]>(0);
|
||||
var verifier = result.Read<byte[]>(1);
|
||||
|
||||
if (SRP6.CheckLogin(username, password, salt, verifier))
|
||||
return true;
|
||||
}
|
||||
|
||||
Log.outInfo(LogFilter.CommandsRA, $"Wrong password for user: {email}");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProcessCommand(string command)
|
||||
|
||||
Reference in New Issue
Block a user