config.cpp
config.h
log.cpp arat / kod blogu değiştir
CONFIGLERE EKLENICEK KODLAR
1 = AÇIK
0 = KAPALI
NOT : BUNLARIN HEPSI SIZDE OLUCAK DIYE BIR KAIDE YOK OLANI YAPARSINIZ OLMAYANI YAPMAZSINIZ
Metin2 Sunucularında MSSQL Log Yapılandırması Nasıl Yapılır?
Metin2 özel sunucu geliştiricileri için MSSQL log yapılandırması, sunucu performansı, güvenlik ve kullanıcı aktivitelerini takip etme açısından kritik öneme sahiptir.
Metin2 özel sunucularında MSSQL (Microsoft SQL Server) kullanmak, büyük veri tabanları ve yüksek kullanıcı trafiği ile çalışırken daha kararlı ve hızlı bir çözüm sunar. Ancak MSSQL veritabanında loglama işlemleri, özellikle güvenlik, kullanıcı işlemleri ve sistem hatalarının izlenmesi açısından oldukça önemlidir. Bu nedenle, doğru yapılandırılmış bir MSSQL log sistemi, sunucu yönetimi için elzemdir.
MSSQL Loglama Nedir ve Neden Gereklidir?
Loglama, sistemde gerçekleşen tüm işlemlerin, hataların ve kullanıcı etkileşimlerinin kaydedildiği süreçtir. Metin2 sunucularında, oyuncu giriş çıkışları, envanter işlemleri, seviye atlama, item kullanımı gibi pek çok işlem loglanmalıdır. Bu sayede hata takibi, güvenlik açıklarının tespiti ve sunucu performans analizi daha kolay yapılır.
MSSQL Log Ayarlarının Temel Bileşenleri
MSSQL log yapılandırmasında dikkat edilmesi gereken bazı temel ayarlar vardır. Bunlar:
- Error Log Ayarları: MSSQL sunucusunda oluşan hataların kaydedildiği log dosyalarıdır. Bu loglar, sistemsel hataların teşhisinde büyük rol oynar.
- Audit Loglama: Kullanıcı erişimlerini ve veritabanı üzerinde yapılan işlemleri kaydeder. Güvenlik açısından önemlidir.
- Transaction Logları: Veritabanı üzerinde yapılan tüm değişiklikleri kaydeder. Geri dönüşüm senaryolarında kullanılır.
Metin2 Sunucusu İçin MSSQL Log Yapılandırması Adımları
1. SQL Server Management Studio üzerinden MSSQL sunucunuza bağlanın.
2. Server Properties > Database Settings kısmından log dosyalarının nerede tutulacağını belirtin.
3. sp_configure komutu ile log_reuse_wait_desc gibi loglama parametrelerini kontrol edin.
4. Extended Events veya SQL Trace gibi gelişmiş loglama yöntemlerini aktif ederek, daha detaylı veriler alabilirsiniz.
Metin2 Client ve Auth Sunucuları İçin Log Entegrasyonu
Metin2 sistemlerinde genellikle auth ve game sunucuları ayrı çalışır. MSSQL log yapılandırması, her iki sunucu için de ayrı ayrı yapılmalıdır. Özellikle auth sunucusunda login logları, game sunucusunda ise karakter işlemleri, envanter değişiklikleri, PvP kayıtları gibi veriler loglanmalıdır.
Auth sunucusunda kullanıcı kimlik doğrulama logları, hatalı giriş denemeleri gibi veriler kaydedilmeli. Game sunucusunda ise, oyuncu seviye atlama, item drop, guild işlemleri gibi veriler loglanmalıdır. Bu sayede hem güvenlik hem de oyun içi istatistikler için veri elde edilir.
Python ve C++ ile MSSQL Log Entegrasyonu
Metin2 özel sunucularında loglama işlemleri, C++ sunucu tarafında ve Python GUI tabanlı sistemlerde entegre edilebilir. Örneğin, C++ ile yazılmış bir sunucu modülünde, oyuncu eylemleri doğrudan MSSQL'e yazılabilir. Python GUI tarafında ise, log verileri gerçek zamanlı olarak analiz edilebilir.
Sonuç
MSSQL log yapılandırması, Metin2 özel sunucularında hem güvenlik hem de performans açısından kritik öneme sahiptir. Doğru yapılandırılmış log sistemleri, hata tespiti, kullanıcı davranış analizi ve veri güvenliği konularında büyük kolaylık sağlar. Bu yapılandırmayı doğru yapmak, uzun vadede sunucu yönetimini kolaylaştırır.
How to Configure MSSQL Logging on Metin2 Servers?
For Metin2 private server developers, configuring MSSQL logging is critical for server performance, security, and tracking user activities.
Using MSSQL (Microsoft SQL Server) on Metin2 private servers provides a more stable and faster solution when working with large databases and high user traffic. However, logging operations within MSSQL databases are essential for tracking errors, user actions, and system events. Therefore, a properly configured MSSQL logging system is crucial for server management.
What Is MSSQL Logging and Why Is It Needed?
Logging is the process where all operations, errors, and user interactions occurring within the system are recorded. On Metin2 servers, events like player logins/logouts, inventory operations, level ups, and item usage must be logged. This allows easier error tracking, detection of security vulnerabilities, and performance analysis of the server.
Key Components of MSSQL Logging Configuration
There are several basic settings to consider during MSSQL logging configuration:
- Error Log Settings: These are log files that record errors occurring on the MSSQL server. These logs play a major role in diagnosing system errors.
- Audit Logging: Records user access and database operations. It is important for security purposes.
- Transaction Logs: Record all changes made to the database. Used in rollback scenarios.
Steps for Configuring MSSQL Logging on Metin2 Servers
1. Connect to your MSSQL server via SQL Server Management Studio.
2. In Server Properties > Database Settings, specify where log files will be stored.
3. Use the sp_configure command to check parameters such as log_reuse_wait_desc.
4. Enable advanced logging methods like Extended Events or SQL Trace to gather more detailed data.
MSSQL Log Integration for Metin2 Client and Auth Servers
In Metin2 systems, auth and game servers typically run separately. MSSQL logging configuration should be done separately for both servers. Login logs should be recorded on the auth server, while character actions, inventory changes, and PvP records should be logged on the game server.
On the auth server, authentication logs and failed login attempts should be recorded. On the game server, events like player level ups, item drops, and guild operations should be logged. This provides data for both security and in-game statistics.
MSSQL Log Integration with Python and C++
On Metin2 private servers, logging operations can be integrated into C++ server-side modules and Python GUI-based systems. For example, player actions in a C++-based server module can be directly written to MSSQL. On the Python GUI side, log data can be analyzed in real-time.
Conclusion
MSSQL logging configuration is critical for security and performance on Metin2 private servers. Properly configured logging systems facilitate error detection, user behavior analysis, and data security. Correctly setting up this configuration makes server management easier in the long term.
Kod:
TOKEN("Tum_Mysql_Log") { str_to_number(Tum_Mysql_Log, value_string); sys_log(0, "Tum_Mysql_Log: %d\n", Tum_Mysql_Log); continue; } TOKEN("Item_Mysql_Log") { str_to_number(ItemLog_Mysql_Log, value_string); sys_log(0, "ItemLog_Mysql_Log: %d\n", ItemLog_Mysql_Log); continue; } TOKEN("Char_Mysql_Log") { str_to_number(CharLog_Mysql_Log, value_string); continue; } TOKEN("Login_Mysql_Log") { str_to_number(LoginLog_Mysql_Log, value_string); continue; } TOKEN("MoneyLog_Mysql_Log") { str_to_number(MoneyLog_Mysql_Log, value_string); continue; } TOKEN("Hack_Mysql_Log") { sys_log(0, "HackLog_Mysql_Log: %d\n", HackLog_Mysql_Log); str_to_number(HackLog_Mysql_Log, value_string); continue; } TOKEN("HackCRC_Mysql_Log") { str_to_number(HackCRCLog_Mysql_Log, value_string); continue; } TOKEN("PCBangLogin_Mysql_Log") { str_to_number(PCBangLoginLog_Mysql_Log, value_string); continue; } TOKEN("GoldBar_Mysql_Log") { str_to_number(GoldBarLog_Mysql_Log, value_string); continue; } TOKEN("Cube_Mysql_Log") { str_to_number(CubeLog_Mysql_Log, value_string); continue; } TOKEN("Ticaret_Mysql_Log") { str_to_number(TicaretLog_Mysql_Log, value_string); continue; } TOKEN("SpeedHack_Mysql_Log") { str_to_number(SpeedHackLog_Mysql_Log, value_string); continue; } TOKEN("ChangeName_Mysql_Log") { str_to_number(ChangeNameLog_Mysql_Log, value_string); continue; } TOKEN("GMCommand_Mysql_Log") { str_to_number(GMCommandLog_Mysql_Log, value_string); continue; } TOKEN("Refine_Mysql_Log") { str_to_number(RefineLog_Mysql_Log, value_string); continue; } TOKEN("Shout_Mysql_Log") { str_to_number(ShoutLog_Mysql_Log, value_string); continue; } TOKEN("Level_Mysql_Log") { str_to_number(LevelLog_Mysql_Log, value_string); continue; } TOKEN("Boot_Mysql_Log") { str_to_number(BootLog_Mysql_Log, value_string); continue; } TOKEN("VCard_Mysql_Log") { str_to_number(VCardLog_Mysql_Log, value_string); continue; } TOKEN("Fish_Mysql_Log") { str_to_number(FishLog_Mysql_Log, value_string); continue; } TOKEN("QuestReward_Mysql_Log") { str_to_number(QuestRewardLog_Mysql_Log, value_string); continue; } TOKEN("DetailLogin_Mysql_Log") { str_to_number(DetailLoginLog_Mysql_Log, value_string); continue; } TOKEN("DragonSlay_Mysql_Log") { str_to_number(DragonSlayLog_Mysql_Log, value_string); continue; } TOKEN("HackShield_Mysql_Log") { str_to_number(HackShieldLog_Mysql_Log, value_string); continue; }
Kod:
int Tum_Mysql_Log = 0; int ItemLog_Mysql_Log = 0; int CharLog_Mysql_Log = 0; int LoginLog_Mysql_Log = 0; int MoneyLog_Mysql_Log = 0; int HackLog_Mysql_Log = 0; int HackCRCLog_Mysql_Log = 0; int PCBangLoginLog_Mysql_Log = 0; int GoldBarLog_Mysql_Log = 0; int CubeLog_Mysql_Log = 0; int SpeedHackLog_Mysql_Log = 0; int ChangeNameLog_Mysql_Log = 0; int GMCommandLog_Mysql_Log = 0; int RefineLog_Mysql_Log = 0; int ShoutLog_Mysql_Log = 0; int LevelLog_Mysql_Log = 0; int BootLog_Mysql_Log = 0; int VCardLog_Mysql_Log = 0; int FishLog_Mysql_Log = 0; int QuestRewardLog_Mysql_Log = 0; int DetailLoginLog_Mysql_Log = 0; int DragonSlayLog_Mysql_Log = 0; int HackShieldLog_Mysql_Log = 0; int TicaretLog_Mysql_Log = 0;
config.h
Kod:
extern int Tum_Mysql_Log; extern int ItemLog_Mysql_Log; extern int CharLog_Mysql_Log; extern int LoginLog_Mysql_Log; extern int MoneyLog_Mysql_Log; extern int HackLog_Mysql_Log; extern int HackCRCLog_Mysql_Log; extern int PCBangLoginLog_Mysql_Log; extern int GoldBarLog_Mysql_Log; extern int CubeLog_Mysql_Log; extern int SpeedHackLog_Mysql_Log; extern int ChangeNameLog_Mysql_Log; extern int GMCommandLog_Mysql_Log; extern int RefineLog_Mysql_Log; extern int ShoutLog_Mysql_Log; extern int LevelLog_Mysql_Log; extern int BootLog_Mysql_Log; extern int VCardLog_Mysql_Log; extern int FishLog_Mysql_Log; extern int QuestRewardLog_Mysql_Log; extern int DetailLoginLog_Mysql_Log; extern int DragonSlayLog_Mysql_Log; extern int HackShieldLog_Mysql_Log;
log.cpp arat / kod blogu değiştir
Kod:
void LogManager::Query(const char * c_pszFormat, ...)
Kod:
void LogManager::Query(const char * c_pszFormat, ...) { if (Tum_Mysql_Log == 1) { char szQuery[4096]; va_list args; va_start(args, c_pszFormat); vsnprintf(szQuery, sizeof(szQuery), c_pszFormat, args); va_end(args); if (test_server) sys_log(0, "LOG: %s", szQuery); m_sql.AsyncQuery(szQuery); } }
Kod:
void LogManager::ItemLog(DWORD dwPID, DWORD x, DWORD y, DWORD dwItemID, const char * c_pszText, const char * c_pszHint, const char * c_pszIP, DWORD dwVnum)
Kod:
void LogManager::ItemLog(DWORD dwPID, DWORD x, DWORD y, DWORD dwItemID, const char * c_pszText, const char * c_pszHint, const char * c_pszIP, DWORD dwVnum) { if (ItemLog_Mysql_Log == 1) { m_sql.EscapeString(__escape_hint, sizeof(__escape_hint), c_pszHint, strlen(c_pszHint)); Query("INSERT DELAYED INTO log%s (type, time, who, x, y, what, how, hint, ip, vnum) VALUES('ITEM', NOW(), %u, %u, %u, %u, '%s', '%s', '%s', %u)", get_table_postfix(), dwPID, x, y, dwItemID, c_pszText, __escape_hint, c_pszIP, dwVnum); } }
Kod:
void LogManager::CharLog(DWORD dwPID, DWORD x, DWORD y, DWORD dwValue, const char * c_pszText, const char * c_pszHint, const char * c_pszIP)
Kod:
void LogManager::CharLog(DWORD dwPID, DWORD x, DWORD y, DWORD dwValue, const char * c_pszText, const char * c_pszHint, const char * c_pszIP) { if (CharLog_Mysql_Log == 1) { m_sql.EscapeString(__escape_hint, sizeof(__escape_hint), c_pszHint, strlen(c_pszHint)); Query("INSERT DELAYED INTO log%s (type, time, who, x, y, what, how, hint, ip) VALUES('CHARACTER', NOW(), %u, %u, %u, %u, '%s', '%s', '%s')", get_table_postfix(), dwPID, x, y, dwValue, c_pszText, __escape_hint, c_pszIP); } }
Kod:
void LogManager::LoginLog(bool isLogin, DWORD dwAccountID, DWORD dwPID, BYTE bLevel, BYTE bJob, DWORD dwPlayTime)
Kod:
void LogManager::LoginLog(bool isLogin, DWORD dwAccountID, DWORD dwPID, BYTE bLevel, BYTE bJob, DWORD dwPlayTime) { if (LoginLog_Mysql_Log == 1) { Query("INSERT DELAYED INTO loginlog%s (type, time, channel, account_id, pid, level, job, playtime) VALUES (%s, NOW(), %d, %u, %u, %d, %d, %u)", get_table_postfix(), isLogin ? "'LOGIN'" : "'LOGOUT'", g_bChannel, dwAccountID, dwPID, bLevel, bJob, dwPlayTime); } }
Kod:
void LogManager::MoneyLog(BYTE type, DWORD vnum, int gold)
Kod:
void LogManager::MoneyLog(BYTE type, DWORD vnum, int gold) { if (MoneyLog_Mysql_Log == 1) { if (type == MONEY_LOG_RESERVED || type >= MONEY_LOG_TYPE_MAX_NUM) { sys_err("TYPE ERROR: type %d vnum %u gold %d", type, vnum, gold); return; } Query("INSERT DELAYED INTO money_log%s VALUES (NOW(), %d, %d, %d)", get_table_postfix(), type, vnum, gold); } }
Kod:
void LogManager::HackLog(const char * c_pszHackName, const char * c_pszLogin, const char * c_pszName, const char * c_pszIP)
Kod:
void LogManager::HackLog(const char * c_pszHackName, const char * c_pszLogin, const char * c_pszName, const char * c_pszIP) { if (HackLog_Mysql_Log == 1) { m_sql.EscapeString(__escape_hint, sizeof(__escape_hint), c_pszHackName, strlen(c_pszHackName)); Query("INSERT INTO hack_log (time, login, name, ip, server, why) SELECT NOW(), '%s', '%s', '%s', '%s', '%s' FROM DUAL WHERE NOT EXISTS(SELECT * FROM hack_log WHERE login = '%s' AND name = '%s' AND ip = '%s' AND server = '%s' AND why = '%s') LIMIT 1",c_pszLogin, c_pszName, c_pszIP, g_stHostname.c_str(), __escape_hint, c_pszLogin, c_pszName, c_pszIP, g_stHostname.c_str(), __escape_hint); } }
Kod:
void LogManager::HackCRCLog(const char * c_pszHackName, const char * c_pszLogin, const char * c_pszName, const char * c_pszIP, DWORD dwCRC)
Kod:
void LogManager::HackCRCLog(const char * c_pszHackName, const char * c_pszLogin, const char * c_pszName, const char * c_pszIP, DWORD dwCRC) { if (HackCRCLog_Mysql_Log == 1) { Query("INSERT INTO hack_crc_log (time, login, name, ip, server, why, crc) VALUES(NOW(), '%s', '%s', '%s', '%s', '%s', %u)", c_pszLogin, c_pszName, c_pszIP, g_stHostname.c_str(), c_pszHackName, dwCRC); } }
Kod:
void LogManager::PCBangLoginLog(DWORD dwPCBangID, const char* c_szPCBangIP, DWORD dwPlayerID, DWORD dwPlayTime)
Kod:
void LogManager::PCBangLoginLog(DWORD dwPCBangID, const char* c_szPCBangIP, DWORD dwPlayerID, DWORD dwPlayTime) { if (PCBangLoginLog_Mysql_Log == 1) { Query("INSERT INTO pcbang_loginlog (time, pcbang_id, ip, pid, play_time) VALUES (NOW(), %u, '%s', %u, %u)", dwPCBangID, c_szPCBangIP, dwPlayerID, dwPlayTime); } }
Kod:
void LogManager::GoldBarLog(DWORD dwPID, DWORD dwItemID, GOLDBAR_HOW eHow, const char* c_pszHint)
Kod:
void LogManager::GoldBarLog(DWORD dwPID, DWORD dwItemID, GOLDBAR_HOW eHow, const char* c_pszHint) { if (GoldBarLog_Mysql_Log == 1) { char szHow[32+1]; switch (eHow) { case PERSONAL_SHOP_BUY: snprintf(szHow, sizeof(szHow), "'BUY'"); break; case PERSONAL_SHOP_SELL: snprintf(szHow, sizeof(szHow), "'SELL'"); break; case SHOP_BUY: snprintf(szHow, sizeof(szHow), "'SHOP_BUY'"); break; case SHOP_SELL: snprintf(szHow, sizeof(szHow), "'SHOP_SELL'"); break; case EXCHANGE_TAKE: snprintf(szHow, sizeof(szHow), "'EXCHANGE_TAKE'"); break; case EXCHANGE_GIVE: snprintf(szHow, sizeof(szHow), "'EXCHANGE_GIVE'"); break; case QUEST: snprintf(szHow, sizeof(szHow), "'QUEST'"); break; default: snprintf(szHow, sizeof(szHow), "''"); break; } Query("INSERT DELAYED INTO goldlog%s (date, time, pid, what, how, hint) VALUES(CURDATE(), CURTIME(), %u, %u, %s, '%s')", get_table_postfix(), dwPID, dwItemID, szHow, c_pszHint); } }
Kod:
void LogManager::CubeLog(DWORD dwPID, DWORD x, DWORD y, DWORD item_vnum, DWORD item_uid, int item_count, bool success)
Kod:
void LogManager::CubeLog(DWORD dwPID, DWORD x, DWORD y, DWORD item_vnum, DWORD item_uid, int item_count, bool success) { if (CubeLog_Mysql_Log == 1) { Query("INSERT DELAYED INTO cube%s (pid, time, x, y, item_vnum, item_uid, item_count, success) ""VALUES(%u, NOW(), %u, %u, %u, %u, %d, %d)",get_table_postfix(), dwPID, x, y, item_vnum, item_uid, item_count, success?1:0); } }
Kod:
void LogManager::SpeedHackLog(DWORD pid, DWORD x, DWORD y, int hack_count)
Kod:
void LogManager::SpeedHackLog(DWORD pid, DWORD x, DWORD y, int hack_count) { if (SpeedHackLog_Mysql_Log == 1) { Query("INSERT INTO speed_hack%s (pid, time, x, y, hack_count) " "VALUES(%u, NOW(), %u, %u, %d)", get_table_postfix(), pid, x, y, hack_count); } }
Kod:
void LogManager::ChangeNameLog(DWORD pid, const char *old_name, const char *new_name, const char *ip
Kod:
void LogManager::ChangeNameLog(DWORD pid, const char *old_name, const char *new_name, const char *ip) { if (ChangeNameLog_Mysql_Log == 1) { Query("INSERT DELAYED INTO change_name%s (pid, old_name, new_name, time, ip) " "VALUES(%u, '%s', '%s', NOW(), '%s') ", get_table_postfix(), pid, old_name, new_name, ip); } }
Kod:
void LogManager::GMCommandLog(DWORD dwPID, const char* szName, const char* szIP, BYTE byChannel, const char* szCommand)
Kod:
void LogManager::GMCommandLog(DWORD dwPID, const char* szName, const char* szIP, BYTE byChannel, const char* szCommand) { if (GMCommandLog_Mysql_Log == 1) { m_sql.EscapeString(__escape_hint, sizeof(__escape_hint), szCommand, strlen(szCommand)); Query("INSERT DELAYED INTO command_log%s (userid, server, ip, port, username, command, date ) " "VALUES(%u, 999, '%s', %u, '%s', '%s', NOW()) ", get_table_postfix(), dwPID, szIP, byChannel, szName, __escape_hint); } }
Kod:
void LogManager::RefineLog(DWORD pid, const char* item_name, DWORD item_id, int item_refine_level, int is_success, const char* how)
Kod:
void LogManager::RefineLog(DWORD pid, const char* item_name, DWORD item_id, int item_refine_level, int is_success, const char* how) { if (RefineLog_Mysql_Log == 1) { m_sql.EscapeString(__escape_hint, sizeof(__escape_hint), item_name, strlen(item_name)); Query("INSERT INTO refinelog%s (pid, item_name, item_id, step, time, is_success, setType) VALUES(%u, '%s', %u, %d, NOW(), %d, '%s')",get_table_postfix(), pid, __escape_hint, item_id, item_refine_level, is_success, how); } }
Kod:
void LogManager::ShoutLog(BYTE bChannel, BYTE bEmpire, const char * pszText)
Kod:
void LogManager::ShoutLog(BYTE bChannel, BYTE bEmpire, const char * pszText) { if (ShoutLog_Mysql_Log == 1) { m_sql.EscapeString(__escape_hint, sizeof(__escape_hint), pszText, strlen(pszText)); Query("INSERT INTO shout_log%s VALUES(NOW(), %d, %d,'%s')", get_table_postfix(), bChannel, bEmpire, __escape_hint); } }
Kod:
void LogManager::LevelLog(LPCHARACTER pChar, unsigned int level, unsigned int playhour)
Kod:
void LogManager::LevelLog(LPCHARACTER pChar, unsigned int level, unsigned int playhour) { if (LevelLog_Mysql_Log == 1) { if (true == LC_IsEurope()) { DWORD aid = 0; if (NULL != pChar->GetDesc()) { aid = pChar->GetDesc()->GetAccountTable().id; } Query("REPLACE INTO levellog%s (name, level, time, account_id, pid, playtime) VALUES('%s', %u, NOW(), %u, %u, %d)", get_table_postfix(), pChar->GetName(), level, aid, pChar->GetPlayerID(), playhour); } else { Query("REPLACE INTO levellog%s (name, level, time, playtime) VALUES('%s', %u, NOW(), %d)", get_table_postfix(), pChar->GetName(), level, playhour); } } }
Kod:
void LogManager::BootLog(const char * c_pszHostName, BYTE bChannel)
Kod:
void LogManager::BootLog(const char * c_pszHostName, BYTE bChannel) { if (BootLog_Mysql_Log == 1) { Query("INSERT INTO bootlog (time, hostname, channel) VALUES(NOW(), '%s', %d)", c_pszHostName, bChannel); } }
Kod:
void LogManager::VCardLog(DWORD vcard_id, DWORD x, DWORD y, const char * hostname, const char * giver_name, const char * giver_ip, const char * taker_name, const char * taker_ip)
Kod:
void LogManager::VCardLog(DWORD vcard_id, DWORD x, DWORD y, const char * hostname, const char * giver_name, const char * giver_ip, const char * taker_name, const char * taker_ip) { if (VCardLog_Mysql_Log == 1) { Query("INSERT DELAYED INTO vcard_log (vcard_id, x, y, hostname, giver_name, giver_ip, taker_name, taker_ip) VALUES(%u, %u, %u, '%s', '%s', '%s', '%s', '%s')", vcard_id, x, y, hostname, giver_name, giver_ip, taker_name, taker_ip); } }
Kod:
void LogManager::FishLog(DWORD dwPID, int prob_idx, int fish_id, int fish_level, DWORD dwMiliseconds, DWORD dwVnum, DWORD dwValue)
Kod:
void LogManager::FishLog(DWORD dwPID, int prob_idx, int fish_id, int fish_level, DWORD dwMiliseconds, DWORD dwVnum, DWORD dwValue) { if (FishLog_Mysql_Log == 1) { Query("INSERT INTO fish_log%s VALUES(NOW(), %u, %d, %u, %d, %u, %u, %u)", get_table_postfix(), dwPID, prob_idx, fish_id, fish_level, dwMiliseconds, dwVnum, dwValue); } }
Kod:
void LogManager::QuestRewardLog(const char * c_pszQuestName, DWORD dwPID, DWORD dwLevel, int iValue1, int iValue2)
Kod:
void LogManager::QuestRewardLog(const char * c_pszQuestName, DWORD dwPID, DWORD dwLevel, int iValue1, int iValue2) { if (QuestRewardLog_Mysql_Log == 1) { Query("INSERT INTO quest_reward_log%s VALUES('%s',%u,%u,2,%u,%u,NOW())", get_table_postfix(), c_pszQuestName, dwPID, dwLevel, iValue1, iValue2); } }
Kod:
void LogManager::DetailLoginLog(bool isLogin, LPCHARACTER ch)
Kod:
void LogManager::DetailLoginLog(bool isLogin, LPCHARACTER ch) { if (DetailLoginLog_Mysql_Log == 1) { if (NULL == ch->GetDesc()) return; if (true == isLogin) { Query("INSERT INTO loginlog2(type, is_gm, login_time, channel, account_id, pid, ip, client_version) " "VALUES('INVALID', %s, NOW(), %d, %u, %u, inet_aton('%s'), '%s')", ch->IsGM() == true ? "'Y'" : "'N'", g_bChannel, ch->GetDesc()->GetAccountTable().id, ch->GetPlayerID(), ch->GetDesc()->GetHostName(), ch->GetDesc()->GetClientVersion()); } else { Query("SET @i = (SELECT MAX(id) FROM loginlog2 WHERE account_id=%u AND pid=%u)", ch->GetDesc()->GetAccountTable().id, ch->GetPlayerID()); Query("UPDATE loginlog2 SET type='VALID', logout_time=NOW(), playtime=TIMEDIFF(logout_time,login_time) WHERE id=@i"); } } }
Kod:
void LogManager::DragonSlayLog(DWORD dwGuildID, DWORD dwDragonVnum, DWORD dwStartTime, DWORD dwEndTime)
Kod:
void LogManager::DragonSlayLog(DWORD dwGuildID, DWORD dwDragonVnum, DWORD dwStartTime, DWORD dwEndTime) { if (DragonSlayLog_Mysql_Log == 1) { Query( "INSERT INTO dragon_slay_log%s VALUES( %d, %d, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d) )", get_table_postfix(), dwGuildID, dwDragonVnum, dwStartTime, dwEndTime); } }
Kod:
void LogManager::HackShieldLog(unsigned long ErrorCode, LPCHARACTER ch)
Kod:
void LogManager::HackShieldLog(unsigned long ErrorCode, LPCHARACTER ch) { if (HackShieldLog_Mysql_Log == 1) { struct in_addr st_addr; #ifndef __WIN32__ if (0 == inet_aton(ch->GetDesc()->GetHostName(), &st_addr)) #else unsigned long in_address; in_address = inet_addr(ch->GetDesc()->GetHostName()); st_addr.s_addr = in_address; if (INADDR_NONE == in_address) #endif { Query( "INSERT INTO hackshield_log(time, account_id, login, pid, name, reason, ip) " "VALUES(NOW(), %u, '%s', %u, '%s', %u, 0)", ch->GetDesc()->GetAccountTable().id, ch->GetDesc()->GetAccountTable().login, ch->GetPlayerID(), ch->GetName(), ErrorCode); } else { Query( "INSERT INTO hackshield_log(time, account_id, login, pid, name, reason, ip) " "VALUES(NOW(), %u, '%s', %u, '%s', %u, inet_aton('%s'))", ch->GetDesc()->GetAccountTable().id, ch->GetDesc()->GetAccountTable().login, ch->GetPlayerID(), ch->GetName(), ErrorCode, ch->GetDesc()->GetHostName()); } } }
CONFIGLERE EKLENICEK KODLAR
Kod:
Tum_Mysql_Log: 1 Item_Mysql_Log: 1 Char_Mysql_Log: 1 Login_Mysql_Log: 1 MoneyLog_Mysql_Log: 1 Hack_Mysql_Log: 1 HackCRC_Mysql_Log: 1 PCBangLogin_Mysql_Log: 1 GoldBar_Mysql_Log: 1 Cube_Mysql_Log: 1 SpeedHack_Mysql_Log: 1 ChangeName_Mysql_Log: 1 GMCommand_Mysql_Log: 1 Refine_Mysql_Log: 1 Shout_Mysql_Log: 1 Level_Mysql_Log: 1 Boot_Mysql_Log: 1 VCard_Mysql_Log: 1 Fish_Mysql_Log: 1 QuestReward_Mysql_Log: 1 DetailLogin_Mysql_Log: 1 DragonSlay_Mysql_Log: 1 HackShield_Mysql_Log: 1
1 = AÇIK
0 = KAPALI
NOT : BUNLARIN HEPSI SIZDE OLUCAK DIYE BIR KAIDE YOK OLANI YAPARSINIZ OLMAYANI YAPMAZSINIZ
Metin2 Sunucularında MSSQL Log Yapılandırması Nasıl Yapılır?
Metin2 özel sunucu geliştiricileri için MSSQL log yapılandırması, sunucu performansı, güvenlik ve kullanıcı aktivitelerini takip etme açısından kritik öneme sahiptir.
Metin2 özel sunucularında MSSQL (Microsoft SQL Server) kullanmak, büyük veri tabanları ve yüksek kullanıcı trafiği ile çalışırken daha kararlı ve hızlı bir çözüm sunar. Ancak MSSQL veritabanında loglama işlemleri, özellikle güvenlik, kullanıcı işlemleri ve sistem hatalarının izlenmesi açısından oldukça önemlidir. Bu nedenle, doğru yapılandırılmış bir MSSQL log sistemi, sunucu yönetimi için elzemdir.
MSSQL Loglama Nedir ve Neden Gereklidir?
Loglama, sistemde gerçekleşen tüm işlemlerin, hataların ve kullanıcı etkileşimlerinin kaydedildiği süreçtir. Metin2 sunucularında, oyuncu giriş çıkışları, envanter işlemleri, seviye atlama, item kullanımı gibi pek çok işlem loglanmalıdır. Bu sayede hata takibi, güvenlik açıklarının tespiti ve sunucu performans analizi daha kolay yapılır.
MSSQL Log Ayarlarının Temel Bileşenleri
MSSQL log yapılandırmasında dikkat edilmesi gereken bazı temel ayarlar vardır. Bunlar:
- Error Log Ayarları: MSSQL sunucusunda oluşan hataların kaydedildiği log dosyalarıdır. Bu loglar, sistemsel hataların teşhisinde büyük rol oynar.
- Audit Loglama: Kullanıcı erişimlerini ve veritabanı üzerinde yapılan işlemleri kaydeder. Güvenlik açısından önemlidir.
- Transaction Logları: Veritabanı üzerinde yapılan tüm değişiklikleri kaydeder. Geri dönüşüm senaryolarında kullanılır.
Metin2 Sunucusu İçin MSSQL Log Yapılandırması Adımları
1. SQL Server Management Studio üzerinden MSSQL sunucunuza bağlanın.
2. Server Properties > Database Settings kısmından log dosyalarının nerede tutulacağını belirtin.
3. sp_configure komutu ile log_reuse_wait_desc gibi loglama parametrelerini kontrol edin.
4. Extended Events veya SQL Trace gibi gelişmiş loglama yöntemlerini aktif ederek, daha detaylı veriler alabilirsiniz.
Metin2 Client ve Auth Sunucuları İçin Log Entegrasyonu
Metin2 sistemlerinde genellikle auth ve game sunucuları ayrı çalışır. MSSQL log yapılandırması, her iki sunucu için de ayrı ayrı yapılmalıdır. Özellikle auth sunucusunda login logları, game sunucusunda ise karakter işlemleri, envanter değişiklikleri, PvP kayıtları gibi veriler loglanmalıdır.
Auth sunucusunda kullanıcı kimlik doğrulama logları, hatalı giriş denemeleri gibi veriler kaydedilmeli. Game sunucusunda ise, oyuncu seviye atlama, item drop, guild işlemleri gibi veriler loglanmalıdır. Bu sayede hem güvenlik hem de oyun içi istatistikler için veri elde edilir.
Python ve C++ ile MSSQL Log Entegrasyonu
Metin2 özel sunucularında loglama işlemleri, C++ sunucu tarafında ve Python GUI tabanlı sistemlerde entegre edilebilir. Örneğin, C++ ile yazılmış bir sunucu modülünde, oyuncu eylemleri doğrudan MSSQL'e yazılabilir. Python GUI tarafında ise, log verileri gerçek zamanlı olarak analiz edilebilir.
Sonuç
MSSQL log yapılandırması, Metin2 özel sunucularında hem güvenlik hem de performans açısından kritik öneme sahiptir. Doğru yapılandırılmış log sistemleri, hata tespiti, kullanıcı davranış analizi ve veri güvenliği konularında büyük kolaylık sağlar. Bu yapılandırmayı doğru yapmak, uzun vadede sunucu yönetimini kolaylaştırır.
How to Configure MSSQL Logging on Metin2 Servers?
For Metin2 private server developers, configuring MSSQL logging is critical for server performance, security, and tracking user activities.
Using MSSQL (Microsoft SQL Server) on Metin2 private servers provides a more stable and faster solution when working with large databases and high user traffic. However, logging operations within MSSQL databases are essential for tracking errors, user actions, and system events. Therefore, a properly configured MSSQL logging system is crucial for server management.
What Is MSSQL Logging and Why Is It Needed?
Logging is the process where all operations, errors, and user interactions occurring within the system are recorded. On Metin2 servers, events like player logins/logouts, inventory operations, level ups, and item usage must be logged. This allows easier error tracking, detection of security vulnerabilities, and performance analysis of the server.
Key Components of MSSQL Logging Configuration
There are several basic settings to consider during MSSQL logging configuration:
- Error Log Settings: These are log files that record errors occurring on the MSSQL server. These logs play a major role in diagnosing system errors.
- Audit Logging: Records user access and database operations. It is important for security purposes.
- Transaction Logs: Record all changes made to the database. Used in rollback scenarios.
Steps for Configuring MSSQL Logging on Metin2 Servers
1. Connect to your MSSQL server via SQL Server Management Studio.
2. In Server Properties > Database Settings, specify where log files will be stored.
3. Use the sp_configure command to check parameters such as log_reuse_wait_desc.
4. Enable advanced logging methods like Extended Events or SQL Trace to gather more detailed data.
MSSQL Log Integration for Metin2 Client and Auth Servers
In Metin2 systems, auth and game servers typically run separately. MSSQL logging configuration should be done separately for both servers. Login logs should be recorded on the auth server, while character actions, inventory changes, and PvP records should be logged on the game server.
On the auth server, authentication logs and failed login attempts should be recorded. On the game server, events like player level ups, item drops, and guild operations should be logged. This provides data for both security and in-game statistics.
MSSQL Log Integration with Python and C++
On Metin2 private servers, logging operations can be integrated into C++ server-side modules and Python GUI-based systems. For example, player actions in a C++-based server module can be directly written to MSSQL. On the Python GUI side, log data can be analyzed in real-time.
Conclusion
MSSQL logging configuration is critical for security and performance on Metin2 private servers. Properly configured logging systems facilitate error detection, user behavior analysis, and data security. Correctly setting up this configuration makes server management easier in the long term.
