Skip to content

Commit

Permalink
CHANGED: #238 my work so far on changing the logon config to pure XML…
Browse files Browse the repository at this point in the history
…. NOTE: nothing is final yet!
  • Loading branch information
dfighter1985 committed Aug 22, 2012
1 parent eb7d158 commit c54e597
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 8 deletions.
4 changes: 3 additions & 1 deletion cmake/CMakeLists.txt
Expand Up @@ -54,7 +54,7 @@ ENDIF()

#Install libmysql.dll required for our core to run.
IF( WIN32)
SET( INSTALLED_DEPENDENCIES ${DEPENDENCY_DLLS}/libmysql.dll ${DEPENDENCY_DLLS}/libeay32.dll)
SET( INSTALLED_DEPENDENCIES ${DEPENDENCY_DLLS}/libmysql.dll ${DEPENDENCY_DLLS}/libeay32.dll ${DEPENDENCY_DLLS}/libxml2.dll )
ENDIF(WIN32)

#Our configurable variables.
Expand Down Expand Up @@ -155,13 +155,15 @@ if(WIN32)
else()
SET( EXTRA_LIBS ${EXTRA_LIBS} libmysql_release_x64.lib )
endif()
SET( EXTRA_LIBS ${EXTRA_LIBS} libxml2_win64.lib )
else(IS_64BIT )
SET( EXTRA_LIBS libeay32_win32.lib )
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(EXTRA_LIBS ${EXTRA_LIBS} libmysql_debug_win32.lib )
else()
SET( EXTRA_LIBS ${EXTRA_LIBS} libmysql_release_win32.lib )
endif()
SET( EXTRA_LIBS ${EXTRA_LIBS} libxml2_win32.lib )
endif()
#Needed for socket stuff and crash handler
SET(EXTRA_LIBS ${EXTRA_LIBS} ws2_32.lib dbghelp.lib )
Expand Down
27 changes: 27 additions & 0 deletions configs/logon.conf.xml
@@ -0,0 +1,27 @@
<config type="logon" version="1">

<logondatabase hostname = "host"
username = "username"
password = "passwd"
database = "database"
port = "3306"
/>

<host logon_address = "127.0.0.1"
logon_port = "3724"
is_address = "127.0.0.1"
is_port = "8093"
/>

<log level="0"
/>

<rates account_refresh = "600"
/>

<security remote_password = "change_me_logon"
allowed_ip_ranges = "127.0.0.1/24"
allowed_mod_ip_ranges = "127.0.0.1/24"
/>

</config>
51 changes: 51 additions & 0 deletions src/arcemu-logonserver/LogonConfig.h
@@ -0,0 +1,51 @@
#ifndef LOGON_CONFIG_H
#define LOGON_CONFIG_H

#include <string>

struct AllowedIP
{
unsigned int IP;
unsigned char Bytes;
};


struct LogonConfigData
{
struct logondb
{
std::string host;
std::string username;
std::string password;
std::string database;
unsigned int port;
};

struct host
{
std::string logon_address;
unsigned int logon_port;
std::string is_address;
unsigned int is_port;
};

struct log
{
unsigned short level;
};

struct rates
{
unsigned int account_refresh;
};

struct security
{
std::string remote_password;
std::string allowed_ip_ranges;
std::string allowed_mod_ip_ranges;
};
};

#endif

83 changes: 83 additions & 0 deletions src/arcemu-logonserver/LogonConfigParser.cpp
@@ -0,0 +1,83 @@
#include "LogonConfigParser.h"
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>

LogonConfigParser::LogonConfigParser()
{
}

LogonConfigParser::~LogonConfigParser()
{
}

bool LogonConfigParser::parseFile( const std::string &name )
{
xmlDocPtr document = xmlParseFile( name.c_str() );
if( document == NULL )
return false;

xmlNodePtr root = xmlDocGetRootElement( document );
if( root == NULL )
{
xmlFreeDoc( document );
return false;
}

if( !isConfig( root ) )
{
xmlFreeDoc( document );
return false;
}

xmlFreeDoc( document );

return true;
}

bool LogonConfigParser::isConfig( _xmlNode *node )
{
if( xmlStrcmp( node->name, BAD_CAST "config" ) != 0 )
return false;

xmlChar *prop = NULL;

prop = xmlGetProp( node, BAD_CAST "type" );
if( prop == NULL )
return false;
if( xmlStrcmp( prop, BAD_CAST "logon" ) != 0 )
return false;

prop = xmlGetProp( node, BAD_CAST "version" );
if( prop == NULL )
return false;
if( xmlStrcmp( prop, BAD_CAST "1" ) )
return false;

return true;
}

bool LogonConfigParser::parseDBPart( _xmlNode *node )
{
return true;
}

bool LogonConfigParser::parseHostPart( _xmlNode *node )
{
return true;
}

bool LogonConfigParser::parseLogPart( _xmlNode *node )
{
return true;
}

bool LogonConfigParser::parseRatesPart( _xmlNode *node )
{
return true;
}

bool LogonConfigParser::parseSecurityPart( _xmlNode *node )
{
return true;
}

29 changes: 29 additions & 0 deletions src/arcemu-logonserver/LogonConfigParser.h
@@ -0,0 +1,29 @@
#ifndef LOGON_CONFIG_PARSER_H
#define LOGON_CONFIG_PARSER_H

#include "LogonConfig.h"

struct _xmlNode;

class LogonConfigParser
{
public:
LogonConfigParser();
~LogonConfigParser();

bool parseFile( const std::string &name );
const LogonConfigData& getData() const{ return data; }

private:
bool isConfig( _xmlNode *node );
bool parseDBPart( _xmlNode *node );
bool parseHostPart( _xmlNode *node );
bool parseLogPart( _xmlNode *node );
bool parseRatesPart( _xmlNode *node );
bool parseSecurityPart( _xmlNode *node );

LogonConfigData data;
};

#endif

12 changes: 11 additions & 1 deletion src/arcemu-logonserver/Main.cpp
Expand Up @@ -31,6 +31,9 @@
#include <sched.h>
#endif

#include "LogonConfig.h"
#include "LogonConfigParser.h"

// Database impl
Database* sLogonSQL;
initialiseSingleton(LogonServer);
Expand Down Expand Up @@ -278,6 +281,11 @@ bool Rehash()
return true;
}

bool rehash2()
{
return true;
}


void LogonServer::Run(int argc, char** argv)
{
Expand Down Expand Up @@ -329,9 +337,11 @@ void LogonServer::Run(int argc, char** argv)
return;
}

if(do_check_conf)
if( true /*do_check_conf */ )
{
LOG_BASIC("Checking config file: %s", config_file);
LogonConfigParser parser;
parser.parseFile( "configs/logon.conf.xml" );
if(Config.MainConfig.SetSource(config_file, true))
LOG_BASIC(" Passed without errors.");
else
Expand Down
6 changes: 0 additions & 6 deletions src/arcemu-logonserver/Main.h
Expand Up @@ -37,12 +37,6 @@ class AuthSocket;
extern set<AuthSocket*> _authSockets;
extern Mutex _authSocketLock;

struct AllowedIP
{
unsigned int IP;
unsigned char Bytes;
};

bool IsServerAllowed(unsigned int IP);
bool IsServerAllowedMod(unsigned int IP);

Expand Down

0 comments on commit c54e597

Please sign in to comment.