Upstream merge

This commit is contained in:
Arthur Ice
2014-07-30 14:22:17 -07:00
92 changed files with 4376 additions and 1633 deletions
+2 -4
View File
@@ -23,7 +23,6 @@ SET(world_sources
perl_EQW.cpp
perl_HTTPRequest.cpp
queryserv.cpp
socket_server.cpp
ucs.cpp
wguild_mgr.cpp
world_logsys.cpp
@@ -54,7 +53,6 @@ SET(world_headers
LoginServerList.h
net.h
queryserv.h
socket_server.h
SoFCharCreateData.h
ucs.h
wguild_mgr.h
@@ -71,7 +69,7 @@ INSTALL(TARGETS world RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
ADD_DEFINITIONS(-DWORLD)
TARGET_LINK_LIBRARIES(world Common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
TARGET_LINK_LIBRARIES(world common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
IF(MSVC)
SET_TARGET_PROPERTIES(world PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
@@ -93,4 +91,4 @@ IF(UNIX)
ADD_DEFINITIONS(-fPIC)
ENDIF(UNIX)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/Bin)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
-8
View File
@@ -46,7 +46,6 @@
#include "LauncherList.h"
#include "ucs.h"
#include "queryserv.h"
#include "socket_server.h"
#ifdef _WINDOWS
#define snprintf _snprintf
@@ -61,7 +60,6 @@ extern ClientList client_list;
extern LauncherList launcher_list;
extern UCSConnection UCSLink;
extern QueryServConnection QSLink;
extern Socket_Server_Connection SSLink;
extern volatile bool RunLoops;
ConsoleList console_list;
@@ -265,12 +263,6 @@ bool Console::Process() {
QSLink.SetConnection(tcpc);
tcpc = 0;
}
else if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeSocket_Server)
{
_log(WORLD__CONSOLE, "New Socket Server Connection from %s:%d", inet_ntoa(in), GetPort());
SSLink.SetConnection(tcpc);
tcpc = 0;
}
else {
_log(WORLD__CONSOLE,"Unsupported packet mode from %s:%d", inet_ntoa(in), GetPort());
}
-4
View File
@@ -86,7 +86,6 @@
#include "AdventureManager.h"
#include "ucs.h"
#include "queryserv.h"
#include "socket_server.h"
TimeoutManager timeout_manager;
EQStreamFactory eqsf(WorldStream,9000);
@@ -98,7 +97,6 @@ LoginServerList loginserverlist;
EQWHTTPServer http_server;
UCSConnection UCSLink;
QueryServConnection QSLink;
Socket_Server_Connection SSLink;
LauncherList launcher_list;
AdventureManager adventure_manager;
DBAsync *dbasync = nullptr;
@@ -456,8 +454,6 @@ int main(int argc, char** argv) {
QSLink.Process();
SSLink.Process();
LFPGroupList.Process();
adventure_manager.Process();
-127
View File
@@ -1,127 +0,0 @@
#include "../common/debug.h"
#include "socket_server.h"
#include "WorldConfig.h"
#include "clientlist.h"
#include "zonelist.h"
#include "../common/logsys.h"
#include "../common/logtypes.h"
#include "../common/md5.h"
#include "../common/EmuTCPConnection.h"
#include "../common/packet_dump.h"
extern ClientList client_list;
extern ZSList zoneserver_list;
Socket_Server_Connection::Socket_Server_Connection()
{
Stream = 0;
authenticated = false;
}
void Socket_Server_Connection::SetConnection(EmuTCPConnection *inStream)
{
if(Stream)
{
_log(SOCKET_SERVER__ERROR, "Incoming Socket_Server Connection while we were already connected to a Socket_Server.");
Stream->Disconnect();
}
Stream = inStream;
authenticated = false;
}
bool Socket_Server_Connection::Process()
{
if (!Stream || !Stream->Connected())
return false;
ServerPacket *pack = 0;
while((pack = Stream->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(SOCKET_SERVER__ERROR, "Socket_Server authorization failed.");
ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
SendPacket(pack);
delete pack;
Disconnect();
return false;
}
}
else
{
struct in_addr in;
in.s_addr = GetIP();
_log(SOCKET_SERVER__ERROR, "Socket_Server_ authorization failed.");
ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
SendPacket(pack);
delete pack;
Disconnect();
return false;
}
}
else
{
_log(SOCKET_SERVER__ERROR,"**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 unauthorized zone access.");
authenticated = true;
}
delete pack;
continue;
}
switch(pack->opcode)
{
case 0:
break;
case ServerOP_KeepAlive:
{
// ignore this
break;
}
case ServerOP_ZAAuth:
{
_log(SOCKET_SERVER__ERROR, "Got authentication from Socket_Server_ when they are already authenticated.");
break;
}
case ServerOP_LFGuildUpdate:
{
zoneserver_list.SendPacket(pack);
break;
}
default:
{
_log(SOCKET_SERVER__ERROR, "Unknown ServerOPcode from Socket_Server_ 0x%04x, size %d", pack->opcode, pack->size);
DumpPacket(pack->pBuffer, pack->size);
break;
}
}
delete pack;
}
return(true);
}
bool Socket_Server_Connection::SendPacket(ServerPacket* pack)
{
if(!Stream)
return false;
return Stream->SendPacket(pack);
}
-23
View File
@@ -1,23 +0,0 @@
#ifndef Socket_Server__H
#define Socket_Server__H
#include "../common/types.h"
#include "../common/EmuTCPConnection.h"
#include "../common/servertalk.h"
class Socket_Server_Connection
{
public:
Socket_Server_Connection();
void SetConnection(EmuTCPConnection *inStream);
bool Process();
bool SendPacket(ServerPacket* pack);
void Disconnect() { if(Stream) Stream->Disconnect(); }
void SendMessage(const char *From, const char *Message);
private:
inline uint32 GetIP() const { return Stream ? Stream->GetrIP() : 0; }
EmuTCPConnection *Stream;
bool authenticated;
};
#endif /*Socket_Server__H_*/