From 72f4f10dbb9982e3287d8de58364f9eddbd7fe37 Mon Sep 17 00:00:00 2001 From: Uleat Date: Tue, 24 Dec 2019 02:36:00 -0500 Subject: [PATCH 1/2] Rename table `Banned_IPs` to `banned_ips` [skip ci] --- common/version.h | 2 +- utils/sql/db_update_manifest.txt | 1 + utils/sql/git/required/2019_12_24_banned_ips_update.sql | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 utils/sql/git/required/2019_12_24_banned_ips_update.sql diff --git a/common/version.h b/common/version.h index bf889cc21..e51279456 100644 --- a/common/version.h +++ b/common/version.h @@ -31,7 +31,7 @@ */ -#define CURRENT_BINARY_DATABASE_VERSION 9144 +#define CURRENT_BINARY_DATABASE_VERSION 9145 #ifdef BOTS #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9026 diff --git a/utils/sql/db_update_manifest.txt b/utils/sql/db_update_manifest.txt index c00255a55..3a6fdc601 100644 --- a/utils/sql/db_update_manifest.txt +++ b/utils/sql/db_update_manifest.txt @@ -398,6 +398,7 @@ 9142|2019_09_02_required_spawn_filter.sql|SHOW COLUMNS FROM `spawnentry` LIKE 'condition_value_filter'|empty| 9143|2019_09_16_account_table_changes.sql|SHOW COLUMNS FROM `account` LIKE 'ls_id'|empty| 9144|2019_11_09_logsys_description_update.sql|SELECT * FROM `logsys_categories`|not_empty| +9145|2019_12_24_banned_ips_update.sql|SHOW TABLES LIKE 'Banned_IPs'|not_empty| # Upgrade conditions: # This won't be needed after this system is implemented, but it is used database that are not diff --git a/utils/sql/git/required/2019_12_24_banned_ips_update.sql b/utils/sql/git/required/2019_12_24_banned_ips_update.sql new file mode 100644 index 000000000..b05bd682b --- /dev/null +++ b/utils/sql/git/required/2019_12_24_banned_ips_update.sql @@ -0,0 +1,5 @@ +RENAME TABLE `Banned_IPs` TO `Banned_IPs_`; + +CREATE TABLE `banned_ips` (PRIMARY KEY (`ip_address`)) SELECT `ip_address`, `notes` FROM `Banned_IPs_`; + +DROP TABLE IF EXISTS `Banned_IPs_`; From 20538e91a1f747c11ad7f86b5ab85cb52e434284 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Tue, 24 Dec 2019 02:59:58 -0600 Subject: [PATCH 2/2] Adjust usages for banned_ips table to reflect Uleat's changes --- common/database.cpp | 4 ++-- common/database.h | 2 +- common/ruletypes.h | 2 +- utils/sql/user_tables.txt | 2 +- zone/command.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/database.cpp b/common/database.cpp index 70741cf86..cbec7fc10 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -124,7 +124,7 @@ uint32 Database::CheckLogin(const char* name, const char* password, const char * //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) { - std::string query = StringFormat("SELECT ip_address FROM Banned_IPs WHERE ip_address='%s'", loginIP); + std::string query = StringFormat("SELECT ip_address FROM banned_ips WHERE ip_address='%s'", loginIP); auto results = QueryDatabase(query); @@ -140,7 +140,7 @@ bool Database::CheckBannedIPs(const char* loginIP) } bool Database::AddBannedIP(char* bannedIP, const char* notes) { - std::string query = StringFormat("INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes); + std::string query = StringFormat("INSERT into banned_ips SET ip_address='%s', notes='%s'", bannedIP, notes); auto results = QueryDatabase(query); if (!results.Success()) { return false; diff --git a/common/database.h b/common/database.h index 0dce5318d..9fc196d18 100644 --- a/common/database.h +++ b/common/database.h @@ -120,7 +120,7 @@ public: /* General Information Queries */ - bool AddBannedIP(char* bannedIP, const char* notes); //Add IP address to the Banned_IPs table. + bool AddBannedIP(char* bannedIP, const char* notes); //Add IP address to the banned_ips table. bool AddGMIP(char* ip_address, char* name); bool CheckBannedIPs(const char* loginIP); //Check incoming connection against banned IP table. bool CheckGMIPs(const char* loginIP, uint32 account_id); diff --git a/common/ruletypes.h b/common/ruletypes.h index 5207b6cbf..c7b4a1aee 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -212,7 +212,7 @@ RULE_CATEGORY_END() RULE_CATEGORY(World) RULE_INT(World, ZoneAutobootTimeoutMS, 60000, "") RULE_INT(World, ClientKeepaliveTimeoutMS, 65000, "") -RULE_BOOL(World, UseBannedIPsTable, false, "Toggle whether or not to check incoming client connections against the Banned_IPs table. Set this value to false to disable this feature") +RULE_BOOL(World, UseBannedIPsTable, false, "Toggle whether or not to check incoming client connections against the banned_ips table. Set this value to false to disable this feature") RULE_BOOL(World, EnableTutorialButton, true, "") RULE_BOOL(World, EnableReturnHomeButton, true, "") RULE_INT(World, MaxLevelForTutorial, 10, "") diff --git a/utils/sql/user_tables.txt b/utils/sql/user_tables.txt index 9806395e8..ee19fe472 100644 --- a/utils/sql/user_tables.txt +++ b/utils/sql/user_tables.txt @@ -6,7 +6,7 @@ account_rewards adventure_details adventure_members adventure_stats -Banned_IPs +banned_ips bugs buyer char_recipe_list diff --git a/zone/command.cpp b/zone/command.cpp index 3d71e4ab4..9740e0811 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -7547,7 +7547,7 @@ void command_ipban(Client *c, const Seperator *sep) c->Message(Chat::White, "Usage: #ipban [xxx.xxx.xxx.xxx]"); } else { if(database.AddBannedIP(sep->arg[1], c->GetName())) { - c->Message(Chat::White, "%s has been successfully added to the Banned_IPs table by %s", sep->arg[1], c->GetName()); + c->Message(Chat::White, "%s has been successfully added to the banned_ips table by %s", sep->arg[1], c->GetName()); } else { c->Message(Chat::White, "IPBan Failed (IP address is possibly already in the table?)"); }