mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
UCS support decided to not rewrite it for now. Maybe later now that it's easier to work with
This commit is contained in:
parent
bf563e9c6a
commit
08e72bbbdd
11
ucs/ucs.cpp
11
ucs/ucs.cpp
@ -54,9 +54,6 @@ volatile bool RunLoops = true;
|
|||||||
void CatchSignal(int sig_num) {
|
void CatchSignal(int sig_num) {
|
||||||
|
|
||||||
RunLoops = false;
|
RunLoops = false;
|
||||||
|
|
||||||
if(worldserver)
|
|
||||||
worldserver->Disconnect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetMailPrefix() {
|
std::string GetMailPrefix() {
|
||||||
@ -143,8 +140,6 @@ int main() {
|
|||||||
|
|
||||||
worldserver = new WorldServer;
|
worldserver = new WorldServer;
|
||||||
|
|
||||||
worldserver->Connect();
|
|
||||||
|
|
||||||
while(RunLoops) {
|
while(RunLoops) {
|
||||||
|
|
||||||
Timer::SetCurrentTime();
|
Timer::SetCurrentTime();
|
||||||
@ -154,12 +149,6 @@ int main() {
|
|||||||
if(ChannelListProcessTimer.Check())
|
if(ChannelListProcessTimer.Check())
|
||||||
ChannelList->Process();
|
ChannelList->Process();
|
||||||
|
|
||||||
if (InterserverTimer.Check()) {
|
|
||||||
if (worldserver->TryReconnect() && (!worldserver->Connected()))
|
|
||||||
worldserver->AsyncConnect();
|
|
||||||
}
|
|
||||||
worldserver->Process();
|
|
||||||
|
|
||||||
EQ::EventLoop::Get().Process();
|
EQ::EventLoop::Get().Process();
|
||||||
|
|
||||||
Sleep(1);
|
Sleep(1);
|
||||||
|
|||||||
@ -17,6 +17,15 @@
|
|||||||
*/
|
*/
|
||||||
#include "../common/global_define.h"
|
#include "../common/global_define.h"
|
||||||
#include "../common/eqemu_logsys.h"
|
#include "../common/eqemu_logsys.h"
|
||||||
|
#include "../common/servertalk.h"
|
||||||
|
#include "../common/misc_functions.h"
|
||||||
|
#include "../common/packet_functions.h"
|
||||||
|
#include "../common/md5.h"
|
||||||
|
#include "worldserver.h"
|
||||||
|
#include "clientlist.h"
|
||||||
|
#include "ucsconfig.h"
|
||||||
|
#include "database.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -25,14 +34,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "../common/servertalk.h"
|
|
||||||
#include "worldserver.h"
|
|
||||||
#include "clientlist.h"
|
|
||||||
#include "ucsconfig.h"
|
|
||||||
#include "database.h"
|
|
||||||
#include "../common/packet_functions.h"
|
|
||||||
#include "../common/md5.h"
|
|
||||||
|
|
||||||
extern WorldServer worldserver;
|
extern WorldServer worldserver;
|
||||||
extern Clientlist *g_Clientlist;
|
extern Clientlist *g_Clientlist;
|
||||||
extern const ucsconfig *Config;
|
extern const ucsconfig *Config;
|
||||||
@ -41,94 +42,78 @@ extern Database database;
|
|||||||
void ProcessMailTo(Client *c, std::string from, std::string subject, std::string message);
|
void ProcessMailTo(Client *c, std::string from, std::string subject, std::string message);
|
||||||
|
|
||||||
WorldServer::WorldServer()
|
WorldServer::WorldServer()
|
||||||
: WorldConnection(EmuTCPConnection::packetModeUCS, Config->SharedKey.c_str())
|
|
||||||
{
|
{
|
||||||
pTryReconnect = true;
|
m_connection.reset(new EQ::Net::ServertalkClient(Config->WorldIP, Config->WorldTCPPort, false, "UCS", Config->SharedKey));
|
||||||
|
m_connection->OnMessage(std::bind(&WorldServer::ProcessMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldServer::~WorldServer()
|
WorldServer::~WorldServer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldServer::OnConnected()
|
void WorldServer::ProcessMessage(uint16 opcode, EQ::Net::Packet &p)
|
||||||
{
|
{
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Connected to World.");
|
ServerPacket tpack(opcode, p);
|
||||||
WorldConnection::OnConnected();
|
ServerPacket *pack = &tpack;
|
||||||
}
|
|
||||||
|
|
||||||
void WorldServer::Process()
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Received Opcode: %4X", opcode);
|
||||||
{
|
|
||||||
WorldConnection::Process();
|
|
||||||
|
|
||||||
if (!Connected())
|
switch(opcode)
|
||||||
return;
|
|
||||||
|
|
||||||
ServerPacket *pack = nullptr;
|
|
||||||
|
|
||||||
while((pack = tcpc.PopPacket()))
|
|
||||||
{
|
{
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Received Opcode: %4X", pack->opcode);
|
case 0: {
|
||||||
|
break;
|
||||||
switch(pack->opcode)
|
}
|
||||||
|
case ServerOP_KeepAlive:
|
||||||
{
|
{
|
||||||
case 0: {
|
break;
|
||||||
|
}
|
||||||
|
case ServerOP_UCSMessage:
|
||||||
|
{
|
||||||
|
char *Buffer = (char *)pack->pBuffer;
|
||||||
|
|
||||||
|
auto From = new char[strlen(Buffer) + 1];
|
||||||
|
|
||||||
|
VARSTRUCT_DECODE_STRING(From, Buffer);
|
||||||
|
|
||||||
|
std::string Message = Buffer;
|
||||||
|
|
||||||
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Player: %s, Sent Message: %s", From, Message.c_str());
|
||||||
|
|
||||||
|
Client *c = g_Clientlist->FindCharacter(From);
|
||||||
|
|
||||||
|
safe_delete_array(From);
|
||||||
|
|
||||||
|
if(Message.length() < 2)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case ServerOP_KeepAlive:
|
if(!c)
|
||||||
{
|
{
|
||||||
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Client not found.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ServerOP_UCSMessage:
|
|
||||||
|
if(Message[0] == ';')
|
||||||
{
|
{
|
||||||
char *Buffer = (char *)pack->pBuffer;
|
c->SendChannelMessageByNumber(Message.substr(1, std::string::npos));
|
||||||
|
|
||||||
auto From = new char[strlen(Buffer) + 1];
|
|
||||||
|
|
||||||
VARSTRUCT_DECODE_STRING(From, Buffer);
|
|
||||||
|
|
||||||
std::string Message = Buffer;
|
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Player: %s, Sent Message: %s", From, Message.c_str());
|
|
||||||
|
|
||||||
Client *c = g_Clientlist->FindCharacter(From);
|
|
||||||
|
|
||||||
safe_delete_array(From);
|
|
||||||
|
|
||||||
if(Message.length() < 2)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if(!c)
|
|
||||||
{
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Client not found.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Message[0] == ';')
|
|
||||||
{
|
|
||||||
c->SendChannelMessageByNumber(Message.substr(1, std::string::npos));
|
|
||||||
}
|
|
||||||
else if(Message[0] == '[')
|
|
||||||
{
|
|
||||||
g_Clientlist->ProcessOPMailCommand(c, Message.substr(1, std::string::npos));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else if(Message[0] == '[')
|
||||||
case ServerOP_UCSMailMessage:
|
|
||||||
{
|
{
|
||||||
ServerMailMessageHeader_Struct *mail = (ServerMailMessageHeader_Struct*)pack->pBuffer;
|
g_Clientlist->ProcessOPMailCommand(c, Message.substr(1, std::string::npos));
|
||||||
database.SendMail(std::string("SOE.EQ.") + Config->ShortName + std::string(".") + std::string(mail->to),
|
|
||||||
std::string(mail->from),
|
|
||||||
mail->subject,
|
|
||||||
mail->message,
|
|
||||||
std::string());
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ServerOP_UCSMailMessage:
|
||||||
|
{
|
||||||
|
ServerMailMessageHeader_Struct *mail = (ServerMailMessageHeader_Struct*)pack->pBuffer;
|
||||||
|
database.SendMail(std::string("SOE.EQ.") + Config->ShortName + std::string(".") + std::string(mail->to),
|
||||||
|
std::string(mail->from),
|
||||||
|
mail->subject,
|
||||||
|
mail->message,
|
||||||
|
std::string());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_delete(pack);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,18 +18,20 @@
|
|||||||
#ifndef WORLDSERVER_H
|
#ifndef WORLDSERVER_H
|
||||||
#define WORLDSERVER_H
|
#define WORLDSERVER_H
|
||||||
|
|
||||||
#include "../common/worldconn.h"
|
#include "../net/servertalk_client_connection.h"
|
||||||
#include "../common/eq_packet_structs.h"
|
#include "../common/eq_packet_structs.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class WorldServer : public WorldConnection
|
class WorldServer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WorldServer();
|
WorldServer();
|
||||||
virtual ~WorldServer();
|
~WorldServer();
|
||||||
virtual void Process();
|
void ProcessMessage(uint16 opcode, EQ::Net::Packet &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void OnConnected();
|
|
||||||
|
std::unique_ptr<EQ::Net::ServertalkClient> m_connection;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -437,6 +437,20 @@ int main(int argc, char** argv) {
|
|||||||
QSLink.RemoveConnection(connection);
|
QSLink.RemoveConnection(connection);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server_connection->OnConnectionIdentified("UCS", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||||
|
Log.OutF(Logs::General, Logs::World_Server, "New UCS Server connection from {2} at {0}:{1}",
|
||||||
|
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||||
|
|
||||||
|
UCSLink.SetConnection(connection);
|
||||||
|
});
|
||||||
|
|
||||||
|
server_connection->OnConnectionRemoved("UCS", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||||
|
Log.OutF(Logs::General, Logs::World_Server, "UCS Query Server connection from {0}",
|
||||||
|
connection->GetUUID());
|
||||||
|
|
||||||
|
UCSLink.SetConnection(nullptr);
|
||||||
|
});
|
||||||
|
|
||||||
EQ::Net::EQStreamManagerOptions opts(9000, false, false);
|
EQ::Net::EQStreamManagerOptions opts(9000, false, false);
|
||||||
EQ::Net::EQStreamManager eqsm(opts);
|
EQ::Net::EQStreamManager eqsm(opts);
|
||||||
|
|
||||||
@ -451,7 +465,6 @@ int main(int argc, char** argv) {
|
|||||||
InterserverTimer.Trigger();
|
InterserverTimer.Trigger();
|
||||||
uint8 ReconnectCounter = 100;
|
uint8 ReconnectCounter = 100;
|
||||||
std::shared_ptr<EQStreamInterface> eqs;
|
std::shared_ptr<EQStreamInterface> eqs;
|
||||||
EmuTCPConnection* tcpc;
|
|
||||||
EQStreamInterface *eqsi;
|
EQStreamInterface *eqsi;
|
||||||
|
|
||||||
eqsm.OnNewConnection([&stream_identifier](std::shared_ptr<EQ::Net::EQStream> stream) {
|
eqsm.OnNewConnection([&stream_identifier](std::shared_ptr<EQ::Net::EQStream> stream) {
|
||||||
@ -510,7 +523,6 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
zoneserver_list.Process();
|
zoneserver_list.Process();
|
||||||
launcher_list.Process();
|
launcher_list.Process();
|
||||||
UCSLink.Process();
|
|
||||||
LFPGroupList.Process();
|
LFPGroupList.Process();
|
||||||
adventure_manager.Process();
|
adventure_manager.Process();
|
||||||
|
|
||||||
|
|||||||
107
world/ucs.cpp
107
world/ucs.cpp
@ -11,109 +11,58 @@
|
|||||||
UCSConnection::UCSConnection()
|
UCSConnection::UCSConnection()
|
||||||
{
|
{
|
||||||
Stream = 0;
|
Stream = 0;
|
||||||
authenticated = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UCSConnection::SetConnection(EmuTCPConnection *inStream)
|
void UCSConnection::SetConnection(std::shared_ptr<EQ::Net::ServertalkServerConnection> inStream)
|
||||||
{
|
{
|
||||||
if(Stream)
|
if(Stream && Stream->Handle())
|
||||||
{
|
{
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Incoming UCS Connection while we were already connected to a UCS.");
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Incoming UCS Connection while we were already connected to a UCS.");
|
||||||
Stream->Disconnect();
|
Stream->Handle()->Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream = inStream;
|
Stream = inStream;
|
||||||
|
Stream->OnMessage(std::bind(&UCSConnection::ProcessPacket, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
authenticated = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UCSConnection::Process()
|
void UCSConnection::ProcessPacket(uint16 opcode, EQ::Net::Packet &p)
|
||||||
{
|
{
|
||||||
if (!Stream || !Stream->Connected())
|
if (!Stream)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
ServerPacket *pack = 0;
|
ServerPacket tpack(opcode, p);
|
||||||
|
ServerPacket *pack = &tpack;
|
||||||
|
|
||||||
while((pack = Stream->PopPacket()))
|
switch(opcode)
|
||||||
{
|
{
|
||||||
if (!authenticated)
|
case 0:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ServerOP_KeepAlive:
|
||||||
{
|
{
|
||||||
if (WorldConfig::get()->SharedKey.length() > 0)
|
// ignore this
|
||||||
{
|
break;
|
||||||
if (pack->opcode == ServerOP_ZAAuth && pack->size == 16)
|
|
||||||
{
|
|
||||||
uint8 tmppass[16];
|
|
||||||
|
|
||||||
MD5::Generate((const uchar*) WorldConfig::get()->SharedKey.c_str(), WorldConfig::get()->SharedKey.length(), tmppass);
|
|
||||||
|
|
||||||
if (memcmp(pack->pBuffer, tmppass, 16) == 0)
|
|
||||||
authenticated = true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct in_addr in;
|
|
||||||
in.s_addr = GetIP();
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "UCS authorization failed.");
|
|
||||||
auto pack = new ServerPacket(ServerOP_ZAAuthFailed);
|
|
||||||
SendPacket(pack);
|
|
||||||
delete pack;
|
|
||||||
Disconnect();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct in_addr in;
|
|
||||||
in.s_addr = GetIP();
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "UCS authorization failed.");
|
|
||||||
auto pack = new ServerPacket(ServerOP_ZAAuthFailed);
|
|
||||||
SendPacket(pack);
|
|
||||||
delete pack;
|
|
||||||
Disconnect();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server,"**WARNING** You have not configured a world shared key in your config file. You should add a <key>STRING</key> element to your <world> element to prevent unauthroized zone access.");
|
|
||||||
authenticated = true;
|
|
||||||
}
|
|
||||||
delete pack;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
switch(pack->opcode)
|
case ServerOP_ZAAuth:
|
||||||
{
|
{
|
||||||
case 0:
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Got authentication from UCS when they are already authenticated.");
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ServerOP_KeepAlive:
|
default:
|
||||||
{
|
{
|
||||||
// ignore this
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Unknown ServerOPcode from UCS 0x%04x, size %d", opcode, pack->size);
|
||||||
break;
|
DumpPacket(pack->pBuffer, pack->size);
|
||||||
}
|
break;
|
||||||
case ServerOP_ZAAuth:
|
|
||||||
{
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Got authentication from UCS when they are already authenticated.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Unknown ServerOPcode from UCS 0x%04x, size %d", pack->opcode, pack->size);
|
|
||||||
DumpPacket(pack->pBuffer, pack->size);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pack;
|
|
||||||
}
|
}
|
||||||
return(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UCSConnection::SendPacket(ServerPacket* pack)
|
void UCSConnection::SendPacket(ServerPacket* pack)
|
||||||
{
|
{
|
||||||
if(!Stream)
|
if(!Stream)
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
return Stream->SendPacket(pack);
|
Stream->SendPacket(pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UCSConnection::SendMessage(const char *From, const char *Message)
|
void UCSConnection::SendMessage(const char *From, const char *Message)
|
||||||
|
|||||||
16
world/ucs.h
16
world/ucs.h
@ -2,22 +2,22 @@
|
|||||||
#define UCS_H
|
#define UCS_H
|
||||||
|
|
||||||
#include "../common/types.h"
|
#include "../common/types.h"
|
||||||
#include "../common/emu_tcp_connection.h"
|
#include "../common/net/servertalk_server_connection.h"
|
||||||
#include "../common/servertalk.h"
|
#include "../common/servertalk.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class UCSConnection
|
class UCSConnection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UCSConnection();
|
UCSConnection();
|
||||||
void SetConnection(EmuTCPConnection *inStream);
|
void SetConnection(std::shared_ptr<EQ::Net::ServertalkServerConnection> connection);
|
||||||
bool Process();
|
void ProcessPacket(uint16 opcode, EQ::Net::Packet &p);
|
||||||
bool SendPacket(ServerPacket* pack);
|
void SendPacket(ServerPacket* pack);
|
||||||
void Disconnect() { if(Stream) Stream->Disconnect(); }
|
void Disconnect() { if(Stream && Stream->Handle()) Stream->Handle()->Disconnect(); }
|
||||||
void SendMessage(const char *From, const char *Message);
|
void SendMessage(const char *From, const char *Message);
|
||||||
private:
|
private:
|
||||||
inline uint32 GetIP() const { return Stream ? Stream->GetrIP() : 0; }
|
inline std::string GetIP() const { return (Stream && Stream->Handle()) ? Stream->Handle()->RemoteIP() : 0; }
|
||||||
EmuTCPConnection *Stream;
|
std::shared_ptr<EQ::Net::ServertalkServerConnection> Stream;
|
||||||
bool authenticated;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*UCS_H_*/
|
#endif /*UCS_H_*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user