apparently ipids are different

This commit is contained in:
scatterflower 2021-03-14 12:01:27 -05:00
parent c673339653
commit ae0d308ec7
3 changed files with 13 additions and 17 deletions

View File

@ -42,10 +42,9 @@ class AOClient : public QObject {
AOClient(Server* p_server, QTcpSocket* p_socket, QObject* parent = nullptr, int user_id = 0);
~AOClient();
QString getHwid();
QString getIpid();
Server* getServer();
void setHwid(QString p_hwid);
QString getIpid();
void calculateIpid();
int id;

View File

@ -28,6 +28,7 @@ AOClient::AOClient(Server* p_server, QTcpSocket* p_socket, QObject* parent, int
current_area = 0;
current_char = "";
remote_ip = p_socket->peerAddress();
calculateIpid();
is_partial = false;
last_wtce_time = 0;
last_message = "";
@ -274,22 +275,17 @@ void AOClient::sendPacket(QString header)
sendPacket(AOPacket(header, {}));
}
QString AOClient::getHwid() { return hwid; }
void AOClient::setHwid(QString p_hwid)
void AOClient::calculateIpid()
{
// TODO: add support for longer hwids?
// TODO: add support for longer ipids?
// This reduces the (fairly high) chance of
// birthday paradox issues arising. However,
// typing more than 8 characters might be a
// bit cumbersome.
hwid = p_hwid;
QCryptographicHash hash(
QCryptographicHash::Md5); // Don't need security, just
// hashing for uniqueness
QString concat_ip_id = remote_ip.toString() + p_hwid;
hash.addData(concat_ip_id.toUtf8());
QCryptographicHash hash(QCryptographicHash::Md5); // Don't need security, just hashing for uniqueness
hash.addData(remote_ip.toString().toUtf8());
ipid = hash.result().toHex().right(8); // Use the last 8 characters (4 bytes)
}

View File

@ -26,9 +26,9 @@ void AOClient::pktDefault(AreaData* area, int argc, QStringList argv, AOPacket p
void AOClient::pktHardwareId(AreaData* area, int argc, QStringList argv, AOPacket packet)
{
setHwid(argv[0]);
if(server->db_manager->isHDIDBanned(getHwid())) {
sendPacket("BD", {server->db_manager->getBanReason(getHwid())});
hwid = argv[0];
if(server->db_manager->isHDIDBanned(hwid)) {
sendPacket("BD", {server->db_manager->getBanReason(hwid)});
socket->close();
return;
}
@ -88,7 +88,7 @@ void AOClient::pktRequestMusic(AreaData* area, int argc, QStringList argv, AOPac
void AOClient::pktLoadingDone(AreaData* area, int argc, QStringList argv, AOPacket packet)
{
if (getHwid() == "") {
if (hwid == "") {
// No early connecting!
socket->close();
return;
@ -271,6 +271,7 @@ void AOClient::pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPack
qDebug() << "ws ip set to" << argv[0];
#endif
remote_ip = QHostAddress(argv[0]);
calculateIpid();
}
}