mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 12:41:30 +00:00
Launcher support added. Still missing UCS but thinking about maybe rewriting it completely
This commit is contained in:
parent
f6ca59fbc6
commit
b7c5de144a
@ -9,7 +9,7 @@ namespace EQ
|
||||
namespace Net
|
||||
{
|
||||
inline bool IsLittleEndian() {
|
||||
static int32_t v = 1;
|
||||
const int32_t v = 1;
|
||||
return 1 == *(int8_t*)&v;
|
||||
}
|
||||
|
||||
|
||||
@ -91,9 +91,6 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
std::map<std::string, ZoneLaunch *> zones;
|
||||
WorldServer world(zones, launcher_name.c_str(), Config);
|
||||
if (!world.Connect()) {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "worldserver.Connect() FAILED! Will retry.");
|
||||
}
|
||||
|
||||
std::map<std::string, ZoneLaunch *>::iterator zone, zend;
|
||||
std::set<std::string> to_remove;
|
||||
@ -108,11 +105,6 @@ int main(int argc, char *argv[]) {
|
||||
//Advance the timer to our current point in time
|
||||
Timer::SetCurrentTime();
|
||||
|
||||
/*
|
||||
* Process the world connection
|
||||
*/
|
||||
world.Process();
|
||||
|
||||
/*
|
||||
* Let the process manager look for dead children
|
||||
*/
|
||||
@ -143,19 +135,8 @@ int main(int argc, char *argv[]) {
|
||||
zones.erase(rem);
|
||||
}
|
||||
|
||||
|
||||
if (InterserverTimer.Check()) {
|
||||
if (world.TryReconnect() && (!world.Connected()))
|
||||
world.AsyncConnect();
|
||||
}
|
||||
|
||||
/*
|
||||
* Take a nice nap until next cycle
|
||||
*/
|
||||
if(zones.empty())
|
||||
Sleep(5000);
|
||||
else
|
||||
Sleep(2000);
|
||||
EQ::EventLoop::Get().Process();
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
//try to be semi-nice about this... without waiting too long
|
||||
|
||||
@ -25,25 +25,27 @@
|
||||
#include "zone_launch.h"
|
||||
|
||||
WorldServer::WorldServer(std::map<std::string, ZoneLaunch *> &zones, const char *name, const EQEmuConfig *config)
|
||||
: WorldConnection(EmuTCPConnection::packetModeLauncher, config->SharedKey.c_str()),
|
||||
m_name(name),
|
||||
: m_name(name),
|
||||
m_config(config),
|
||||
m_zones(zones)
|
||||
{
|
||||
m_connection.reset(new EQ::Net::ServertalkClient(config->WorldIP, config->WorldTCPPort, false, "Launcher", config->SharedKey));
|
||||
m_connection->OnConnect([this](EQ::Net::ServertalkClient *client) {
|
||||
OnConnected();
|
||||
});
|
||||
|
||||
m_connection->OnMessage(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
WorldServer::~WorldServer() {
|
||||
}
|
||||
|
||||
void WorldServer::OnConnected() {
|
||||
WorldConnection::OnConnected();
|
||||
|
||||
auto pack = new ServerPacket(ServerOP_LauncherConnectInfo, sizeof(LauncherConnectInfo));
|
||||
LauncherConnectInfo* sci = (LauncherConnectInfo*) pack->pBuffer;
|
||||
strn0cpy(sci->name, m_name, sizeof(sci->name));
|
||||
// sci->port = net.GetZonePort();
|
||||
// strcpy(sci->address, net.GetZoneAddress());
|
||||
SendPacket(pack);
|
||||
m_connection->SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
|
||||
//send status for all zones...
|
||||
@ -55,82 +57,69 @@ void WorldServer::OnConnected() {
|
||||
}
|
||||
}
|
||||
|
||||
void WorldServer::Process() {
|
||||
void WorldServer::HandleMessage(uint16 opcode, EQ::Net::Packet &p) {
|
||||
ServerPacket tpack(opcode, p);
|
||||
ServerPacket *pack = &tpack;
|
||||
|
||||
WorldConnection::Process();
|
||||
|
||||
if (!Connected())
|
||||
return;
|
||||
|
||||
ServerPacket *pack = 0;
|
||||
while((pack = tcpc.PopPacket())) {
|
||||
switch(pack->opcode) {
|
||||
case 0: {
|
||||
switch(opcode) {
|
||||
case 0: {
|
||||
break;
|
||||
}
|
||||
case ServerOP_EmoteMessage:
|
||||
case ServerOP_KeepAlive: {
|
||||
// ignore this
|
||||
break;
|
||||
}
|
||||
case ServerOP_LauncherZoneRequest: {
|
||||
if(pack->size != sizeof(LauncherZoneRequest)) {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Invalid size of LauncherZoneRequest: %d", pack->size);
|
||||
break;
|
||||
}
|
||||
case ServerOP_EmoteMessage:
|
||||
case ServerOP_KeepAlive: {
|
||||
// ignore this
|
||||
break;
|
||||
}
|
||||
case ServerOP_ZAAuthFailed: {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World server responded 'Not Authorized', disabling reconnect");
|
||||
pTryReconnect = false;
|
||||
Disconnect();
|
||||
break;
|
||||
}
|
||||
case ServerOP_LauncherZoneRequest: {
|
||||
if(pack->size != sizeof(LauncherZoneRequest)) {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Invalid size of LauncherZoneRequest: %d", pack->size);
|
||||
break;
|
||||
}
|
||||
const LauncherZoneRequest *lzr = (const LauncherZoneRequest *) pack->pBuffer;
|
||||
|
||||
switch(ZoneRequestCommands(lzr->command)) {
|
||||
case ZR_Start: {
|
||||
if(m_zones.find(lzr->short_name) != m_zones.end()) {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to start zone %s, but it is already running.", lzr->short_name);
|
||||
} else {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to start zone %s.", lzr->short_name);
|
||||
auto l = new ZoneLaunch(this, m_name, lzr->short_name, lzr->port, m_config);
|
||||
m_zones[lzr->short_name] = l;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ZR_Restart: {
|
||||
auto res = m_zones.find(lzr->short_name);
|
||||
if(res == m_zones.end()) {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to restart zone %s, but it is not running.", lzr->short_name);
|
||||
} else {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to restart zone %s.", lzr->short_name);
|
||||
res->second->Restart();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ZR_Stop: {
|
||||
auto res = m_zones.find(lzr->short_name);
|
||||
if(res == m_zones.end()) {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to stop zone %s, but it is not running.", lzr->short_name);
|
||||
} else {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to stop zone %s.", lzr->short_name);
|
||||
res->second->Stop();
|
||||
}
|
||||
break;
|
||||
}
|
||||
const LauncherZoneRequest *lzr = (const LauncherZoneRequest *) pack->pBuffer;
|
||||
|
||||
switch(ZoneRequestCommands(lzr->command)) {
|
||||
case ZR_Start: {
|
||||
if(m_zones.find(lzr->short_name) != m_zones.end()) {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to start zone %s, but it is already running.", lzr->short_name);
|
||||
} else {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to start zone %s.", lzr->short_name);
|
||||
auto l = new ZoneLaunch(this, m_name, lzr->short_name, lzr->port, m_config);
|
||||
m_zones[lzr->short_name] = l;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_GroupIDReply: {
|
||||
//ignore this, world is still being dumb
|
||||
case ZR_Restart: {
|
||||
auto res = m_zones.find(lzr->short_name);
|
||||
if(res == m_zones.end()) {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to restart zone %s, but it is not running.", lzr->short_name);
|
||||
} else {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to restart zone %s.", lzr->short_name);
|
||||
res->second->Restart();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Unknown opcode 0x%x from World of len %d", pack->opcode, pack->size);
|
||||
case ZR_Stop: {
|
||||
auto res = m_zones.find(lzr->short_name);
|
||||
if(res == m_zones.end()) {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to stop zone %s, but it is not running.", lzr->short_name);
|
||||
} else {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to stop zone %s.", lzr->short_name);
|
||||
res->second->Stop();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
safe_delete(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_GroupIDReply: {
|
||||
//ignore this, world is still being dumb
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Unknown opcode 0x%x from World of len %d", pack->opcode, pack->size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,12 +133,6 @@ void WorldServer::SendStatus(const char *short_name, uint32 start_count, bool ru
|
||||
it->start_count = start_count;
|
||||
it->running = running?1:0;
|
||||
|
||||
SendPacket(pack);
|
||||
m_connection->SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -18,7 +18,8 @@
|
||||
#ifndef WORLDSERVER_H
|
||||
#define WORLDSERVER_H
|
||||
|
||||
#include "../common/worldconn.h"
|
||||
#include "../common/net/servertalk_client_connection.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
@ -26,18 +27,19 @@
|
||||
class ZoneLaunch;
|
||||
class EQEmuConfig;
|
||||
|
||||
class WorldServer : public WorldConnection {
|
||||
class WorldServer {
|
||||
public:
|
||||
WorldServer(std::map<std::string, ZoneLaunch *> &zones, const char *name, const EQEmuConfig *config);
|
||||
virtual ~WorldServer();
|
||||
~WorldServer();
|
||||
|
||||
virtual void Process();
|
||||
void HandleMessage(uint16 opcode, EQ::Net::Packet &p);
|
||||
|
||||
void SendStatus(const char *short_name, uint32 start_count, bool running);
|
||||
|
||||
private:
|
||||
virtual void OnConnected();
|
||||
|
||||
std::unique_ptr<EQ::Net::ServertalkClient> m_connection;
|
||||
const char *const m_name;
|
||||
const EQEmuConfig *const m_config;
|
||||
std::map<std::string, ZoneLaunch *> &m_zones;
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
extern LauncherList launcher_list;
|
||||
|
||||
LauncherLink::LauncherLink(int id, EmuTCPConnection *c)
|
||||
LauncherLink::LauncherLink(int id, std::shared_ptr<EQ::Net::ServertalkServerConnection> c)
|
||||
: ID(id),
|
||||
tcpc(c),
|
||||
authenticated(false),
|
||||
@ -43,143 +43,105 @@ LauncherLink::LauncherLink(int id, EmuTCPConnection *c)
|
||||
{
|
||||
m_dynamicCount = 0;
|
||||
m_bootTimer.Disable();
|
||||
|
||||
tcpc->OnMessage(std::bind(&LauncherLink::ProcessMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_process_timer.reset(new EQ::Timer(100, true, std::bind(&LauncherLink::Process, this, std::placeholders::_1)));
|
||||
}
|
||||
|
||||
LauncherLink::~LauncherLink() {
|
||||
tcpc->Free();
|
||||
}
|
||||
|
||||
bool LauncherLink::Process() {
|
||||
if (!tcpc->Connected())
|
||||
return false;
|
||||
|
||||
if(m_bootTimer.Check(false)) {
|
||||
void LauncherLink::Process(EQ::Timer *t) {
|
||||
if (m_bootTimer.Check(false)) {
|
||||
//force a boot on any zone which isnt running.
|
||||
std::map<std::string, ZoneState>::iterator cur, end;
|
||||
cur = m_states.begin();
|
||||
end = m_states.end();
|
||||
for(; cur != end; ++cur) {
|
||||
if(!cur->second.up) {
|
||||
for (; cur != end; ++cur) {
|
||||
if (!cur->second.up) {
|
||||
StartZone(cur->first.c_str(), cur->second.port);
|
||||
}
|
||||
}
|
||||
m_bootTimer.Disable();
|
||||
}
|
||||
}
|
||||
|
||||
ServerPacket *pack = 0;
|
||||
while((pack = tcpc->PopPacket())) {
|
||||
if (!authenticated) {
|
||||
if (WorldConfig::get()->SharedKey.length() > 0) {
|
||||
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::World_Server, "Launcher 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::World_Server, "Launcher authorization failed.");
|
||||
auto pack = new ServerPacket(ServerOP_ZAAuthFailed);
|
||||
SendPacket(pack);
|
||||
delete pack;
|
||||
Disconnect();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::World_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 0:
|
||||
break;
|
||||
case ServerOP_KeepAlive: {
|
||||
// ignore this
|
||||
break;
|
||||
}
|
||||
case ServerOP_ZAAuth: {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Got authentication from %s when they are already authenticated.", m_name.c_str());
|
||||
break;
|
||||
}
|
||||
case ServerOP_LauncherConnectInfo: {
|
||||
const LauncherConnectInfo *it = (const LauncherConnectInfo *) pack->pBuffer;
|
||||
if(HasName()) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Launcher '%s' received an additional connect packet with name '%s'. Ignoring.", m_name.c_str(), it->name);
|
||||
break;
|
||||
}
|
||||
m_name = it->name;
|
||||
void LauncherLink::ProcessMessage(uint16 opcode, EQ::Net::Packet &p)
|
||||
{
|
||||
ServerPacket tpack(opcode, p);
|
||||
ServerPacket *pack = &tpack;
|
||||
|
||||
EQLConfig *config = launcher_list.GetConfig(m_name.c_str());
|
||||
if(config == nullptr) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Unknown launcher '%s' connected. Disconnecting.", it->name);
|
||||
Disconnect();
|
||||
break;
|
||||
}
|
||||
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Launcher Identified itself as '%s'. Loading zone list.", it->name);
|
||||
|
||||
std::vector<LauncherZone> result;
|
||||
//database.GetLauncherZones(it->name, result);
|
||||
config->GetZones(result);
|
||||
|
||||
std::vector<LauncherZone>::iterator cur, end;
|
||||
cur = result.begin();
|
||||
end = result.end();
|
||||
ZoneState zs;
|
||||
for(; cur != end; cur++) {
|
||||
zs.port = cur->port;
|
||||
zs.up = false;
|
||||
zs.starts = 0;
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "%s: Loaded zone '%s' on port %d", m_name.c_str(), cur->name.c_str(), zs.port);
|
||||
m_states[cur->name] = zs;
|
||||
}
|
||||
|
||||
//now we add all the dynamics.
|
||||
BootDynamics(config->GetDynamicCount());
|
||||
|
||||
m_bootTimer.Start();
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_LauncherZoneStatus: {
|
||||
const LauncherZoneStatus *it = (const LauncherZoneStatus *) pack->pBuffer;
|
||||
std::map<std::string, ZoneState>::iterator res;
|
||||
res = m_states.find(it->short_name);
|
||||
if(res == m_states.end()) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "%s: reported state for zone %s which it does not have.", m_name.c_str(), it->short_name);
|
||||
break;
|
||||
}
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "%s: %s reported state %s (%d starts)", m_name.c_str(), it->short_name, it->running?"STARTED":"STOPPED", it->start_count);
|
||||
res->second.up = it->running;
|
||||
res->second.starts = it->start_count;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Unknown ServerOPcode from launcher 0x%04x, size %d",pack->opcode,pack->size);
|
||||
DumpPacket(pack->pBuffer, pack->size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete pack;
|
||||
switch(opcode) {
|
||||
case 0:
|
||||
break;
|
||||
case ServerOP_KeepAlive: {
|
||||
// ignore this
|
||||
break;
|
||||
}
|
||||
case ServerOP_ZAAuth: {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Got authentication from %s when they are already authenticated.", m_name.c_str());
|
||||
break;
|
||||
}
|
||||
case ServerOP_LauncherConnectInfo: {
|
||||
const LauncherConnectInfo *it = (const LauncherConnectInfo *) pack->pBuffer;
|
||||
if(HasName()) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Launcher '%s' received an additional connect packet with name '%s'. Ignoring.", m_name.c_str(), it->name);
|
||||
break;
|
||||
}
|
||||
m_name = it->name;
|
||||
|
||||
EQLConfig *config = launcher_list.GetConfig(m_name.c_str());
|
||||
if(config == nullptr) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Unknown launcher '%s' connected. Disconnecting.", it->name);
|
||||
Disconnect();
|
||||
break;
|
||||
}
|
||||
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Launcher Identified itself as '%s'. Loading zone list.", it->name);
|
||||
|
||||
std::vector<LauncherZone> result;
|
||||
//database.GetLauncherZones(it->name, result);
|
||||
config->GetZones(result);
|
||||
|
||||
std::vector<LauncherZone>::iterator cur, end;
|
||||
cur = result.begin();
|
||||
end = result.end();
|
||||
ZoneState zs;
|
||||
for(; cur != end; cur++) {
|
||||
zs.port = cur->port;
|
||||
zs.up = false;
|
||||
zs.starts = 0;
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "%s: Loaded zone '%s' on port %d", m_name.c_str(), cur->name.c_str(), zs.port);
|
||||
m_states[cur->name] = zs;
|
||||
}
|
||||
|
||||
//now we add all the dynamics.
|
||||
BootDynamics(config->GetDynamicCount());
|
||||
|
||||
m_bootTimer.Start();
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_LauncherZoneStatus: {
|
||||
const LauncherZoneStatus *it = (const LauncherZoneStatus *) pack->pBuffer;
|
||||
std::map<std::string, ZoneState>::iterator res;
|
||||
res = m_states.find(it->short_name);
|
||||
if(res == m_states.end()) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "%s: reported state for zone %s which it does not have.", m_name.c_str(), it->short_name);
|
||||
break;
|
||||
}
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "%s: %s reported state %s (%d starts)", m_name.c_str(), it->short_name, it->running?"STARTED":"STOPPED", it->start_count);
|
||||
res->second.up = it->running;
|
||||
res->second.starts = it->start_count;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Unknown ServerOPcode from launcher 0x%04x, size %d",pack->opcode,pack->size);
|
||||
DumpPacket(pack->pBuffer, pack->size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool LauncherLink::ContainsZone(const char *short_name) const {
|
||||
|
||||
@ -18,8 +18,10 @@
|
||||
#ifndef LAUNCHERLINK_H_
|
||||
#define LAUNCHERLINK_H_
|
||||
|
||||
#include "../common/emu_tcp_connection.h"
|
||||
#include "../common/timer.h"
|
||||
#include "../net/servertalk_server_connection.h"
|
||||
#include "../event/timer.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
@ -28,21 +30,22 @@ class ServerPacket;
|
||||
|
||||
class LauncherLink {
|
||||
public:
|
||||
LauncherLink(int id, EmuTCPConnection *tcpc);
|
||||
LauncherLink(int id, std::shared_ptr<EQ::Net::ServertalkServerConnection> tcpc);
|
||||
~LauncherLink();
|
||||
|
||||
bool Process();
|
||||
bool SendPacket(ServerPacket* pack) { return tcpc->SendPacket(pack); }
|
||||
// bool SendPacket(TCPConnection::TCPNetPacket_Struct* tnps) { return tcpc->SendPacket(tnps); }
|
||||
void Process(EQ::Timer *t);
|
||||
void ProcessMessage(uint16 opcode, EQ::Net::Packet &p);
|
||||
void SendPacket(ServerPacket* pack) { tcpc->SendPacket(pack); }
|
||||
|
||||
int GetID() const { return(ID); }
|
||||
void Disconnect() { tcpc->Disconnect(); }
|
||||
void Disconnect() { if (tcpc->Handle()) { tcpc->Handle()->Disconnect(); } }
|
||||
|
||||
inline bool HasName() const { return(m_name.length() > 0); }
|
||||
inline uint32 GetIP() const { return tcpc->GetrIP(); }
|
||||
inline uint16 GetPort() const { return tcpc->GetrPort(); }
|
||||
inline bool HasName() const { return(m_name.length() > 0); }
|
||||
inline std::string GetIP() const { return tcpc->Handle() ? tcpc->Handle()->RemoteIP() : 0; }
|
||||
inline uint16 GetPort() const { return tcpc->Handle() ? tcpc->Handle()->RemotePort() : 0; }
|
||||
inline std::string GetUUID() const { return tcpc->GetUUID(); }
|
||||
inline const char * GetName() const { return(m_name.c_str()); }
|
||||
inline int CountZones() const { return(m_states.size()); }
|
||||
inline int CountZones() const { return(m_states.size()); }
|
||||
|
||||
bool ContainsZone(const char *short_name) const;
|
||||
|
||||
@ -60,7 +63,8 @@ public:
|
||||
|
||||
protected:
|
||||
const int ID;
|
||||
EmuTCPConnection*const tcpc;
|
||||
std::shared_ptr<EQ::Net::ServertalkServerConnection> tcpc;
|
||||
std::unique_ptr<EQ::Timer> m_process_timer;
|
||||
bool authenticated;
|
||||
std::string m_name;
|
||||
Timer m_bootTimer;
|
||||
|
||||
@ -52,17 +52,11 @@ LauncherList::~LauncherList() {
|
||||
}
|
||||
|
||||
void LauncherList::Process() {
|
||||
//process pending launchers..
|
||||
std::vector<LauncherLink *>::iterator cur;
|
||||
cur = m_pendingLaunchers.begin();
|
||||
while(cur != m_pendingLaunchers.end()) {
|
||||
LauncherLink *l = *cur;
|
||||
if(!l->Process()) {
|
||||
//launcher has died before it identified itself.
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Removing pending launcher %d", l->GetID());
|
||||
cur = m_pendingLaunchers.erase(cur);
|
||||
delete l;
|
||||
} else if(l->HasName()) {
|
||||
if(l->HasName()) {
|
||||
//launcher has identified itself now.
|
||||
//remove ourself from the pending list
|
||||
cur = m_pendingLaunchers.erase(cur);
|
||||
@ -81,21 +75,6 @@ void LauncherList::Process() {
|
||||
++cur;
|
||||
}
|
||||
}
|
||||
|
||||
//process active launchers.
|
||||
std::map<std::string, LauncherLink *>::iterator curl;
|
||||
curl = m_launchers.begin();
|
||||
while(curl != m_launchers.end()) {
|
||||
LauncherLink *l = curl->second;
|
||||
if(!l->Process()) {
|
||||
//launcher has died before it identified itself.
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Removing launcher %s (%d)", l->GetName(), l->GetID());
|
||||
curl = m_launchers.erase(curl);
|
||||
delete l;
|
||||
} else {
|
||||
++curl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LauncherLink *LauncherList::Get(const char *name) {
|
||||
@ -104,16 +83,6 @@ LauncherLink *LauncherList::Get(const char *name) {
|
||||
if(res == m_launchers.end())
|
||||
return(nullptr);
|
||||
return(res->second);
|
||||
/* std::string goal(name);
|
||||
|
||||
std::vector<LauncherLink *>::iterator cur, end;
|
||||
cur = m_launchers.begin();
|
||||
end = m_launchers.end();
|
||||
for(; cur != end; cur++) {
|
||||
if(goal == (*cur)->GetName())
|
||||
return(*cur);
|
||||
}
|
||||
return(nullptr);*/
|
||||
}
|
||||
|
||||
LauncherLink *LauncherList::FindByZone(const char *short_name) {
|
||||
@ -127,12 +96,33 @@ LauncherLink *LauncherList::FindByZone(const char *short_name) {
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
void LauncherList::Add(EmuTCPConnection *conn) {
|
||||
void LauncherList::Add(std::shared_ptr<EQ::Net::ServertalkServerConnection> conn) {
|
||||
auto it = new LauncherLink(nextID++, conn);
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Adding pending launcher %d", it->GetID());
|
||||
m_pendingLaunchers.push_back(it);
|
||||
}
|
||||
|
||||
void LauncherList::Remove(std::shared_ptr<EQ::Net::ServertalkServerConnection> conn)
|
||||
{
|
||||
auto pendingLauncherIter = m_pendingLaunchers.begin();
|
||||
while (pendingLauncherIter != m_pendingLaunchers.end()) {
|
||||
if ((*pendingLauncherIter)->GetUUID() == conn->GetUUID()) {
|
||||
m_pendingLaunchers.erase(pendingLauncherIter);
|
||||
break;
|
||||
}
|
||||
++pendingLauncherIter;
|
||||
}
|
||||
|
||||
auto launcherIter = m_launchers.begin();
|
||||
while (launcherIter != m_launchers.end()) {
|
||||
if (launcherIter->second->GetUUID() == conn->GetUUID()) {
|
||||
m_launchers.erase(launcherIter);
|
||||
break;
|
||||
}
|
||||
++launcherIter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int LauncherList::GetLauncherCount() {
|
||||
return(m_launchers.size());
|
||||
|
||||
@ -19,12 +19,13 @@
|
||||
#define LAUNCHERLIST_H_
|
||||
|
||||
#include "../common/types.h"
|
||||
#include "../net/servertalk_server_connection.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
class LauncherLink;
|
||||
class EmuTCPConnection;
|
||||
class EQLConfig;
|
||||
|
||||
class LauncherList {
|
||||
@ -39,7 +40,8 @@ public:
|
||||
void CreateLauncher(const char *name, uint8 dynamic_count);
|
||||
void Remove(const char *name);
|
||||
|
||||
void Add(EmuTCPConnection *conn);
|
||||
void Add(std::shared_ptr<EQ::Net::ServertalkServerConnection> conn);
|
||||
void Remove(std::shared_ptr<EQ::Net::ServertalkServerConnection> conn);
|
||||
LauncherLink *Get(const char *name);
|
||||
LauncherLink *FindByZone(const char *short_name);
|
||||
|
||||
@ -49,7 +51,6 @@ public:
|
||||
protected:
|
||||
std::map<std::string, EQLConfig *> m_configs; //we own these objects
|
||||
std::map<std::string, LauncherLink *> m_launchers; //we own these objects
|
||||
// std::map<std::string, EQLConfig *> m_configs; //we own these objects
|
||||
std::vector<LauncherLink *> m_pendingLaunchers; //we own these objects, have not yet identified themself
|
||||
int nextID;
|
||||
};
|
||||
|
||||
@ -409,6 +409,20 @@ int main(int argc, char** argv) {
|
||||
zoneserver_list.Remove(connection->GetUUID());
|
||||
});
|
||||
|
||||
server_connection->OnConnectionIdentified("Launcher", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "New Launcher connection from {2} at {0}:{1}",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
|
||||
launcher_list.Add(connection);
|
||||
});
|
||||
|
||||
server_connection->OnConnectionRemoved("Launcher", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "Removed Launcher connection from {0}",
|
||||
connection->GetUUID());
|
||||
|
||||
launcher_list.Remove(connection);
|
||||
});
|
||||
|
||||
server_connection->OnConnectionIdentified("QueryServ", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "New Query Server connection from {2} at {0}:{1}",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
@ -479,32 +493,6 @@ int main(int argc, char** argv) {
|
||||
|
||||
client_list.Process();
|
||||
|
||||
//while ((tcpc = tcps.NewQueuePop())) {
|
||||
// struct in_addr in;
|
||||
// in.s_addr = tcpc->GetrIP();
|
||||
//
|
||||
// /* World - Tell what is being connected */
|
||||
// if (tcpc->GetMode() == EmuTCPConnection::modePacket) {
|
||||
// if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeZone) {
|
||||
// Log.Out(Logs::General, Logs::World_Server, "New Zone Server from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
// }
|
||||
// else if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeLauncher) {
|
||||
// Log.Out(Logs::General, Logs::World_Server, "New Launcher from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
// }
|
||||
// else if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeUCS) {
|
||||
// Log.Out(Logs::General, Logs::World_Server, "New UCS Connection from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
// }
|
||||
// else if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeQueryServ) {
|
||||
// Log.Out(Logs::General, Logs::World_Server, "New QS Connection from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
// }
|
||||
// else {
|
||||
// Log.Out(Logs::General, Logs::World_Server, "Unsupported packet mode from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// console_list.Add(new Console(tcpc));
|
||||
//}
|
||||
|
||||
if(PurgeInstanceTimer.Check())
|
||||
{
|
||||
database.PurgeExpiredInstances();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user