gauthd
 
Loading...
Searching...
No Matches
D:/pwsrc2.0/docs/gauthd/gauthd.cpp
Go to the documentation of this file.
1
6
7 #include "gauthserver.hpp"
8 #include "gmysqlclient.hpp"
9 #include "conf.h"
10 #include "log.h"
11 #include "thread.h"
12 #include <iostream>
13 #include <unistd.h>
14
15 using namespace GNET;
16
42 int main(int argc, char *argv[])
43 {
44 // Проверка аргументов командной строки
45 if (argc != 2 || access(argv[1], R_OK) == -1)
46 {
47 std::cerr << "Usage: " << argv[0] << " configurefile" << std::endl;
48 exit(-1);
49 }
50
51 // Инициализация конфигурации и логгера
52 Conf *conf = Conf::GetInstance(argv[1]);
53 Log::setprogname("gauthd");
54
55 // Настройка GAuthServer
56 {
58 manager->SetAccumulate(atoi(conf->find(manager->Identification(), "accumulate").c_str()));
59
60 std::string value = conf->find(manager->Identification(), "shared_key");
61 manager->shared_key = Octets(value.c_str(), value.size());
62
63 Protocol::Server(manager);
64 }
65
66 // Настройка GMysqlClient
67 {
69 const char *location = "GMysqlClient";
70
71 manager->Init(
72 conf->find(location, "address").c_str(),
73 atoi(conf->find(location, "port").c_str()),
74 conf->find(location, "user").c_str(),
75 conf->find(location, "passwd").c_str(),
76 conf->find(location, "name").c_str(),
77 atoi(conf->find(location, "hash").c_str())
78 );
79 manager->Connect();
80
81 // Применение патча AlexPatch
82 const char *alex = "AlexPatch";
83 manager->AlexPatch(
84 atoi(conf->find(alex, "lkmod").c_str()),
85 atoi(conf->find(alex, "loginlog").c_str()),
86 conf->find(alex, "logoutshell").c_str()
87 );
88 }
89
90 // Запуск задач
91 Thread::Pool::AddTask(new CheckTimer(10));
92 Thread::Pool::AddTask(PollIO::Task::GetInstance());
93 Thread::Pool::Run();
94
95 return 0;
96 }
Основной класс для работы с MySQL базой данных
void Init(const char *ip, const int port, const char *user, const char *passwd, const char *db, const int h)
Инициализация параметров подключения
void AlexPatch(const bool lkmod, const bool log, const char *shell)
Дополнительные настройки
bool Connect()
Установить соединение с БД
static GMysqlClient * GetInstance()
Получить экземпляр класса (Singleton)
Periodic task manager for financial and security checks.
Main authentication server class handling sessions and user validation.
static GAuthServer * GetInstance()
Получить экземпляр синглтона.
void SetAccumulate(size_t size)
Установить лимит накопления данных.
Octets shared_key
Общий ключ для шифрования.
std::string Identification() const
Идентификатор протокола.
int main(int argc, char *argv[])
Главная функция программы.
Definition gauthd.cpp:42
Заголовочный файл, содержащий определения классов для аутентификации и управления сессиями.
MySQL клиент для работы с базой данных игрового сервера
Основное пространство имен для сетевых компонентов системы.