feat: Добавлена авторизация через UDP пакеты
This commit is contained in:
9
include/client/main.nut
Normal file
9
include/client/main.nut
Normal file
@@ -0,0 +1,9 @@
|
||||
CLIENT_PASSWORD <- "";
|
||||
|
||||
addEventHandler("onPacket", function(data){
|
||||
local id = data.readUInt8();
|
||||
if (id == 250)
|
||||
{
|
||||
CLIENT_PASSWORD = data.readString();
|
||||
}
|
||||
})
|
||||
@@ -450,9 +450,17 @@ addEventHandler("onPlayerEquipSpell", function(playerid, slotId, instance)
|
||||
|
||||
addEventHandler("onPlayerJoin", function(playerid)
|
||||
{
|
||||
client_password = _globalInstance.generateClientPassword();
|
||||
|
||||
local packet = Packet();
|
||||
packet.writeUInt8(250);
|
||||
packet.writeString(client_password);
|
||||
packet.send(playerid, RELIABLE);
|
||||
|
||||
local data = {
|
||||
event = "onPlayerJoin",
|
||||
playerid = playerid
|
||||
playerid = playerid,
|
||||
password = client_password
|
||||
}
|
||||
|
||||
if (_globalInstance != -1)
|
||||
@@ -133,4 +133,18 @@ class PyG2O
|
||||
|
||||
_message_call.bindenv(this)(request["data"]);
|
||||
}
|
||||
|
||||
function generateClientPassword()
|
||||
{
|
||||
local chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()";
|
||||
local result = "";
|
||||
local length = 32;
|
||||
|
||||
for (local i = 0; i < length; i++) {
|
||||
local randomIndex = rand() % chars.len();
|
||||
result += chars.slice(randomIndex, randomIndex + 1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user