Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHANGED: #238 my work so far on changing the logon config to pure XML…
…. NOTE: nothing is final yet!
- Loading branch information
1 parent
eb7d158
commit c54e597
Showing
7 changed files
with
204 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters