Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 04-19-2008, 12:47 AM
TheLieka
Developer
 
Join Date: Oct 2004
Location: THE ATL (wut wut)
Posts: 325
Default

Correction: Part of the MQWarp detector code got caught in the last diff. Here's the diff without that part.

Code:
diff  C:/1106/zone/command.h C:/vztz/zone/command.h
231a232
> void command_ipban(Client *c, const Seperator *sep);
diff  C:/1106/zone/command.cpp C:/vztz/zone/command.cpp
362a363
> 		command_add("ipban","[IP address] - Ban IP by character name",200,command_ipban) ||
1366a1368
> 
> void command_ipban(Client *c, const Seperator *sep)
> {
> 	if(sep->arg[1] == 0)
> 	{
> 		c->Message(0, "Usage:  #ipban [xxx.xxx.xxx.xxx]");
> 	} else {
> 		if(database.AddBannedIP(sep->arg[1], c->GetName())) {
> 			c->Message(0, "%s has been successfully added to the Banned_IPs table by %s",sep->arg[1], c->GetName());
> 		} else {
> 			c->Message(0, "IPBan Failed (IP address is possibly already in the table?)");
> 		}
> 	}
> }
> 
diff  C:/1106/world/net.cpp C:/vztz/world/net.cpp
361,364c361,378
< 			_log(WORLD__CLIENT, "New client from %s:%d", inet_ntoa(in), ntohs(eqsi->GetRemotePort()));
< 			Client* client = new Client(eqsi);
< 			// @merth: client->zoneattempt=0;
< 			client_list.Add(client);
---
> 			if (RuleB(World, UseBannedIPsTable)){ //Lieka:  Check to see if we have the responsibility for blocking IPs.
> 				_log(WORLD__CLIENT, "Checking inbound connection %s against BannedIPs table", inet_ntoa(in));
> 				if (!database.CheckBannedIPs(inet_ntoa(in))){ //Lieka:  Check inbound IP against banned IP table.
> 					_log(WORLD__CLIENT, "Connection %s PASSED banned IPs check.  Processing connection.", inet_ntoa(in));
> 					Client* client = new Client(eqsi);
> 					// @merth: client->zoneattempt=0;
> 					client_list.Add(client);
> 				} else {
> 					_log(WORLD__CLIENT, "Connection from %s FAILED banned IPs check.  Closing connection.", inet_ntoa(in));
> 					eqsi->Close(); //Lieka:  If the inbound IP is on the banned table, close the EQStream.
> 				}
> 			}
> 			if (!RuleB(World, UseBannedIPsTable)){
> 					_log(WORLD__CLIENT, "New connection from %s:%d, processing connection", inet_ntoa(in), ntohs(eqsi->GetRemotePort()));
> 					Client* client = new Client(eqsi);
> 					// @merth: client->zoneattempt=0;
> 					client_list.Add(client);
> 				}
diff  C:/1106/common/ruletypes.h C:/vztz/common/ruletypes.h
69a70
> RULE_BOOL ( World, UseBannedIPsTable, false ) //Lieka Edit:  Check banned IP table before accepting connections to the world server.  Default value: false (feature disabled)
diff  C:/1106/common/database.h C:/vztz/common/database.h
139a140,141
> 	bool	CheckBannedIPs(const char* loginIP); //Lieka Edit:  Check incomming connection against banned IP table.
> 	bool	AddBannedIP(char* bannedIP, const char* notes); //Lieka Edit:  Add IP address to the Banned_IPs table.
diff  C:/1106/common/database.cpp C:/vztz/common/database.cpp
207a208,257
> //Lieka:  Get Banned IP Address List - Only return false if the incoming connection's IP address is not present in the banned_ips table.
> bool Database::CheckBannedIPs(const char* loginIP)
> {
> 	char errbuf[MYSQL_ERRMSG_SIZE];
>     char *query = 0;
>     MYSQL_RES *result;
>     MYSQL_ROW row;
> 	//cout << "Checking against Banned IPs table."<< endl; //Lieka:  Debugging
> 	if (RunQuery(query, MakeAnyLenString(&query, "SELECT ip_address FROM Banned_IPs WHERE ip_address='%s'", loginIP), errbuf, &result)) {
> 		safe_delete_array(query);
> 		if (mysql_num_rows(result) != 0)
> 		{
> 			//cout << loginIP << " was present in the banned IPs table" << endl; //Lieka:  Debugging
> 			mysql_free_result(result);
> 			return true;
> 		}
> 		else
> 		{
> 			//cout << loginIP << " was not present in the banned IPs table." << endl; //Lieka:  Debugging
> 			mysql_free_result(result);
> 			return false;
> 		}
> 		mysql_free_result(result);
> 	}
> 	else
> 	{
> 		cerr << "Error in CheckBannedIPs query '" << query << "' " << errbuf << endl;
> 		safe_delete_array(query);
> 		return true;
> 	}
> 	
> 	return true;
> }
> 
> bool Database::AddBannedIP(char* bannedIP, const char* notes)
> {
> 	char errbuf[MYSQL_ERRMSG_SIZE];
>     char *query = 0;
> 	
> 	if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes), errbuf)) {
> 		cerr << "Error in ReserveName query '" << query << "' " << errbuf << endl;
> 		safe_delete_array(query);
> 		return false;
> 	}
> 	safe_delete_array(query);
> 	return true;
> }
> 
> //End Lieka Edit
Dax
__________________
Daxum



Former ServerOp - Vallon Zek / Tallon Zek Emu Server - Legit / Guild PvP - (2007 - 2011 RIP)
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 07:35 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3