From ae3a8a54935e2196d813f4dcc2836c482bec06f3 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 14 Aug 2017 14:12:06 +0100 Subject: [PATCH] Added capability to unblock addresses without a restart --- src/pocketmine/command/defaults/PardonIpCommand.php | 1 + src/pocketmine/network/AdvancedSourceInterface.php | 5 +++++ src/pocketmine/network/Network.php | 6 ++++++ src/pocketmine/network/mcpe/RakLibInterface.php | 4 ++++ src/raklib | 2 +- 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/command/defaults/PardonIpCommand.php b/src/pocketmine/command/defaults/PardonIpCommand.php index 76cc5544f..cfe7571ed 100644 --- a/src/pocketmine/command/defaults/PardonIpCommand.php +++ b/src/pocketmine/command/defaults/PardonIpCommand.php @@ -50,6 +50,7 @@ class PardonIpCommand extends VanillaCommand{ if(preg_match("/^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$/", $args[0])){ $sender->getServer()->getIPBans()->remove($args[0]); + $sender->getServer()->getNetwork()->unblockAddress($args[0]); Command::broadcastCommandMessage($sender, new TranslationContainer("commands.unbanip.success", [$args[0]])); }else{ $sender->sendMessage(new TranslationContainer("commands.unbanip.invalid")); diff --git a/src/pocketmine/network/AdvancedSourceInterface.php b/src/pocketmine/network/AdvancedSourceInterface.php index b85ff8b99..cf553081e 100644 --- a/src/pocketmine/network/AdvancedSourceInterface.php +++ b/src/pocketmine/network/AdvancedSourceInterface.php @@ -34,6 +34,11 @@ interface AdvancedSourceInterface extends SourceInterface{ */ public function blockAddress(string $address, int $timeout = 300); + /** + * @param string $address + */ + public function unblockAddress(string $address); + /** * @param Network $network */ diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index 6b60ddd80..4f1ce278e 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -171,4 +171,10 @@ class Network{ $interface->blockAddress($address, $timeout); } } + + public function unblockAddress(string $address){ + foreach($this->advancedInterfaces as $interface){ + $interface->unblockAddress($address); + } + } } diff --git a/src/pocketmine/network/mcpe/RakLibInterface.php b/src/pocketmine/network/mcpe/RakLibInterface.php index 863caaf14..2e57a27cd 100644 --- a/src/pocketmine/network/mcpe/RakLibInterface.php +++ b/src/pocketmine/network/mcpe/RakLibInterface.php @@ -152,6 +152,10 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ $this->interface->blockAddress($address, $timeout); } + public function unblockAddress(string $address){ + $this->interface->unblockAddress($address); + } + public function handleRaw($address, $port, $payload){ $this->server->handlePacket($address, $port, $payload); } diff --git a/src/raklib b/src/raklib index ddd953f0e..cd31b332c 160000 --- a/src/raklib +++ b/src/raklib @@ -1 +1 @@ -Subproject commit ddd953f0e2a6577dd39f0a450546dad12a472b01 +Subproject commit cd31b332c38f98bafa238771caf1583f8461f7f8