Streams work on all of the servers now

This commit is contained in:
KimLS 2016-09-29 22:21:39 -07:00
parent a76149c8e3
commit 7a3147a3b3
25 changed files with 128 additions and 181 deletions

View File

@ -26,8 +26,6 @@ SET(common_sources
eqemu_logsys.cpp eqemu_logsys.cpp
eq_limits.cpp eq_limits.cpp
eq_packet.cpp eq_packet.cpp
eq_stream.cpp
eq_stream_factory.cpp
eq_stream_ident.cpp eq_stream_ident.cpp
eq_stream_proxy.cpp eq_stream_proxy.cpp
eqtime.cpp eqtime.cpp
@ -69,7 +67,6 @@ SET(common_sources
tcp_connection.cpp tcp_connection.cpp
tcp_server.cpp tcp_server.cpp
textures.cpp textures.cpp
timeoutmgr.cpp
timer.cpp timer.cpp
unix.cpp unix.cpp
worldconn.cpp worldconn.cpp
@ -142,13 +139,10 @@ SET(common_headers
eqemu_logsys.h eqemu_logsys.h
eq_limits.h eq_limits.h
eq_packet.h eq_packet.h
eq_stream.h
eq_stream_factory.h
eq_stream_ident.h eq_stream_ident.h
eq_stream_intf.h eq_stream_intf.h
eq_stream_locator.h eq_stream_locator.h
eq_stream_proxy.h eq_stream_proxy.h
eq_stream_type.h
eqtime.h eqtime.h
errmsg.h errmsg.h
extprofile.h extprofile.h
@ -205,7 +199,6 @@ SET(common_headers
tcp_connection.h tcp_connection.h
tcp_server.h tcp_server.h
textures.h textures.h
timeoutmgr.h
timer.h timer.h
types.h types.h
unix.h unix.h

View File

@ -4,7 +4,7 @@
#include "eqemu_logsys.h" #include "eqemu_logsys.h"
#include "eq_stream_ident.h" #include "eq_stream_ident.h"
#include "eq_stream_proxy.h" #include "eq_stream_proxy.h"
#include "misc.h"
EQStreamIdentifier::~EQStreamIdentifier() { EQStreamIdentifier::~EQStreamIdentifier() {
while(!m_identified.empty()) { while(!m_identified.empty()) {
@ -98,14 +98,14 @@ void EQStreamIdentifier::Process() {
Patch *p = *curp; Patch *p = *curp;
//ask the stream to see if it matches the supplied signature //ask the stream to see if it matches the supplied signature
EQStream::MatchState res = r.stream->CheckSignature(&p->signature); EQStreamInterface::MatchState res = r.stream->CheckSignature(&p->signature);
switch(res) { switch(res) {
case EQStream::MatchNotReady: case EQStreamInterface::MatchNotReady:
//the stream has not received enough packets to compare with this signature //the stream has not received enough packets to compare with this signature
// Log.LogDebugType(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: Tried patch %s, but stream is not ready for it.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str()); // Log.LogDebugType(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: Tried patch %s, but stream is not ready for it.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str());
all_ready = false; all_ready = false;
break; break;
case EQStream::MatchSuccessful: { case EQStreamInterface::MatchSuccessful: {
//yay, a match. //yay, a match.
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Identified stream %s:%d with signature %s", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str()); Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Identified stream %s:%d with signature %s", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str());
@ -120,7 +120,7 @@ void EQStreamIdentifier::Process() {
found_one = true; found_one = true;
break; break;
} }
case EQStream::MatchFailed: case EQStreamInterface::MatchFailed:
//do nothing... //do nothing...
Log.Out(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: Tried patch %s, and it did not match.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str()); Log.Out(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: Tried patch %s, and it did not match.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str());
break; break;

View File

@ -1,7 +1,7 @@
#ifndef EQSTREAMIDENT_H_ #ifndef EQSTREAMIDENT_H_
#define EQSTREAMIDENT_H_ #define EQSTREAMIDENT_H_
#include "eq_stream.h" #include "eq_stream_intf.h"
#include "timer.h" #include "timer.h"
#include <vector> #include <vector>
#include <queue> #include <queue>

View File

@ -5,6 +5,7 @@
#include <string> #include <string>
#include "emu_versions.h" #include "emu_versions.h"
#include "eq_packet.h"
typedef enum { typedef enum {
ESTABLISHED, ESTABLISHED,

View File

@ -1,7 +1,6 @@
#include "global_define.h" #include "global_define.h"
#include "eq_stream_proxy.h" #include "eq_stream_proxy.h"
#include "eq_stream.h"
#include "struct_strategy.h" #include "struct_strategy.h"

View File

@ -4,7 +4,6 @@
#include "types.h" #include "types.h"
#include "eq_stream_intf.h" #include "eq_stream_intf.h"
#include "eq_stream.h"
#include <memory> #include <memory>
class StructStrategy; class StructStrategy;

View File

@ -46,7 +46,7 @@ void EQ::Net::DaybreakConnectionManager::Attach(uv_loop_t *loop)
uv_timer_start(&m_resend_timer, [](uv_timer_t *handle) { uv_timer_start(&m_resend_timer, [](uv_timer_t *handle) {
DaybreakConnectionManager *c = (DaybreakConnectionManager*)handle->data; DaybreakConnectionManager *c = (DaybreakConnectionManager*)handle->data;
c->ProcessResend(); c->ProcessResend();
}, 10, 10); }, 5, 5);
uv_udp_init(loop, &m_socket); uv_udp_init(loop, &m_socket);
m_socket.data = this; m_socket.data = this;
@ -174,6 +174,10 @@ void EQ::Net::DaybreakConnectionManager::ProcessResend()
void EQ::Net::DaybreakConnectionManager::ProcessPacket(const std::string &endpoint, int port, const char *data, size_t size) void EQ::Net::DaybreakConnectionManager::ProcessPacket(const std::string &endpoint, int port, const char *data, size_t size)
{ {
if (m_options.simulated_in_packet_loss && m_options.simulated_in_packet_loss >= m_rand.Int(0, 100)) {
return;
}
if (size < DaybreakHeader::size()) { if (size < DaybreakHeader::size()) {
Log.OutF(Logs::Detail, Logs::Netcode, "Packet of size {0} which is less than {1}", size, DaybreakHeader::size()); Log.OutF(Logs::Detail, Logs::Netcode, "Packet of size {0} which is less than {1}", size, DaybreakHeader::size());
return; return;
@ -200,7 +204,7 @@ void EQ::Net::DaybreakConnectionManager::ProcessPacket(const std::string &endpoi
connection->ProcessPacket(p); connection->ProcessPacket(p);
} }
else if(data[1] != OP_OutOfSession) { else if(data[1] != OP_OutOfSession) {
SendSessionLost(endpoint, port); SendDisconnect(endpoint, port);
} }
} }
} }
@ -220,11 +224,12 @@ std::shared_ptr<EQ::Net::DaybreakConnection> EQ::Net::DaybreakConnectionManager:
return nullptr; return nullptr;
} }
void EQ::Net::DaybreakConnectionManager::SendSessionLost(const std::string &addr, int port) void EQ::Net::DaybreakConnectionManager::SendDisconnect(const std::string &addr, int port)
{ {
DaybreakHeader header; DaybreakDisconnect header;
header.zero = 0; header.zero = 0;
header.opcode = OP_OutOfSession; header.opcode = OP_SessionDisconnect;
header.connect_code = 0;
WritablePacket out; WritablePacket out;
out.PutSerialize(0, header); out.PutSerialize(0, header);
@ -336,28 +341,28 @@ void EQ::Net::DaybreakConnection::ResetStats()
void EQ::Net::DaybreakConnection::Process() void EQ::Net::DaybreakConnection::Process()
{ {
m_resend_delay = (size_t)(m_rolling_ping * 1.33); try {
m_resend_delay = (size_t)(m_stats.last_stat_ping * m_owner->m_options.resend_delay_factor) + m_owner->m_options.resend_delay_ms;
if (m_resend_delay > 1000) {
m_resend_delay = 1000;
}
if (m_resend_delay < 15) { auto now = Clock::now();
m_resend_delay = 15; auto time_since_hold = (size_t)std::chrono::duration_cast<std::chrono::milliseconds>(now - m_hold_time).count();
if (time_since_hold >= m_owner->m_options.hold_length_ms) {
FlushBuffer();
}
ProcessQueue();
auto time_since_stats = (size_t)std::chrono::duration_cast<std::chrono::milliseconds>(now - m_last_stats).count();
if (m_owner->m_options.stats_delay_ms > 0 && time_since_stats >= m_owner->m_options.stats_delay_ms) {
SendStatSync();
m_last_stats = now;
}
} }
catch (std::exception ex) {
if (m_resend_delay > 1000) { Log.OutF(Logs::Detail, Logs::Netcode, "Error processing connection: {0}", ex.what());
m_resend_delay = 1000;
}
auto now = Clock::now();
auto time_since_hold = (size_t)std::chrono::duration_cast<std::chrono::milliseconds>(now - m_hold_time).count();
if (time_since_hold >= m_owner->m_options.hold_length_ms) {
FlushBuffer();
}
ProcessQueue();
auto time_since_stats = (size_t)std::chrono::duration_cast<std::chrono::milliseconds>(now - m_last_stats).count();
if (m_owner->m_options.stats_delay_ms > 0 && time_since_stats >= m_owner->m_options.stats_delay_ms) {
SendStatSync();
m_last_stats = now;
} }
} }
@ -954,10 +959,19 @@ void EQ::Net::DaybreakConnection::ProcessResend(int stream)
auto s = &m_streams[stream]; auto s = &m_streams[stream];
for (auto &entry : s->sent_packets) { for (auto &entry : s->sent_packets) {
auto time_since_last_send = std::chrono::duration_cast<std::chrono::milliseconds>(now - entry.second.last_sent); auto time_since_last_send = std::chrono::duration_cast<std::chrono::milliseconds>(now - entry.second.last_sent);
if ((size_t)time_since_last_send.count() > m_resend_delay) { if(entry.second.times_resent == 0) {
InternalBufferedSend(entry.second.packet); if ((size_t)time_since_last_send.count() > m_resend_delay) {
entry.second.last_sent = now; InternalBufferedSend(entry.second.packet);
entry.second.times_resent++; entry.second.last_sent = now;
entry.second.times_resent++;
}
}
else {
if ((size_t)time_since_last_send.count() > std::min(m_resend_delay / (entry.second.times_resent + 1), 5ULL)) {
InternalBufferedSend(entry.second.packet);
entry.second.last_sent = now;
entry.second.times_resent++;
}
} }
} }
} }
@ -1042,6 +1056,7 @@ void EQ::Net::DaybreakConnection::SendStatSync()
request.packets_sent = m_stats.sent_packets + 1; request.packets_sent = m_stats.sent_packets + 1;
request.packets_recv = m_stats.recv_packets; request.packets_recv = m_stats.recv_packets;
m_last_session_stats = Clock::now(); m_last_session_stats = Clock::now();
//InternalSend()
} }
void EQ::Net::DaybreakConnection::InternalBufferedSend(Packet &p) void EQ::Net::DaybreakConnection::InternalBufferedSend(Packet &p)
@ -1130,9 +1145,14 @@ void EQ::Net::DaybreakConnection::InternalSend(Packet &p)
send_buffers[0].base = (char*)out.Data(); send_buffers[0].base = (char*)out.Data();
send_buffers[0].len = out.Length(); send_buffers[0].len = out.Length();
uv_udp_send(send_req, &m_owner->m_socket, send_buffers, 1, (sockaddr*)&send_addr, send_func);
m_stats.sent_bytes += out.Length(); m_stats.sent_bytes += out.Length();
m_stats.sent_packets++; m_stats.sent_packets++;
if (m_owner->m_options.simulated_out_packet_loss && m_owner->m_options.simulated_out_packet_loss >= m_owner->m_rand.Int(0, 100)) {
delete send_req;
return;
}
uv_udp_send(send_req, &m_owner->m_socket, send_buffers, 1, (sockaddr*)&send_addr, send_func);
return; return;
} }
@ -1144,9 +1164,15 @@ void EQ::Net::DaybreakConnection::InternalSend(Packet &p)
send_buffers[0].base = (char*)p.Data(); send_buffers[0].base = (char*)p.Data();
send_buffers[0].len = p.Length(); send_buffers[0].len = p.Length();
uv_udp_send(send_req, &m_owner->m_socket, send_buffers, 1, (sockaddr*)&send_addr, send_func);
m_stats.sent_bytes += p.Length(); m_stats.sent_bytes += p.Length();
m_stats.sent_packets++; m_stats.sent_packets++;
if (m_owner->m_options.simulated_out_packet_loss && m_owner->m_options.simulated_out_packet_loss >= m_owner->m_rand.Int(0, 100)) {
delete send_req;
return;
}
uv_udp_send(send_req, &m_owner->m_socket, send_buffers, 1, (sockaddr*)&send_addr, send_func);
} }
void EQ::Net::DaybreakConnection::InternalQueuePacket(Packet &p, int stream_id, bool reliable) void EQ::Net::DaybreakConnection::InternalQueuePacket(Packet &p, int stream_id, bool reliable)

View File

@ -217,10 +217,11 @@ namespace EQ
DaybreakConnectionManagerOptions() { DaybreakConnectionManagerOptions() {
max_connection_count = 0; max_connection_count = 0;
keepalive_delay_ms = 0; keepalive_delay_ms = 0;
resend_delay_ms = 1000; resend_delay_ms = 10;
resend_delay_factor = 1.25;
stats_delay_ms = 0; stats_delay_ms = 0;
connect_delay_ms = 1000; connect_delay_ms = 1000;
stale_connection_ms = 60000; stale_connection_ms = 135000;
crc_length = 2; crc_length = 2;
max_packet_size = 512; max_packet_size = 512;
encode_passes[0] = DaybreakEncodeType::EncodeNone; encode_passes[0] = DaybreakEncodeType::EncodeNone;
@ -228,11 +229,14 @@ namespace EQ
port = 0; port = 0;
hold_size = 384; hold_size = 384;
hold_length_ms = 50; hold_length_ms = 50;
simulated_in_packet_loss = 0;
simulated_out_packet_loss = 0;
} }
size_t max_packet_size; size_t max_packet_size;
size_t max_connection_count; size_t max_connection_count;
size_t keepalive_delay_ms; size_t keepalive_delay_ms;
double resend_delay_factor;
size_t resend_delay_ms; size_t resend_delay_ms;
size_t stats_delay_ms; size_t stats_delay_ms;
size_t connect_delay_ms; size_t connect_delay_ms;
@ -240,6 +244,8 @@ namespace EQ
size_t crc_length; size_t crc_length;
size_t hold_size; size_t hold_size;
size_t hold_length_ms; size_t hold_length_ms;
size_t simulated_in_packet_loss;
size_t simulated_out_packet_loss;
DaybreakEncodeType encode_passes[2]; DaybreakEncodeType encode_passes[2];
int port; int port;
}; };
@ -274,7 +280,7 @@ namespace EQ
void ProcessPacket(const std::string &endpoint, int port, const char *data, size_t size); void ProcessPacket(const std::string &endpoint, int port, const char *data, size_t size);
std::shared_ptr<DaybreakConnection> FindConnectionByEndpoint(std::string addr, int port); std::shared_ptr<DaybreakConnection> FindConnectionByEndpoint(std::string addr, int port);
void SendSessionLost(const std::string &addr, int port); void SendDisconnect(const std::string &addr, int port);
friend class DaybreakConnection; friend class DaybreakConnection;
}; };

View File

@ -37,7 +37,7 @@
#include <stdarg.h> #include <stdarg.h>
#endif #endif
#include "eq_stream.h" #include "eq_stream_intf.h"
#include "packet_dump_file.h" #include "packet_dump_file.h"
void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip) { void FileDumpPacketAscii(const char* filename, const uchar* buf, uint32 size, uint32 cols, uint32 skip) {

View File

@ -3,7 +3,8 @@
#include "eqemu_logsys.h" #include "eqemu_logsys.h"
#include "struct_strategy.h" #include "struct_strategy.h"
#include "eq_stream.h" #include "eq_stream_intf.h"
#include "opcodemgr.h"
#include <map> #include <map>
#include <memory> #include <memory>

View File

@ -41,16 +41,12 @@ ADD_EXECUTABLE(loginserver ${eqlogin_sources} ${eqlogin_headers})
INSTALL(TARGETS loginserver RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) INSTALL(TARGETS loginserver RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
TARGET_LINK_LIBRARIES(loginserver common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) TARGET_LINK_LIBRARIES(loginserver common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY} libuv fmt)
IF(MSVC) IF(WIN32)
SET_TARGET_PROPERTIES(loginserver PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") TARGET_LINK_LIBRARIES(loginserver "ws2_32" "psapi" "iphlpapi" "userenv")
TARGET_LINK_LIBRARIES(loginserver "Ws2_32.lib") ENDIF(WIN32)
ENDIF(MSVC)
IF(MINGW)
TARGET_LINK_LIBRARIES(loginserver "WS2_32")
ENDIF(MINGW)
IF(UNIX) IF(UNIX)
TARGET_LINK_LIBRARIES(loginserver "${CMAKE_DL_LIBS}") TARGET_LINK_LIBRARIES(loginserver "${CMAKE_DL_LIBS}")

View File

@ -20,13 +20,13 @@
#include "../common/global_define.h" #include "../common/global_define.h"
#include "../common/opcodemgr.h" #include "../common/opcodemgr.h"
#include "../common/eq_stream_type.h"
#include "../common/eq_stream_factory.h"
#include "../common/random.h" #include "../common/random.h"
#ifndef WIN32 #ifndef WIN32
#include "eq_crypto_api.h" #include "eq_crypto_api.h"
#endif #endif
#include <string>
#include <memory>
#include "../common/eq_stream_intf.h"
using namespace std; using namespace std;

View File

@ -27,7 +27,8 @@ extern EQEmuLogSys Log;
ClientManager::ClientManager() ClientManager::ClientManager()
{ {
int titanium_port = atoi(server.config->GetVariable("Titanium", "port").c_str()); int titanium_port = atoi(server.config->GetVariable("Titanium", "port").c_str());
titanium_stream = new EQStreamFactory(LoginStream, titanium_port); EQ::Net::EQStreamManagerOptions titanium_opts(titanium_port, false, false);
titanium_stream = new EQ::Net::EQStreamManager(titanium_opts);
titanium_ops = new RegularOpcodeManager; titanium_ops = new RegularOpcodeManager;
if(!titanium_ops->LoadOpcodes(server.config->GetVariable("Titanium", "opcodes").c_str())) if(!titanium_ops->LoadOpcodes(server.config->GetVariable("Titanium", "opcodes").c_str()))
{ {
@ -36,18 +37,16 @@ ClientManager::ClientManager()
run_server = false; run_server = false;
} }
if(titanium_stream->Open()) titanium_stream->OnNewConnection([this](std::shared_ptr<EQ::Net::EQStream> stream) {
{ Log.OutF(Logs::General, Logs::Login_Server, "New Titanium client connection from {0}:{1}", stream->RemoteEndpoint(), stream->GetRemotePort());
Log.Out(Logs::General, Logs::Login_Server, "ClientManager listening on Titanium stream."); stream->SetOpcodeManager(&titanium_ops);
} Client *c = new Client(stream, cv_titanium);
else clients.push_back(c);
{ });
Log.Out(Logs::General, Logs::Error, "ClientManager fatal error: couldn't open Titanium stream.");
run_server = false;
}
int sod_port = atoi(server.config->GetVariable("SoD", "port").c_str()); int sod_port = atoi(server.config->GetVariable("SoD", "port").c_str());
sod_stream = new EQStreamFactory(LoginStream, sod_port); EQ::Net::EQStreamManagerOptions sod_opts(sod_port, false, false);
sod_stream = new EQ::Net::EQStreamManager(sod_opts);
sod_ops = new RegularOpcodeManager; sod_ops = new RegularOpcodeManager;
if(!sod_ops->LoadOpcodes(server.config->GetVariable("SoD", "opcodes").c_str())) if(!sod_ops->LoadOpcodes(server.config->GetVariable("SoD", "opcodes").c_str()))
{ {
@ -56,22 +55,18 @@ ClientManager::ClientManager()
run_server = false; run_server = false;
} }
if(sod_stream->Open()) sod_stream->OnNewConnection([this](std::shared_ptr<EQ::Net::EQStream> stream) {
{ Log.OutF(Logs::General, Logs::Login_Server, "New SoD client connection from {0}:{1}", stream->RemoteEndpoint(), stream->GetRemotePort());
Log.Out(Logs::General, Logs::Login_Server, "ClientManager listening on SoD stream."); stream->SetOpcodeManager(&sod_ops);
} Client *c = new Client(stream, cv_sod);
else clients.push_back(c);
{ });
Log.Out(Logs::General, Logs::Error, "ClientManager fatal error: couldn't open SoD stream.");
run_server = false;
}
} }
ClientManager::~ClientManager() ClientManager::~ClientManager()
{ {
if(titanium_stream) if(titanium_stream)
{ {
titanium_stream->Close();
delete titanium_stream; delete titanium_stream;
} }
@ -82,7 +77,6 @@ ClientManager::~ClientManager()
if(sod_stream) if(sod_stream)
{ {
sod_stream->Close();
delete sod_stream; delete sod_stream;
} }
@ -95,31 +89,6 @@ ClientManager::~ClientManager()
void ClientManager::Process() void ClientManager::Process()
{ {
ProcessDisconnect(); ProcessDisconnect();
std::shared_ptr<EQStreamInterface> cur = titanium_stream->Pop();
while(cur)
{
struct in_addr in;
in.s_addr = cur->GetRemoteIP();
Log.Out(Logs::General, Logs::Login_Server, "New Titanium client connection from %s:%d", inet_ntoa(in), ntohs(cur->GetRemotePort()));
cur->SetOpcodeManager(&titanium_ops);
Client *c = new Client(cur, cv_titanium);
clients.push_back(c);
cur = titanium_stream->Pop();
}
cur = sod_stream->Pop();
while(cur)
{
struct in_addr in;
in.s_addr = cur->GetRemoteIP();
Log.Out(Logs::General, Logs::Login_Server, "New SoD client connection from %s:%d", inet_ntoa(in), ntohs(cur->GetRemotePort()));
cur->SetOpcodeManager(&sod_ops);
Client *c = new Client(cur, cv_sod);
clients.push_back(c);
cur = sod_stream->Pop();
}
list<Client*>::iterator iter = clients.begin(); list<Client*>::iterator iter = clients.begin();
while(iter != clients.end()) while(iter != clients.end())

View File

@ -20,8 +20,7 @@
#include "../common/global_define.h" #include "../common/global_define.h"
#include "../common/opcodemgr.h" #include "../common/opcodemgr.h"
#include "../common/eq_stream_type.h" #include "../common/net/eqstream.h"
#include "../common/eq_stream_factory.h"
#include "client.h" #include "client.h"
#include <list> #include <list>
@ -71,9 +70,9 @@ private:
list<Client*> clients; list<Client*> clients;
OpcodeManager *titanium_ops; OpcodeManager *titanium_ops;
EQStreamFactory *titanium_stream; EQ::Net::EQStreamManager *titanium_stream;
OpcodeManager *sod_ops; OpcodeManager *sod_ops;
EQStreamFactory *sod_stream; EQ::Net::EQStreamManager *sod_stream;
}; };
#endif #endif

View File

@ -18,7 +18,7 @@
#include "../common/global_define.h" #include "../common/global_define.h"
#include "../common/types.h" #include "../common/types.h"
#include "../common/opcodemgr.h" #include "../common/opcodemgr.h"
#include "../common/eq_stream_factory.h" #include "../common/event/event_loop.h"
#include "../common/timer.h" #include "../common/timer.h"
#include "../common/platform.h" #include "../common/platform.h"
#include "../common/crash.h" #include "../common/crash.h"
@ -29,7 +29,6 @@
#include <string> #include <string>
#include <sstream> #include <sstream>
TimeoutManager timeout_manager;
LoginServer server; LoginServer server;
EQEmuLogSys Log; EQEmuLogSys Log;
bool run_server = true; bool run_server = true;
@ -199,8 +198,8 @@ int main()
Timer::SetCurrentTime(); Timer::SetCurrentTime();
server.client_manager->Process(); server.client_manager->Process();
server.server_manager->Process(); server.server_manager->Process();
timeout_manager.CheckTimeouts(); EQ::EventLoop::Get().Process();
Sleep(100); Sleep(1);
} }
Log.Out(Logs::General, Logs::Login_Server, "Server Shutdown."); Log.Out(Logs::General, Logs::Login_Server, "Server Shutdown.");

View File

@ -19,7 +19,6 @@
#define EQEMU_SERVERMANAGER_H #define EQEMU_SERVERMANAGER_H
#include "../common/global_define.h" #include "../common/global_define.h"
#include "../common/eq_stream_factory.h"
#include "../common/emu_tcp_connection.h" #include "../common/emu_tcp_connection.h"
#include "../common/emu_tcp_server.h" #include "../common/emu_tcp_server.h"
#include "../common/servertalk.h" #include "../common/servertalk.h"

View File

@ -19,7 +19,6 @@
#define EQEMU_WORLDSERVER_H #define EQEMU_WORLDSERVER_H
#include "../common/global_define.h" #include "../common/global_define.h"
#include "../common/eq_stream_factory.h"
#include "../common/emu_tcp_connection.h" #include "../common/emu_tcp_connection.h"
#include "../common/emu_tcp_server.h" #include "../common/emu_tcp_server.h"
#include "../common/servertalk.h" #include "../common/servertalk.h"

View File

@ -20,7 +20,6 @@
#include "../common/global_define.h" #include "../common/global_define.h"
#include "../common/eqemu_logsys.h" #include "../common/eqemu_logsys.h"
#include "../common/opcodemgr.h" #include "../common/opcodemgr.h"
#include "../common/eq_stream_factory.h"
#include "../common/rulesys.h" #include "../common/rulesys.h"
#include "../common/servertalk.h" #include "../common/servertalk.h"
#include "../common/platform.h" #include "../common/platform.h"
@ -34,7 +33,6 @@
volatile bool RunLoops = true; volatile bool RunLoops = true;
TimeoutManager timeout_manager;
Database database; Database database;
LFGuildManager lfguildmanager; LFGuildManager lfguildmanager;
std::string WorldShortName; std::string WorldShortName;
@ -117,8 +115,7 @@ int main() {
worldserver->AsyncConnect(); worldserver->AsyncConnect();
} }
worldserver->Process(); worldserver->Process();
timeout_manager.CheckTimeouts(); Sleep(1);
Sleep(100);
} }
Log.CloseFileLogs(); Log.CloseFileLogs();
} }

View File

@ -23,16 +23,11 @@ INSTALL(TARGETS ucs RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
ADD_DEFINITIONS(-DUCS) ADD_DEFINITIONS(-DUCS)
TARGET_LINK_LIBRARIES(ucs common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) TARGET_LINK_LIBRARIES(ucs common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY} libuv fmt)
IF(MSVC) IF(WIN32)
SET_TARGET_PROPERTIES(ucs PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") TARGET_LINK_LIBRARIES(ucs "ws2_32" "psapi" "iphlpapi" "userenv")
TARGET_LINK_LIBRARIES(ucs "Ws2_32.lib") ENDIF(WIN32)
ENDIF(MSVC)
IF(MINGW)
TARGET_LINK_LIBRARIES(ucs "WS2_32")
ENDIF(MINGW)
IF(UNIX) IF(UNIX)
TARGET_LINK_LIBRARIES(ucs "${CMAKE_DL_LIBS}") TARGET_LINK_LIBRARIES(ucs "${CMAKE_DL_LIBS}")

View File

@ -25,7 +25,6 @@
#include "database.h" #include "database.h"
#include "chatchannel.h" #include "chatchannel.h"
#include "../common/eq_stream_factory.h"
#include "../common/emu_tcp_connection.h" #include "../common/emu_tcp_connection.h"
#include "../common/emu_tcp_server.h" #include "../common/emu_tcp_server.h"
#include <list> #include <list>
@ -468,21 +467,22 @@ static void ProcessCommandIgnore(Client *c, std::string Ignoree) {
} }
Clientlist::Clientlist(int ChatPort) { Clientlist::Clientlist(int ChatPort) {
EQ::Net::EQStreamManagerOptions chat_opts(ChatPort, false, false);
chatsf = new EQStreamFactory(ChatStream, ChatPort, 45000); chat_opts.opcode_size = 1;
chatsf = new EQ::Net::EQStreamManager(chat_opts);
ChatOpMgr = new RegularOpcodeManager; ChatOpMgr = new RegularOpcodeManager;
if(!ChatOpMgr->LoadOpcodes("mail_opcodes.conf")) if(!ChatOpMgr->LoadOpcodes("mail_opcodes.conf"))
exit(1); exit(1);
if (chatsf->Open()) chatsf->OnNewConnection([this](std::shared_ptr<EQ::Net::EQStream> stream) {
Log.Out(Logs::Detail, Logs::UCS_Server,"Client (UDP) Chat listener started on port %i.", ChatPort); Log.OutF(Logs::General, Logs::Login_Server, "New Client UDP connection from {0}:{1}", stream->RemoteEndpoint(), stream->GetRemotePort());
else { stream->SetOpcodeManager(&ChatOpMgr);
Log.Out(Logs::Detail, Logs::UCS_Server,"Failed to start client (UDP) listener (port %-4i)", ChatPort);
exit(1); auto c = new Client(stream);
} ClientChatConnections.push_back(c);
});
} }
Client::Client(std::shared_ptr<EQStreamInterface> eqs) { Client::Client(std::shared_ptr<EQStreamInterface> eqs) {
@ -574,21 +574,6 @@ void Clientlist::CheckForStaleConnections(Client *c) {
void Clientlist::Process() void Clientlist::Process()
{ {
std::shared_ptr<EQStreamInterface> eqs;
while ((eqs = chatsf->Pop())) {
struct in_addr in;
in.s_addr = eqs->GetRemoteIP();
Log.Out(Logs::Detail, Logs::UCS_Server, "New Client UDP connection from %s:%d", inet_ntoa(in),
ntohs(eqs->GetRemotePort()));
eqs->SetOpcodeManager(&ChatOpMgr);
auto c = new Client(eqs);
ClientChatConnections.push_back(c);
}
auto it = ClientChatConnections.begin(); auto it = ClientChatConnections.begin();
while (it != ClientChatConnections.end()) { while (it != ClientChatConnections.end()) {
(*it)->AccountUpdate(); (*it)->AccountUpdate();
@ -614,7 +599,7 @@ void Clientlist::Process()
switch (opcode) { switch (opcode) {
case OP_MailLogin: { case OP_MailLogin: {
char *PacketBuffer = (char *)app->pBuffer; char *PacketBuffer = (char *)app->pBuffer + 1;
char MailBox[64]; char MailBox[64];
char Key[64]; char Key[64];
char ConnectionTypeIndicator; char ConnectionTypeIndicator;
@ -668,7 +653,7 @@ void Clientlist::Process()
} }
case OP_Mail: { case OP_Mail: {
std::string CommandString = (const char *)app->pBuffer; std::string CommandString = (const char *)app->pBuffer + 1;
ProcessOPMailCommand((*it), CommandString); ProcessOPMailCommand((*it), CommandString);
break; break;
} }

View File

@ -21,8 +21,7 @@
#define CHATSERVER_CLIENTLIST_H #define CHATSERVER_CLIENTLIST_H
#include "../common/opcodemgr.h" #include "../common/opcodemgr.h"
#include "../common/eq_stream_type.h" #include "../common/net/eqstream.h"
#include "../common/eq_stream_factory.h"
#include "../common/rulesys.h" #include "../common/rulesys.h"
#include "chatchannel.h" #include "chatchannel.h"
#include <list> #include <list>
@ -185,7 +184,7 @@ public:
private: private:
EQStreamFactory *chatsf; EQ::Net::EQStreamManager *chatsf;
std::list<Client*> ClientChatConnections; std::list<Client*> ClientChatConnections;

View File

@ -21,11 +21,11 @@
#include "../common/global_define.h" #include "../common/global_define.h"
#include "clientlist.h" #include "clientlist.h"
#include "../common/opcodemgr.h" #include "../common/opcodemgr.h"
#include "../common/eq_stream_factory.h"
#include "../common/rulesys.h" #include "../common/rulesys.h"
#include "../common/servertalk.h" #include "../common/servertalk.h"
#include "../common/platform.h" #include "../common/platform.h"
#include "../common/crash.h" #include "../common/crash.h"
#include "../common/event/event_loop.h"
#include "database.h" #include "database.h"
#include "ucsconfig.h" #include "ucsconfig.h"
#include "chatchannel.h" #include "chatchannel.h"
@ -36,7 +36,6 @@
ChatChannelList *ChannelList; ChatChannelList *ChannelList;
Clientlist *g_Clientlist; Clientlist *g_Clientlist;
EQEmuLogSys Log; EQEmuLogSys Log;
TimeoutManager timeout_manager;
Database database; Database database;
WorldServer *worldserver = nullptr; WorldServer *worldserver = nullptr;
@ -158,9 +157,9 @@ int main() {
} }
worldserver->Process(); worldserver->Process();
timeout_manager.CheckTimeouts(); EQ::EventLoop::Get().Process();
Sleep(100); Sleep(1);
} }
ChannelList->RemoveAllChannels(); ChannelList->RemoveAllChannels();

View File

@ -20,7 +20,6 @@
#include <string> #include <string>
//#include "../common/eq_stream.h"
#include "../common/linked_list.h" #include "../common/linked_list.h"
#include "../common/timer.h" #include "../common/timer.h"
//#include "zoneserver.h" //#include "zoneserver.h"

View File

@ -28,16 +28,12 @@
#include "../common/eqemu_logsys.h" #include "../common/eqemu_logsys.h"
#include "../common/queue.h" #include "../common/queue.h"
#include "../common/timer.h" #include "../common/timer.h"
#include "../common/eq_stream_factory.h"
#include "../common/eq_packet.h" #include "../common/eq_packet.h"
#include "../common/seperator.h" #include "../common/seperator.h"
#include "../common/version.h" #include "../common/version.h"
#include "../common/eqtime.h" #include "../common/eqtime.h"
#include "../common/timeoutmgr.h"
#include "../common/event/event_loop.h" #include "../common/event/event_loop.h"
#include "../common/net/eqstream.h" #include "../common/net/eqstream.h"
#include "../common/opcodemgr.h" #include "../common/opcodemgr.h"
#include "../common/guilds.h" #include "../common/guilds.h"
#include "../common/eq_stream_ident.h" #include "../common/eq_stream_ident.h"
@ -90,7 +86,6 @@
#include "ucs.h" #include "ucs.h"
#include "queryserv.h" #include "queryserv.h"
TimeoutManager timeout_manager;
EmuTCPServer tcps; EmuTCPServer tcps;
ClientList client_list; ClientList client_list;
GroupLFPList LFPGroupList; GroupLFPList LFPGroupList;
@ -395,7 +390,7 @@ int main(int argc, char** argv) {
return 1; return 1;
} }
EQ::Net::EQStreamManagerOptions opts(9000, false, true); EQ::Net::EQStreamManagerOptions opts(9000, false, false);
EQ::Net::EQStreamManager eqsm(opts); EQ::Net::EQStreamManager eqsm(opts);
//register all the patches we have avaliable with the stream identifier. //register all the patches we have avaliable with the stream identifier.
@ -492,8 +487,6 @@ int main(int argc, char** argv) {
Log.Out(Logs::Detail, Logs::World_Server, "EQTime successfully saved."); Log.Out(Logs::Detail, Logs::World_Server, "EQTime successfully saved.");
} }
//check for timeouts in other threads
timeout_manager.CheckTimeouts();
loginserverlist.Process(); loginserverlist.Process();
console_list.Process(); console_list.Process();
zoneserver_list.Process(); zoneserver_list.Process();

View File

@ -23,8 +23,6 @@
#include "../common/features.h" #include "../common/features.h"
#include "../common/queue.h" #include "../common/queue.h"
#include "../common/timer.h" #include "../common/timer.h"
#include "../common/eq_stream.h"
#include "../common/eq_stream_factory.h"
#include "../common/eq_packet_structs.h" #include "../common/eq_packet_structs.h"
#include "../common/mutex.h" #include "../common/mutex.h"
#include "../common/version.h" #include "../common/version.h"
@ -95,7 +93,6 @@
volatile bool RunLoops = true; volatile bool RunLoops = true;
extern volatile bool is_zone_loaded; extern volatile bool is_zone_loaded;
TimeoutManager timeout_manager;
NetConnection net; NetConnection net;
EntityList entity_list; EntityList entity_list;
WorldServer worldserver; WorldServer worldserver;
@ -448,7 +445,7 @@ int main(int argc, char** argv) {
if (!eqsf_open && Config->ZonePort != 0) { if (!eqsf_open && Config->ZonePort != 0) {
Log.Out(Logs::General, Logs::Zone_Server, "Starting EQ Network server on port %d", Config->ZonePort); Log.Out(Logs::General, Logs::Zone_Server, "Starting EQ Network server on port %d", Config->ZonePort);
EQ::Net::EQStreamManagerOptions opts(Config->ZonePort, false, true); EQ::Net::EQStreamManagerOptions opts(Config->ZonePort, false, false);
eqsm.reset(new EQ::Net::EQStreamManager(opts)); eqsm.reset(new EQ::Net::EQStreamManager(opts));
eqsf_open = true; eqsf_open = true;
@ -479,9 +476,6 @@ int main(int argc, char** argv) {
zoneupdate_timer.Trigger(); zoneupdate_timer.Trigger();
} }
//check for timeouts in other threads
timeout_manager.CheckTimeouts();
if (worldserver.Connected()) { if (worldserver.Connected()) {
worldwasconnected = true; worldwasconnected = true;
} }