Merge pull request #10 from Berkaykrdl/filemonitor-cleanup
chore: fm, limit time & valid server check removed
This commit is contained in:
@@ -80,24 +80,6 @@ bool CClientManager::FindLogonAccount(const char * c_pszLogin)
|
|||||||
|
|
||||||
void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketGDLoginByKey * p)
|
void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketGDLoginByKey * p)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_LIMIT_TIME
|
|
||||||
static int s_updateCount = 0;
|
|
||||||
static int s_curTime = time(0);
|
|
||||||
if (s_updateCount > 100)
|
|
||||||
{
|
|
||||||
s_curTime = time(0);
|
|
||||||
s_updateCount = 0;
|
|
||||||
}
|
|
||||||
++s_updateCount;
|
|
||||||
|
|
||||||
if (s_curTime >= GLOBAL_LIMIT_TIME)
|
|
||||||
{
|
|
||||||
sys_err("Server life time expired.");
|
|
||||||
exit(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CLoginData * pkLoginData = GetLoginData(p->dwLoginKey);
|
CLoginData * pkLoginData = GetLoginData(p->dwLoginKey);
|
||||||
char szLogin[LOGIN_MAX_LEN + 1];
|
char szLogin[LOGIN_MAX_LEN + 1];
|
||||||
trim_and_lower(p->szLogin, szLogin, sizeof(szLogin));
|
trim_and_lower(p->szLogin, szLogin, sizeof(szLogin));
|
||||||
|
|||||||
@@ -1,138 +0,0 @@
|
|||||||
#include "stdafx.h"
|
|
||||||
#ifdef OS_FREEBSD
|
|
||||||
#include "FileMonitor_FreeBSD.h"
|
|
||||||
#include "libthecore/log.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define INVALID_KERNEL_EVENT -1
|
|
||||||
|
|
||||||
FileMonitorFreeBSD::FileMonitorFreeBSD()
|
|
||||||
{
|
|
||||||
m_KernelEventQueue = INVALID_KERNEL_EVENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileMonitorFreeBSD::~FileMonitorFreeBSD()
|
|
||||||
{
|
|
||||||
if( m_KernelEventQueue != INVALID_KERNEL_EVENT )
|
|
||||||
{
|
|
||||||
close ( m_KernelEventQueue );
|
|
||||||
m_KernelEventQueue = INVALID_KERNEL_EVENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
TMonitorFileHashMap::iterator it;
|
|
||||||
for( it = m_FileLists.begin(); it != m_FileLists.end(); ++it )
|
|
||||||
{
|
|
||||||
close(it->second.fhMonitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_FileLists.clear();
|
|
||||||
|
|
||||||
m_MonitoredEventLists.clear();
|
|
||||||
m_TriggeredEventLists.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FileMonitorFreeBSD::Update(DWORD dwPulses)
|
|
||||||
{
|
|
||||||
if( m_KernelEventQueue == INVALID_KERNEL_EVENT || m_FileLists.size() == 0 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
int nEvent = kevent(m_KernelEventQueue, &m_TriggeredEventLists[0], (int)m_TriggeredEventLists.size(), &m_MonitoredEventLists[0], (int)m_MonitoredEventLists.size(), NULL );
|
|
||||||
if( nEvent == INVALID_KERNEL_EVENT )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if( nEvent > 0 )
|
|
||||||
{
|
|
||||||
for( int i = 0; i < nEvent; ++i )
|
|
||||||
{
|
|
||||||
int nEventFlags = m_MonitoredEventLists[i].flags;
|
|
||||||
eFileUpdatedOptions eUpdateOption = e_FileUpdate_None;
|
|
||||||
|
|
||||||
if (nEventFlags & EV_ERROR)
|
|
||||||
eUpdateOption = e_FileUpdate_Error;
|
|
||||||
|
|
||||||
else if (nEventFlags & NOTE_DELETE)
|
|
||||||
eUpdateOption = e_FileUpdate_Deleted;
|
|
||||||
|
|
||||||
else if (nEventFlags & NOTE_EXTEND || nEventFlags & NOTE_WRITE)
|
|
||||||
eUpdateOption = e_FileUpdate_Modified;
|
|
||||||
|
|
||||||
else if (nEventFlags & NOTE_ATTRIB)
|
|
||||||
eUpdateOption = e_FileUpdate_AttrModified;
|
|
||||||
|
|
||||||
else if (nEventFlags & NOTE_LINK)
|
|
||||||
eUpdateOption = e_FileUpdate_Linked;
|
|
||||||
|
|
||||||
else if (nEventFlags & NOTE_RENAME)
|
|
||||||
eUpdateOption = e_FileUpdate_Renamed;
|
|
||||||
|
|
||||||
else if (nEventFlags & NOTE_REVOKE)
|
|
||||||
eUpdateOption = e_FileUpdate_Revoked;
|
|
||||||
|
|
||||||
if( eUpdateOption != e_FileUpdate_None )
|
|
||||||
{
|
|
||||||
TMonitorFileHashMap::iterator it;
|
|
||||||
for( it = m_FileLists.begin(); it != m_FileLists.end(); ++it )
|
|
||||||
{
|
|
||||||
FileIOContext_FreeBSD& context = it->second;
|
|
||||||
if( context.idxToEventList == i )
|
|
||||||
{
|
|
||||||
std::string strModifedFileName = it->first;
|
|
||||||
context.pListenFunc( strModifedFileName, eUpdateOption );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileMonitorFreeBSD::AddWatch(const std::string& strFileName, PFN_FileChangeListener pListenerFunc)
|
|
||||||
{
|
|
||||||
int iFileHandle = -1;
|
|
||||||
if( (iFileHandle = open(strFileName.c_str(), O_RDONLY)) == -1)
|
|
||||||
{
|
|
||||||
sys_err("FileMonitorFreeBSD:AddWatch : can`t open file(%s).\n", strFileName.c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//create kqueue if not exists
|
|
||||||
if( m_KernelEventQueue == INVALID_KERNEL_EVENT )
|
|
||||||
m_KernelEventQueue = kqueue();
|
|
||||||
|
|
||||||
if( m_KernelEventQueue == INVALID_KERNEL_EVENT )
|
|
||||||
{
|
|
||||||
sys_err("FileMonitorFreeBSD:AddWatch : failed to create kqueue.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TMonitorFileHashMap::iterator it = m_FileLists.find( strFileName );
|
|
||||||
if( it != m_FileLists.end() )
|
|
||||||
{
|
|
||||||
sys_log(0, "FileMonitorFreeBSD:AddWatch : trying to add duplicated watch on file(%s).\n", strFileName.c_str() );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//set file context
|
|
||||||
FileIOContext_FreeBSD context;
|
|
||||||
{
|
|
||||||
context.fhMonitor = iFileHandle;
|
|
||||||
context.idxToEventList = (int)m_MonitoredEventLists.size();
|
|
||||||
context.pListenFunc = pListenerFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_FileLists[strFileName] = context;
|
|
||||||
|
|
||||||
//set events
|
|
||||||
struct kevent kTriggerEvent, kMonitorEvent;
|
|
||||||
|
|
||||||
EV_SET(&kTriggerEvent, iFileHandle, EVFILT_VNODE,
|
|
||||||
EV_ADD | EV_ENABLE | EV_ONESHOT,
|
|
||||||
NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_LINK | NOTE_RENAME | NOTE_REVOKE,
|
|
||||||
0, 0);
|
|
||||||
|
|
||||||
m_TriggeredEventLists.push_back( kTriggerEvent );
|
|
||||||
m_MonitoredEventLists.push_back( kMonitorEvent );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#ifdef OS_FREEBSD
|
|
||||||
#include "IFileMonitor.h"
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/event.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/signal.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
struct FileIOContext_FreeBSD
|
|
||||||
{
|
|
||||||
int fhMonitor;
|
|
||||||
int idxToEventList; // evtTrigger & evtMonitor index should be same
|
|
||||||
PFN_FileChangeListener pListenFunc;
|
|
||||||
};
|
|
||||||
|
|
||||||
class FileMonitorFreeBSD : public IFileMonitor
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
FileMonitorFreeBSD(); //hidden
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual ~FileMonitorFreeBSD();
|
|
||||||
|
|
||||||
void AddWatch (const std::string& strFileName, PFN_FileChangeListener pListenerFunc);
|
|
||||||
void Update (DWORD dwPulses);
|
|
||||||
|
|
||||||
static FileMonitorFreeBSD& Instance()
|
|
||||||
{
|
|
||||||
static FileMonitorFreeBSD theMonitor;
|
|
||||||
return theMonitor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef std::unordered_map<std::string, FileIOContext_FreeBSD> TMonitorFileHashMap;
|
|
||||||
typedef std::vector<struct kevent> TEventList;
|
|
||||||
|
|
||||||
TMonitorFileHashMap m_FileLists;
|
|
||||||
TEventList m_MonitoredEventLists;
|
|
||||||
TEventList m_TriggeredEventLists;
|
|
||||||
|
|
||||||
int m_KernelEventQueue;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#ifndef IFILEMONITOR_INCLUDED
|
|
||||||
#define IFILEMONITOR_INCLUDED
|
|
||||||
|
|
||||||
//#include <boost/function.hpp>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
enum eFileUpdatedOptions
|
|
||||||
{
|
|
||||||
e_FileUpdate_None = -1,
|
|
||||||
e_FileUpdate_Error,
|
|
||||||
e_FileUpdate_Deleted,
|
|
||||||
e_FileUpdate_Modified,
|
|
||||||
e_FileUpdate_AttrModified,
|
|
||||||
e_FileUpdate_Linked,
|
|
||||||
e_FileUpdate_Renamed,
|
|
||||||
e_FileUpdate_Revoked,
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO : in FreeBSD boost function doesn`t work with boost bind
|
|
||||||
// so currently we only support for static function ptr only
|
|
||||||
//typedef boost::function< void ( const std::string&, eFileUpdatedOptions ) > PFN_FileChangeListener;
|
|
||||||
typedef void (* PFN_FileChangeListener )(const std::string&, eFileUpdatedOptions);
|
|
||||||
|
|
||||||
struct IFileMonitor
|
|
||||||
{
|
|
||||||
virtual void Update (DWORD dwPulses) = 0;
|
|
||||||
virtual void AddWatch (const std::string& strFileName, PFN_FileChangeListener pListenerFunc) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // IFILEMONITOR_INCLUDED
|
|
||||||
@@ -692,15 +692,6 @@ void CHARACTER_MANAGER::Update(int iPulse)
|
|||||||
for (itertype(m_map_dwMobKillCount) it = m_map_dwMobKillCount.begin(); it != m_map_dwMobKillCount.end(); ++it)
|
for (itertype(m_map_dwMobKillCount) it = m_map_dwMobKillCount.begin(); it != m_map_dwMobKillCount.end(); ++it)
|
||||||
DBManager::instance().SendMoneyLog(MONEY_LOG_MONSTER_KILL, it->first, it->second);
|
DBManager::instance().SendMoneyLog(MONEY_LOG_MONSTER_KILL, it->first, it->second);
|
||||||
|
|
||||||
#ifdef _USE_SERVER_KEY_
|
|
||||||
extern bool Metin2Server_IsInvalid();
|
|
||||||
extern bool g_bShutdown;
|
|
||||||
if (Metin2Server_IsInvalid())
|
|
||||||
{
|
|
||||||
g_bShutdown = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_map_dwMobKillCount.clear();
|
m_map_dwMobKillCount.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -192,16 +192,6 @@ EVENTFUNC(ping_event)
|
|||||||
desc->SetPong(false);
|
desc->SetPong(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_LIMIT_TIME
|
|
||||||
if ((unsigned)get_global_time() >= GLOBAL_LIMIT_TIME)
|
|
||||||
{
|
|
||||||
extern void ClearAdminPages();
|
|
||||||
ClearAdminPages();
|
|
||||||
extern g_bShutdown;
|
|
||||||
g_bShutdown = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
desc->SendHandshake(get_dword_time(), 0);
|
desc->SendHandshake(get_dword_time(), 0);
|
||||||
|
|
||||||
return (ping_event_second_cycle);
|
return (ping_event_second_cycle);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "common/stl.h"
|
#include "common/stl.h"
|
||||||
#include "common/length.h"
|
#include "common/length.h"
|
||||||
#include "IFileMonitor.h"
|
|
||||||
|
|
||||||
class CLoginKey;
|
class CLoginKey;
|
||||||
class CClientPackageCryptInfo;
|
class CClientPackageCryptInfo;
|
||||||
|
|||||||
@@ -18,10 +18,6 @@
|
|||||||
#include "castle.h"
|
#include "castle.h"
|
||||||
#include "dev_log.h"
|
#include "dev_log.h"
|
||||||
|
|
||||||
#ifndef OS_WINDOWS
|
|
||||||
#include "limit_time.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern time_t get_global_time();
|
extern time_t get_global_time();
|
||||||
|
|
||||||
bool IsEmptyAdminPage()
|
bool IsEmptyAdminPage()
|
||||||
@@ -39,14 +35,6 @@ bool IsAdminPage(const char * ip)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearAdminPages()
|
|
||||||
{
|
|
||||||
for (size_t n = 0; n < g_stAdminPageIP.size(); ++n)
|
|
||||||
g_stAdminPageIP[n].clear();
|
|
||||||
|
|
||||||
g_stAdminPageIP.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
CInputProcessor::CInputProcessor() : m_pPacketInfo(NULL), m_iBufferLeft(0)
|
CInputProcessor::CInputProcessor() : m_pPacketInfo(NULL), m_iBufferLeft(0)
|
||||||
{
|
{
|
||||||
if (!m_pPacketInfo)
|
if (!m_pPacketInfo)
|
||||||
@@ -174,17 +162,6 @@ bool CInputProcessor::Process(LPDESC lpDesc, const void * c_pvOrig, int iBytes,
|
|||||||
void CInputProcessor::Pong(LPDESC d)
|
void CInputProcessor::Pong(LPDESC d)
|
||||||
{
|
{
|
||||||
d->SetPong(true);
|
d->SetPong(true);
|
||||||
|
|
||||||
extern bool Metin2Server_IsInvalid();
|
|
||||||
|
|
||||||
#ifdef ENABLE_LIMIT_TIME
|
|
||||||
if (Metin2Server_IsInvalid())
|
|
||||||
{
|
|
||||||
extern bool g_bShutdown;
|
|
||||||
g_bShutdown = true;
|
|
||||||
ClearAdminPages();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputProcessor::Handshake(LPDESC d, const char * c_pData)
|
void CInputProcessor::Handshake(LPDESC d, const char * c_pData)
|
||||||
|
|||||||
@@ -9,10 +9,6 @@
|
|||||||
#include "locale_service.h"
|
#include "locale_service.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
#ifndef OS_WINDOWS
|
|
||||||
#include "limit_time.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern time_t get_global_time();
|
extern time_t get_global_time();
|
||||||
|
|
||||||
bool FN_IS_VALID_LOGIN_STRING(const char *str)
|
bool FN_IS_VALID_LOGIN_STRING(const char *str)
|
||||||
@@ -106,17 +102,6 @@ CInputAuth::CInputAuth()
|
|||||||
|
|
||||||
void CInputAuth::Login(LPDESC d, const char * c_pData)
|
void CInputAuth::Login(LPDESC d, const char * c_pData)
|
||||||
{
|
{
|
||||||
extern bool Metin2Server_IsInvalid();
|
|
||||||
|
|
||||||
#ifdef ENABLE_LIMIT_TIME
|
|
||||||
if (Metin2Server_IsInvalid())
|
|
||||||
{
|
|
||||||
extern void ClearAdminPages();
|
|
||||||
ClearAdminPages();
|
|
||||||
exit(1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
TPacketCGLogin3 * pinfo = (TPacketCGLogin3 *) c_pData;
|
TPacketCGLogin3 * pinfo = (TPacketCGLogin3 *) c_pData;
|
||||||
|
|
||||||
if (!g_bAuthServer)
|
if (!g_bAuthServer)
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
#ifndef __LIMIT_TIME__
|
|
||||||
#define __LIMIT_TIME__
|
|
||||||
|
|
||||||
// #define ENABLE_LIMIT_TIME
|
|
||||||
#define GLOBAL_LIMIT_TIME 1684265966UL // Tue May 16 21:39:26 2023
|
|
||||||
#define TIME_OVER_PONG_DOWN_RATE 50000
|
|
||||||
#define TIME_OVER_LOGIN_DOWN_RATE 10000
|
|
||||||
#endif
|
|
||||||
@@ -58,15 +58,6 @@
|
|||||||
#include "skill_power.h"
|
#include "skill_power.h"
|
||||||
#include "SpeedServer.h"
|
#include "SpeedServer.h"
|
||||||
#include "DragonSoul.h"
|
#include "DragonSoul.h"
|
||||||
#ifndef OS_WINDOWS
|
|
||||||
#include "limit_time.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#define __FILEMONITOR__
|
|
||||||
|
|
||||||
#if defined (OS_FREEBSD) && defined(__FILEMONITOR__)
|
|
||||||
#include "FileMonitor_FreeBSD.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// #ifndef OS_WINDOWS
|
// #ifndef OS_WINDOWS
|
||||||
// #include <gtest/gtest.h>
|
// #include <gtest/gtest.h>
|
||||||
@@ -76,11 +67,6 @@
|
|||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 윈도우에서 테스트할 때는 항상 서버키 체크
|
|
||||||
#ifdef _WIN32
|
|
||||||
//#define _USE_SERVER_KEY_
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern void WriteVersion();
|
extern void WriteVersion();
|
||||||
//extern const char * _malloc_options;
|
//extern const char * _malloc_options;
|
||||||
#if defined(OS_FREEBSD) && defined(DEBUG_ALLOC)
|
#if defined(OS_FREEBSD) && defined(DEBUG_ALLOC)
|
||||||
@@ -236,13 +222,6 @@ void heartbeat(LPHEART ht, int pulse)
|
|||||||
// 1초마다
|
// 1초마다
|
||||||
if (!(pulse % ht->passes_per_sec))
|
if (!(pulse % ht->passes_per_sec))
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_LIMIT_TIME
|
|
||||||
if ((unsigned)get_global_time() >= GLOBAL_LIMIT_TIME)
|
|
||||||
{
|
|
||||||
g_bShutdown = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!g_bAuthServer)
|
if (!g_bAuthServer)
|
||||||
{
|
{
|
||||||
TPlayerCountPacket pack;
|
TPlayerCountPacket pack;
|
||||||
@@ -294,14 +273,6 @@ void heartbeat(LPHEART ht, int pulse)
|
|||||||
if (!(pulse % (passes_per_sec + 4)))
|
if (!(pulse % (passes_per_sec + 4)))
|
||||||
CHARACTER_MANAGER::instance().ProcessDelayedSave();
|
CHARACTER_MANAGER::instance().ProcessDelayedSave();
|
||||||
|
|
||||||
//4초 마다
|
|
||||||
#if defined (OS_FREEBSD) && defined(__FILEMONITOR__)
|
|
||||||
if (!(pulse % (passes_per_sec * 5)))
|
|
||||||
{
|
|
||||||
FileMonitorFreeBSD::Instance().Update(pulse);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 약 5.08초마다
|
// 약 5.08초마다
|
||||||
if (!(pulse % (passes_per_sec * 5 + 2)))
|
if (!(pulse % (passes_per_sec * 5 + 2)))
|
||||||
{
|
{
|
||||||
@@ -335,87 +306,6 @@ void heartbeat(LPHEART ht, int pulse)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool g_isInvalidServer = false;
|
|
||||||
|
|
||||||
bool Metin2Server_IsInvalid()
|
|
||||||
{
|
|
||||||
return g_isInvalidServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Metin2Server_Check()
|
|
||||||
{
|
|
||||||
#ifdef _SERVER_CHECK_
|
|
||||||
|
|
||||||
#ifdef _USE_SERVER_KEY_
|
|
||||||
if (false == CheckServer::CheckIp(g_szPublicIP))
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
fprintf(stderr, "check ip failed\n");
|
|
||||||
#endif
|
|
||||||
g_isInvalidServer = true;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (LC_IsEurope() || test_server)
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
// 브라질 ip
|
|
||||||
if (strncmp (g_szPublicIP, "189.112.1", 9) == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 캐나다 ip
|
|
||||||
if (strncmp (g_szPublicIP, "74.200.6", 8) == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
static const size_t CheckServerListSize = 1;
|
|
||||||
static const char* CheckServerList[] = { "202.31.178.251"};
|
|
||||||
static const int CheckServerPort = 7120;
|
|
||||||
|
|
||||||
socket_t sockConnector = INVALID_SOCKET;
|
|
||||||
|
|
||||||
for (size_t i = 0 ; i < CheckServerListSize ; i++)
|
|
||||||
{
|
|
||||||
sockConnector = socket_connect( CheckServerList[i], CheckServerPort );
|
|
||||||
|
|
||||||
if (0 < sockConnector)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 > sockConnector)
|
|
||||||
{
|
|
||||||
if (true != LC_IsEurope()) // 유럽은 접속을 하지 못하면 인증된 것으로 간주
|
|
||||||
g_isInvalidServer = true;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char buf[256] = { 0, };
|
|
||||||
|
|
||||||
socket_read(sockConnector, buf, sizeof(buf) - 1);
|
|
||||||
|
|
||||||
sys_log(0, "recv[%s]", buf);
|
|
||||||
|
|
||||||
if (strncmp(buf, "OK", 2) == 0)
|
|
||||||
g_isInvalidServer = false;
|
|
||||||
else if (strncmp(buf, "CK", 2) == 0)
|
|
||||||
g_isInvalidServer = true;
|
|
||||||
|
|
||||||
socket_close(sockConnector);
|
|
||||||
#else
|
|
||||||
g_isInvalidServer = false;
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CleanUpForEarlyExit() {
|
static void CleanUpForEarlyExit() {
|
||||||
CancelReloadSpamEvent();
|
CancelReloadSpamEvent();
|
||||||
}
|
}
|
||||||
@@ -514,15 +404,6 @@ int main(int argc, char **argv)
|
|||||||
ani_init();
|
ani_init();
|
||||||
PanamaLoad();
|
PanamaLoad();
|
||||||
|
|
||||||
Metin2Server_Check();
|
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_USE_SERVER_KEY_)
|
|
||||||
if (CheckServer::IsFail())
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( g_bTrafficProfileOn )
|
if ( g_bTrafficProfileOn )
|
||||||
TrafficProfiler::instance().Initialize( TRAFFIC_PROFILE_FLUSH_CYCLE, "ProfileLog" );
|
TrafficProfiler::instance().Initialize( TRAFFIC_PROFILE_FLUSH_CYCLE, "ProfileLog" );
|
||||||
|
|
||||||
@@ -533,11 +414,6 @@ int main(int argc, char **argv)
|
|||||||
sys_err("Failed to Load ClientPackageCryptInfo File(%s)", strPackageCryptInfoDir.c_str());
|
sys_err("Failed to Load ClientPackageCryptInfo File(%s)", strPackageCryptInfoDir.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined (OS_FREEBSD) && defined(__FILEMONITOR__)
|
|
||||||
PFN_FileChangeListener pPackageNotifyFunc = &(DESC_MANAGER::NotifyClientPackageFileChanged);
|
|
||||||
//FileMonitorFreeBSD::Instance().AddWatch( strPackageCryptInfoName, pPackageNotifyFunc );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (idle());
|
while (idle());
|
||||||
|
|
||||||
sys_log(0, "<shutdown> Starting...");
|
sys_log(0, "<shutdown> Starting...");
|
||||||
@@ -630,12 +506,6 @@ int start(int argc, char **argv)
|
|||||||
#if defined(OS_FREEBSD) && defined(DEBUG_ALLOC)
|
#if defined(OS_FREEBSD) && defined(DEBUG_ALLOC)
|
||||||
_malloc_message = WriteMallocMessage;
|
_malloc_message = WriteMallocMessage;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_LIMIT_TIME
|
|
||||||
if ((unsigned)get_global_time() >= GLOBAL_LIMIT_TIME)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char optstring[] = "npverltI";
|
char optstring[] = "npverltI";
|
||||||
while ((ch = getopt(argc, argv, optstring)) != -1)
|
while ((ch = getopt(argc, argv, optstring)) != -1)
|
||||||
@@ -870,12 +740,6 @@ int idle()
|
|||||||
memset(&thecore_profiler[0], 0, sizeof(thecore_profiler));
|
memset(&thecore_profiler[0], 0, sizeof(thecore_profiler));
|
||||||
memset(&s_dwProfiler[0], 0, sizeof(s_dwProfiler));
|
memset(&s_dwProfiler[0], 0, sizeof(s_dwProfiler));
|
||||||
}
|
}
|
||||||
#ifdef _USE_SERVER_KEY_
|
|
||||||
if (Metin2Server_IsInvalid() && 0 == (thecore_random() % 7146))
|
|
||||||
{
|
|
||||||
return 0; // shutdown
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef OS_WINDOWS
|
#ifdef OS_WINDOWS
|
||||||
if (_kbhit()) {
|
if (_kbhit()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user