chore: blockcountry, blockexception removed
This commit is contained in:
@@ -1,151 +0,0 @@
|
||||
/*********************************************************************
|
||||
* date : 2007.05.31
|
||||
* file : block_country.cpp
|
||||
* author : mhh
|
||||
* description :
|
||||
*/
|
||||
|
||||
#define _block_country_cpp_
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "constants.h"
|
||||
#include "block_country.h"
|
||||
#include "dev_log.h"
|
||||
|
||||
#define DEC_ITER(iter) std::vector<T_BLOCK_IP*>::iterator iter
|
||||
#define DO_ALL_BLOCKED_IP(iter) for ((iter)=s_blocked_ip.begin(); (iter)!=s_blocked_ip.end(); ++(iter))
|
||||
|
||||
#define DEC_EXCEPTION_ITER(iter) std::set<std::string>::iterator iter
|
||||
|
||||
|
||||
typedef struct {
|
||||
DWORD ip_from;
|
||||
DWORD ip_to;
|
||||
} T_BLOCK_IP;
|
||||
|
||||
//--------------------------------------
|
||||
// static variables
|
||||
std::vector<T_BLOCK_IP*> s_blocked_ip;
|
||||
std::set<std::string> s_block_exception;
|
||||
// static variables
|
||||
//--------------------------------------
|
||||
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
// static functions
|
||||
static void __add_block_exception(const char *login)
|
||||
{
|
||||
dev_log(LOG_DEB0, "BLOCK_EXCEPTION_ADD : %s", login);
|
||||
|
||||
DEC_EXCEPTION_ITER(iter);
|
||||
std::string string_login(login);
|
||||
|
||||
iter = s_block_exception.find(string_login);
|
||||
|
||||
// can not find
|
||||
if (iter==s_block_exception.end())
|
||||
{
|
||||
s_block_exception.insert(string_login);
|
||||
}
|
||||
}
|
||||
|
||||
static void __del_block_exception(const char *login)
|
||||
{
|
||||
dev_log(LOG_DEB0, "BLOCK_EXCEPTION_DEL : %s", login);
|
||||
|
||||
DEC_EXCEPTION_ITER(iter);
|
||||
std::string string_login(login);
|
||||
|
||||
iter = s_block_exception.find(string_login);
|
||||
|
||||
// ok : find
|
||||
if (iter!=s_block_exception.end())
|
||||
{
|
||||
s_block_exception.erase(iter);
|
||||
}
|
||||
}
|
||||
// static functions
|
||||
//--------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
void add_blocked_country_ip(TPacketBlockCountryIp *data)
|
||||
{
|
||||
T_BLOCK_IP *block_ip = M2_NEW T_BLOCK_IP;
|
||||
|
||||
block_ip->ip_from = data->ip_from;
|
||||
block_ip->ip_to = data->ip_to;
|
||||
|
||||
s_blocked_ip.push_back(block_ip);
|
||||
|
||||
dev_log(LOG_DEB0, "BLOCKED_IP = %u - %u", block_ip->ip_from, block_ip->ip_to);
|
||||
}
|
||||
|
||||
|
||||
void block_exception(TPacketBlockException *data)
|
||||
{
|
||||
if (NULL==data) return;
|
||||
|
||||
if (BLOCK_EXCEPTION_CMD_ADD!=data->cmd && BLOCK_EXCEPTION_CMD_DEL!=data->cmd)
|
||||
return;
|
||||
|
||||
|
||||
switch (data->cmd)
|
||||
{
|
||||
case BLOCK_EXCEPTION_CMD_ADD:
|
||||
__add_block_exception(data->login);
|
||||
break;
|
||||
case BLOCK_EXCEPTION_CMD_DEL:
|
||||
__del_block_exception(data->login);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_blocked_country_ip(const char *user_ip)
|
||||
{
|
||||
DEC_ITER(iter);
|
||||
T_BLOCK_IP *block_ip;
|
||||
DWORD ip_number;
|
||||
struct in_addr st_addr;
|
||||
|
||||
#ifndef OS_WINDOWS
|
||||
if (0 == inet_aton(user_ip, &st_addr))
|
||||
#else
|
||||
unsigned long in_address;
|
||||
in_address = inet_addr(user_ip);
|
||||
st_addr.s_addr = in_address;
|
||||
if (INADDR_NONE == in_address)
|
||||
#endif
|
||||
{
|
||||
dev_log(LOG_INFO, "BLOCKED_COUNTRY_IP (%s) : YES", user_ip);
|
||||
return true; // 아이피가 괴상하니 일단 블럭처리
|
||||
}
|
||||
ip_number = htonl(st_addr.s_addr);
|
||||
|
||||
DO_ALL_BLOCKED_IP(iter)
|
||||
{
|
||||
block_ip = *iter;
|
||||
if ( block_ip->ip_from <= ip_number && ip_number <= block_ip->ip_to )
|
||||
{
|
||||
dev_log(LOG_INFO, "BLOCKED_COUNTRY_IP (%s) : YES", user_ip);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
dev_log(LOG_INFO, "BLOCKED_COUNTRY_IP (%s) : NO", user_ip);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_block_exception(const char *login)
|
||||
{
|
||||
std::string login_string(login);
|
||||
std::set<std::string>::iterator iter;
|
||||
|
||||
iter = s_block_exception.find(login_string);
|
||||
if (iter != s_block_exception.end())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/*********************************************************************
|
||||
* date : 2007.05.31
|
||||
* file : block_country.h
|
||||
* author : mhh
|
||||
* description :
|
||||
*/
|
||||
|
||||
#ifndef _block_country_h_
|
||||
#define _block_country_h_
|
||||
|
||||
|
||||
void add_blocked_country_ip(TPacketBlockCountryIp *data);
|
||||
void block_exception(TPacketBlockException *data);
|
||||
bool is_blocked_country_ip(const char *user_ip);
|
||||
bool is_block_exception(const char *login);
|
||||
|
||||
#endif // _block_country_h_
|
||||
|
||||
@@ -657,15 +657,6 @@ void VCardUse(LPCHARACTER CardOwner, LPCHARACTER CardTaker, LPITEM item)
|
||||
sys_log(0, "VCARD_TAKE: %u %s -> %s", p.dwID, CardOwner->GetName(), CardTaker->GetName());
|
||||
}
|
||||
|
||||
void DBManager::RequestBlockException(const char *login, int cmd)
|
||||
{
|
||||
TPacketBlockException packet;
|
||||
|
||||
packet.cmd = cmd;
|
||||
strlcpy(packet.login, login, sizeof(packet.login));
|
||||
db_clientdesc->DBPacket(HEADER_GD_BLOCK_EXCEPTION, 0, &packet, sizeof(packet));
|
||||
}
|
||||
|
||||
size_t DBManager::EscapeString(char* dst, size_t dstSize, const char *src, size_t srcSize)
|
||||
{
|
||||
return m_sql_direct.EscapeString(dst, dstSize, src, srcSize);
|
||||
|
||||
@@ -93,10 +93,6 @@ class DBManager : public singleton<DBManager>
|
||||
DWORD CountQueryResult() { return m_sql.CountResult(); }
|
||||
void ResetQueryResult() { m_sql.ResetQueryFinished(); }
|
||||
|
||||
// BLOCK EXCEPTION
|
||||
void RequestBlockException(const char *login, int cmd);
|
||||
// BLOCK EXCEPTION
|
||||
|
||||
void LoadDBString();
|
||||
const std::string & GetDBString(const std::string& key);
|
||||
const std::vector<std::string> & GetGreetMessage();
|
||||
|
||||
@@ -564,20 +564,6 @@ dev_log(LOG_DEB0, "DC : '%s'", msg.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!stBuf.compare(0, 15, "BLOCK_EXCEPTION"))
|
||||
{
|
||||
// BLOCK_EXCEPTION cmd(add=1, del=2) login
|
||||
std::istringstream is(stBuf);
|
||||
std::string dummy_string;
|
||||
std::string login_string;
|
||||
int cmd;
|
||||
|
||||
is >> dummy_string >> cmd >> login_string;
|
||||
|
||||
sys_log(0, "block_exception %s:%d", login_string.c_str(), cmd);
|
||||
DBManager::instance().RequestBlockException(login_string.c_str(), cmd);
|
||||
stResult = "BLOCK_EXCEPTION_YES";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -267,8 +267,6 @@ protected:
|
||||
|
||||
void ChangeMonarchLord(TPacketChangeMonarchLordACK* data);
|
||||
void UpdateMonarchInfo(TMonarchInfo* data);
|
||||
void AddBlockCountryIp(TPacketBlockCountryIp * data);
|
||||
void BlockException(TPacketBlockException * data);
|
||||
|
||||
// MYSHOP_PRICE_LIST
|
||||
/// 아이템 가격정보 리스트 요청에 대한 응답 패킷(HEADER_DG_MYSHOP_PRICELIST_RES) 처리함수
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "monarch.h"
|
||||
#include "affect.h"
|
||||
#include "castle.h"
|
||||
#include "block_country.h"
|
||||
#include "motion.h"
|
||||
|
||||
#include "dev_log.h"
|
||||
@@ -1002,12 +1001,6 @@ void CInputDB::Boot(const char* data)
|
||||
|
||||
// castle_boot
|
||||
castle_boot();
|
||||
|
||||
// request blocked_country_ip
|
||||
{
|
||||
db_clientdesc->DBPacket(HEADER_GD_BLOCK_COUNTRY_IP, 0, NULL, 0);
|
||||
dev_log(LOG_DEB0, "<sent HEADER_GD_BLOCK_COUNTRY_IP>");
|
||||
}
|
||||
}
|
||||
|
||||
EVENTINFO(quest_login_event_info)
|
||||
@@ -2327,13 +2320,6 @@ int CInputDB::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||
UpdateMonarchInfo((TMonarchInfo*)c_pData);
|
||||
break;
|
||||
|
||||
case HEADER_DG_BLOCK_COUNTRY_IP:
|
||||
this->AddBlockCountryIp((TPacketBlockCountryIp *) c_pData);
|
||||
break;
|
||||
case HEADER_DG_BLOCK_EXCEPTION:
|
||||
this->BlockException((TPacketBlockException *) c_pData);
|
||||
break;
|
||||
|
||||
case HEADER_DG_ACK_CHANGE_GUILD_MASTER :
|
||||
this->GuildChangeMaster((TPacketChangeGuildMaster*) c_pData);
|
||||
break;
|
||||
@@ -2484,16 +2470,6 @@ void CInputDB::UpdateMonarchInfo(TMonarchInfo* info)
|
||||
sys_log(0, "MONARCH INFO UPDATED");
|
||||
}
|
||||
|
||||
void CInputDB::AddBlockCountryIp(TPacketBlockCountryIp * data)
|
||||
{
|
||||
add_blocked_country_ip(data);
|
||||
}
|
||||
|
||||
void CInputDB::BlockException(TPacketBlockException *data)
|
||||
{
|
||||
block_exception(data);
|
||||
}
|
||||
|
||||
void CInputDB::GuildChangeMaster(TPacketChangeGuildMaster* p)
|
||||
{
|
||||
CGuildManager::instance().ChangeMaster(p->dwGuildID);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "arena.h"
|
||||
#include "OXEvent.h"
|
||||
#include "priv_manager.h"
|
||||
#include "block_country.h"
|
||||
#include "dev_log.h"
|
||||
#include "log.h"
|
||||
#include "horsename_manager.h"
|
||||
@@ -140,20 +139,6 @@ void CInputLogin::LoginByKey(LPDESC d, const char * data)
|
||||
char login[LOGIN_MAX_LEN + 1];
|
||||
trim_and_lower(pinfo->login, login, sizeof(login));
|
||||
|
||||
// is blocked ip?
|
||||
{
|
||||
dev_log(LOG_DEB0, "check_blocked_country_start");
|
||||
|
||||
if (!is_block_exception(login) && is_blocked_country_ip(d->GetHostName()))
|
||||
{
|
||||
sys_log(0, "BLOCK_COUNTRY_IP (%s)", d->GetHostName());
|
||||
d->SetPhase(PHASE_CLOSE);
|
||||
return;
|
||||
}
|
||||
|
||||
dev_log(LOG_DEB0, "check_blocked_country_end");
|
||||
}
|
||||
|
||||
if (g_bNoMoreClient)
|
||||
{
|
||||
TPacketGCLoginFailure failurePacket;
|
||||
|
||||
@@ -306,7 +306,6 @@ enum
|
||||
HEADER_GG_CHECK_CLIENT_VERSION = 21,
|
||||
HEADER_GG_BLOCK_CHAT = 22,
|
||||
|
||||
HEADER_GG_BLOCK_EXCEPTION = 24,
|
||||
HEADER_GG_SIEGE = 25,
|
||||
HEADER_GG_MONARCH_NOTICE = 26,
|
||||
HEADER_GG_MONARCH_TRANSFER = 27,
|
||||
|
||||
Reference in New Issue
Block a user