Skip to content

Commit

Permalink
CHANGED: #238 Logon now uses the new XML config.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfighter1985 committed Aug 22, 2012
1 parent c54e597 commit 8856f7d
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 104 deletions.
2 changes: 1 addition & 1 deletion src/arcemu-logonserver/AccountCache.h
Expand Up @@ -205,7 +205,7 @@ class InformationCore : public Singleton<InformationCore>
InformationCore()
{
realmhigh = 0;
usepings = !Config.MainConfig.GetBoolDefault("LogonServer", "DisablePings", false);
usepings = true;
m_realms.clear();
}

Expand Down
21 changes: 11 additions & 10 deletions src/arcemu-logonserver/LogonConfig.h
Expand Up @@ -12,39 +12,40 @@ struct AllowedIP

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

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

struct log
struct LogSettings
{
unsigned short level;
};
}log;

struct rates
struct Rates
{
unsigned int account_refresh;
};
}rates;

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

};

#endif
Expand Down
112 changes: 110 additions & 2 deletions src/arcemu-logonserver/LogonConfigParser.cpp
Expand Up @@ -29,9 +29,38 @@ bool LogonConfigParser::parseFile( const std::string &name )
return false;
}

xmlFreeDoc( document );
bool ok = true;

return true;
xmlNodePtr node = root->children;
while( node != NULL )
{
if( xmlStrcmp( node->name, BAD_CAST "logondatabase" ) == 0 )
ok = parseDBPart( node );
else
if( xmlStrcmp( node->name, BAD_CAST "host" ) == 0 )
ok = parseHostPart( node );
else
if( xmlStrcmp( node->name, BAD_CAST "log" ) == 0 )
ok = parseLogPart( node );
else
if( xmlStrcmp( node->name, BAD_CAST "rates" ) == 0 )
ok = parseRatesPart( node );
else
if( xmlStrcmp( node->name, BAD_CAST "security" ) == 0 )
ok = parseSecurityPart( node );

if( !ok )
break;

node = node->next;
}

xmlFreeDoc( document );

if( !ok )
return false;
else
return true;
}

bool LogonConfigParser::isConfig( _xmlNode *node )
Expand All @@ -58,26 +87,105 @@ bool LogonConfigParser::isConfig( _xmlNode *node )

bool LogonConfigParser::parseDBPart( _xmlNode *node )
{
xmlChar *prop = NULL;

prop = xmlGetProp( node, BAD_CAST "hostname" );
if( prop == NULL )
return false;
data.logondb.host = reinterpret_cast< char* >( prop );

prop = xmlGetProp( node, BAD_CAST "username" );
if( prop == NULL )
return false;
data.logondb.username = reinterpret_cast< char* >( prop );

prop = xmlGetProp( node, BAD_CAST "password" );
if( prop == NULL )
return false;
data.logondb.password = reinterpret_cast< char* >( prop );

prop = xmlGetProp( node, BAD_CAST "database" );
if( prop == NULL )
return false;
data.logondb.database = reinterpret_cast< char* >( prop );

prop = xmlGetProp( node, BAD_CAST "port" );
if( prop == NULL )
data.logondb.port = 3306u;
else
data.logondb.port = static_cast< unsigned int >( atoi( reinterpret_cast< char* >( prop ) ) );

return true;
}

bool LogonConfigParser::parseHostPart( _xmlNode *node )
{
xmlChar *prop = NULL;

prop = xmlGetProp( node, BAD_CAST "logon_address" );
if( prop == NULL )
return false;
data.host.logon_address = reinterpret_cast< char* >( prop );

prop = xmlGetProp( node, BAD_CAST "logon_port" );
if( prop == NULL )
return false;
data.host.logon_port = static_cast< unsigned int >( atoi( reinterpret_cast< char* >( prop ) ) );

prop = xmlGetProp( node, BAD_CAST "is_address" );
if( prop == NULL )
return false;
data.host.is_address = reinterpret_cast< char* >( prop );

prop = xmlGetProp( node, BAD_CAST "is_port" );
if( prop == NULL )
return false;
data.host.is_port = static_cast< unsigned int >( atoi( reinterpret_cast< char* >( prop ) ) );

return true;
}

bool LogonConfigParser::parseLogPart( _xmlNode *node )
{
xmlChar *prop = xmlGetProp( node, BAD_CAST "level" );
if( prop == NULL )
data.log.level = 0;
else
data.log.level = static_cast< unsigned int >( atoi( reinterpret_cast< char* >( prop ) ) );

return true;
}

bool LogonConfigParser::parseRatesPart( _xmlNode *node )
{
xmlChar *prop = xmlGetProp( node, BAD_CAST "account_refresh" );
if( prop == NULL )
data.rates.account_refresh = 600u;
else
data.rates.account_refresh = static_cast< unsigned int >( atoi( reinterpret_cast< char* >( prop ) ) );

return true;
}

bool LogonConfigParser::parseSecurityPart( _xmlNode *node )
{
xmlChar *prop = NULL;

prop = xmlGetProp( node, BAD_CAST "remote_password" );
if( prop == NULL )
return false;
data.security.remote_password = reinterpret_cast< char* >( prop );

prop = xmlGetProp( node, BAD_CAST "allowed_ip_ranges" );
if( prop == NULL )
return false;
data.security.allowed_ip_ranges = reinterpret_cast< char* >( prop );

prop = xmlGetProp( node, BAD_CAST "allowed_mod_ip_ranges" );
if( prop == NULL )
return false;
data.security.allowed_mod_ip_ranges = reinterpret_cast< char* >( prop );

return true;
}

4 changes: 2 additions & 2 deletions src/arcemu-logonserver/LogonConsole.cpp
Expand Up @@ -21,12 +21,12 @@
#include "LogonConsole.h"

initialiseSingleton(LogonConsole);
bool Rehash();
bool rehash2();

void LogonConsole::TranslateRehash(char* str)
{
sLog.outString("rehashing config file...");
Rehash();
rehash2();
}

void LogonConsole::Kill()
Expand Down

0 comments on commit 8856f7d

Please sign in to comment.