mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-22 12:18:27 +00:00
Working on login / world connection mostly there, fixed a few crashes with encryption on 0 length packets
This commit is contained in:
@@ -17,8 +17,8 @@ namespace EQ
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode));
|
||||
archive(zero,
|
||||
opcode);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,11 +34,11 @@ namespace EQ
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode),
|
||||
CEREAL_NVP(protocol_version),
|
||||
CEREAL_NVP(connect_code),
|
||||
CEREAL_NVP(max_packet_size));
|
||||
archive(zero,
|
||||
opcode,
|
||||
protocol_version,
|
||||
connect_code,
|
||||
max_packet_size);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,14 +57,14 @@ namespace EQ
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode),
|
||||
CEREAL_NVP(connect_code),
|
||||
CEREAL_NVP(encode_key),
|
||||
CEREAL_NVP(crc_bytes),
|
||||
CEREAL_NVP(encode_pass1),
|
||||
CEREAL_NVP(encode_pass2),
|
||||
CEREAL_NVP(max_packet_size));
|
||||
archive(zero,
|
||||
opcode,
|
||||
connect_code,
|
||||
encode_key,
|
||||
crc_bytes,
|
||||
encode_pass1,
|
||||
encode_pass2,
|
||||
max_packet_size);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -78,9 +78,9 @@ namespace EQ
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode),
|
||||
CEREAL_NVP(connect_code));
|
||||
archive(zero,
|
||||
opcode,
|
||||
connect_code);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -94,9 +94,9 @@ namespace EQ
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode),
|
||||
CEREAL_NVP(sequence));
|
||||
archive(zero,
|
||||
opcode,
|
||||
sequence);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -109,8 +109,8 @@ namespace EQ
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(reliable),
|
||||
CEREAL_NVP(total_size));
|
||||
archive(reliable,
|
||||
total_size);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -131,16 +131,16 @@ namespace EQ
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode),
|
||||
CEREAL_NVP(timestamp),
|
||||
CEREAL_NVP(stat_ping),
|
||||
CEREAL_NVP(avg_ping),
|
||||
CEREAL_NVP(min_ping),
|
||||
CEREAL_NVP(max_ping),
|
||||
CEREAL_NVP(last_ping),
|
||||
CEREAL_NVP(packets_sent),
|
||||
CEREAL_NVP(packets_recv));
|
||||
archive(zero,
|
||||
opcode,
|
||||
timestamp,
|
||||
stat_ping,
|
||||
avg_ping,
|
||||
min_ping,
|
||||
max_ping,
|
||||
last_ping,
|
||||
packets_sent,
|
||||
packets_recv);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -159,14 +159,14 @@ namespace EQ
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(CEREAL_NVP(zero),
|
||||
CEREAL_NVP(opcode),
|
||||
CEREAL_NVP(timestamp),
|
||||
CEREAL_NVP(our_timestamp),
|
||||
CEREAL_NVP(client_sent),
|
||||
CEREAL_NVP(client_recv),
|
||||
CEREAL_NVP(server_sent),
|
||||
CEREAL_NVP(server_recv));
|
||||
archive(zero,
|
||||
opcode,
|
||||
timestamp,
|
||||
our_timestamp,
|
||||
client_sent,
|
||||
client_recv,
|
||||
server_sent,
|
||||
server_recv);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+1
-5
@@ -26,11 +26,7 @@ namespace EQ {
|
||||
|
||||
template<typename T>
|
||||
T GetSerialize(size_t offset) const
|
||||
{
|
||||
if (T::size() > (Length() - offset)) {
|
||||
throw std::out_of_range("Packet::GetSerialize(), packet not large enough to cast to type.");
|
||||
}
|
||||
|
||||
{
|
||||
T ret;
|
||||
Util::MemoryStreamReader reader(((char*)Data() + offset), Length());
|
||||
cereal::BinaryInputArchive input(reader);
|
||||
|
||||
@@ -19,20 +19,23 @@ EQ::Net::ServertalkClient::~ServertalkClient()
|
||||
{
|
||||
}
|
||||
|
||||
void EQ::Net::ServertalkClient::Send(uint16_t opcode, EQ::Net::Packet & p)
|
||||
void EQ::Net::ServertalkClient::Send(uint16_t opcode, EQ::Net::Packet &p)
|
||||
{
|
||||
EQ::Net::WritablePacket out;
|
||||
#ifdef ENABLE_SECURITY
|
||||
if (m_encrypted) {
|
||||
if (p.Length() == 0) {
|
||||
p.PutUInt8(0, 0);
|
||||
}
|
||||
|
||||
out.PutUInt32(0, p.Length() + crypto_secretbox_MACBYTES);
|
||||
out.PutUInt16(4, opcode);
|
||||
unsigned char *cipher = new unsigned char[p.Length() + crypto_secretbox_MACBYTES];
|
||||
|
||||
crypto_box_easy_afternm(cipher, (unsigned char*)p.Data(), p.Length(), m_nonce_ours, m_shared_key);
|
||||
std::unique_ptr<unsigned char[]> cipher(new unsigned char[p.Length() + crypto_secretbox_MACBYTES]);
|
||||
|
||||
crypto_box_easy_afternm(&cipher[0], (unsigned char*)p.Data(), p.Length(), m_nonce_ours, m_shared_key);
|
||||
(*(uint64_t*)&m_nonce_ours[0])++;
|
||||
out.PutData(6, cipher, p.Length() + crypto_secretbox_MACBYTES);
|
||||
|
||||
delete[] cipher;
|
||||
out.PutData(6, &cipher[0], p.Length() + crypto_secretbox_MACBYTES);
|
||||
}
|
||||
else {
|
||||
out.PutUInt32(0, p.Length());
|
||||
|
||||
@@ -22,8 +22,13 @@ void EQ::Net::ServertalkServerConnection::Send(uint16_t opcode, EQ::Net::Packet
|
||||
EQ::Net::WritablePacket out;
|
||||
#ifdef ENABLE_SECURITY
|
||||
if (m_encrypted) {
|
||||
if (p.Length() == 0) {
|
||||
p.PutUInt8(0, 0);
|
||||
}
|
||||
|
||||
out.PutUInt32(0, p.Length() + crypto_secretbox_MACBYTES);
|
||||
out.PutUInt16(4, opcode);
|
||||
|
||||
std::unique_ptr<unsigned char[]> cipher(new unsigned char[p.Length() + crypto_secretbox_MACBYTES]);
|
||||
|
||||
crypto_box_easy_afternm(&cipher[0], (unsigned char*)p.Data(), p.Length(), m_nonce_ours, m_shared_key);
|
||||
|
||||
@@ -152,6 +152,15 @@ void DumpPacket(const ServerPacket* pack, bool iShowInfo) {
|
||||
DumpPacketHex(pack->pBuffer, pack->size);
|
||||
}
|
||||
|
||||
void DumpPacket(uint16 opcode, const EQ::Net::Packet &p, bool iShowInfo) {
|
||||
if (iShowInfo) {
|
||||
std::cout << "Dumping ServerPacket: 0x" << std::hex << std::setfill('0') << std::setw(4) << opcode << std::dec;
|
||||
std::cout << " size:" << p.Length() << std::endl;
|
||||
}
|
||||
|
||||
std::cout << p.ToString() << std::endl;
|
||||
}
|
||||
|
||||
void DumpPacketBin(const ServerPacket* pack) {
|
||||
DumpPacketBin(pack->pBuffer, pack->size);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
#ifndef PACKET_DUMP_H
|
||||
#define PACKET_DUMP_H
|
||||
|
||||
#include "../common/types.h"
|
||||
#include "types.h"
|
||||
#include "net/packet.h"
|
||||
|
||||
class ServerPacket;
|
||||
|
||||
@@ -28,6 +29,7 @@ std::string DumpPacketHexToString(const uchar* buf, uint32 size, uint32 cols = 1
|
||||
void DumpPacketBin(const void* data, uint32 len);
|
||||
void DumpPacket(const uchar* buf, uint32 size);
|
||||
void DumpPacket(const ServerPacket* pack, bool iShowInfo = false);
|
||||
void DumpPacket(uint16 opcode, const EQ::Net::Packet &p, bool iShowInfo = false);
|
||||
void DumpPacketBin(const ServerPacket* pack);
|
||||
void DumpPacketBin(uint32 data);
|
||||
void DumpPacketBin(uint16 data);
|
||||
|
||||
+16
-7
@@ -4,6 +4,8 @@
|
||||
#include "../common/types.h"
|
||||
#include "../common/packet_functions.h"
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <cereal/types/string.hpp>
|
||||
|
||||
#define SERVER_TIMEOUT 45000 // how often keepalive gets sent
|
||||
#define INTERSERVER_TIMER 10000
|
||||
@@ -524,14 +526,21 @@ struct ServerLSPlayerZoneChange_Struct {
|
||||
uint32 from; // 0 = world
|
||||
uint32 to; // 0 = world
|
||||
};
|
||||
|
||||
struct ClientAuth_Struct {
|
||||
uint32 lsaccount_id; // ID# in login server's db
|
||||
char name[30]; // username in login server's db
|
||||
char key[30]; // the Key the client will present
|
||||
uint8 lsadmin; // login server admin level
|
||||
int16 worldadmin; // login's suggested worldadmin level setting for this user, up to the world if they want to obey it
|
||||
char ip[64];
|
||||
uint8 local; // 1 if the client is from the local network
|
||||
int lsaccount_id; // ID# in login server's db
|
||||
std::string name; // username in login server's db
|
||||
std::string key; // the Key the client will present
|
||||
int lsadmin; // login server admin level
|
||||
int worldadmin; // login's suggested worldadmin level setting for this user, up to the world if they want to obey it
|
||||
std::string ip;
|
||||
int local; // 1 if the client is from the local network
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive &ar)
|
||||
{
|
||||
ar(lsaccount_id, name, key, lsadmin, worldadmin, ip, local);
|
||||
}
|
||||
};
|
||||
|
||||
struct ServerSystemwideMessage {
|
||||
|
||||
Reference in New Issue
Block a user