Block IP addresses on ban-ip

This commit is contained in:
Shoghi Cervantes 2014-12-26 13:56:35 +01:00
parent 854479180f
commit 2db2e8cfc4
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89
4 changed files with 21 additions and 3 deletions

View File

@ -71,7 +71,7 @@ namespace pocketmine {
use pocketmine\wizard\Installer; use pocketmine\wizard\Installer;
const VERSION = "Alpha_1.4dev"; const VERSION = "Alpha_1.4dev";
const API_VERSION = "1.9.0"; const API_VERSION = "1.10.0";
const CODENAME = "絶好(Zekkou)ケーキ(Cake)"; const CODENAME = "絶好(Zekkou)ケーキ(Cake)";
const MINECRAFT_VERSION = "v0.10.4 alpha"; const MINECRAFT_VERSION = "v0.10.4 alpha";

View File

@ -622,6 +622,16 @@ class Server{
$this->mainInterface->putRaw($address, $port, $payload); $this->mainInterface->putRaw($address, $port, $payload);
} }
/**
* Blocks an IP address from the main interface. Setting timeout to -1 will block it forever
*
* @param string $address
* @param int $timeout
*/
public function blockAddress($address, $timeout = 300){
$this->mainInterface->blockAddress($address, $timeout);
}
/** /**
* @param string $address * @param string $address
* @param int $port * @param int $port
@ -639,7 +649,7 @@ class Server{
} }
} }
$this->mainInterface->blockAddress($address, 600); $this->blockAddress($address, 600);
} }
//TODO: add raw packet events //TODO: add raw packet events
} }
@ -1834,6 +1844,9 @@ class Server{
$this->reloadWhitelist(); $this->reloadWhitelist();
$this->operators->reload(); $this->operators->reload();
foreach($this->getIPBans()->getEntries() as $entry){
$this->blockAddress($entry->getName(), -1);
}
$this->pluginManager->registerInterface(PharPluginLoader::class); $this->pluginManager->registerInterface(PharPluginLoader::class);
$this->pluginManager->loadPlugins($this->pluginPath); $this->pluginManager->loadPlugins($this->pluginPath);
@ -1911,6 +1924,9 @@ class Server{
} }
foreach($this->getIPBans()->getEntries() as $entry){
$this->blockAddress($entry->getName(), -1);
}
if($this->getProperty("settings.send-usage", true) !== false){ if($this->getProperty("settings.send-usage", true) !== false){
$this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask([$this, "sendUsage"]), 6000, 6000); $this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask([$this, "sendUsage"]), 6000, 6000);

View File

@ -75,6 +75,8 @@ class BanIpCommand extends VanillaCommand{
} }
} }
$sender->getServer()->blockAddress($ip, -1);
Command::broadcastCommandMessage($sender, "Banned IP Address " . $ip); Command::broadcastCommandMessage($sender, "Banned IP Address " . $ip);
} }
} }

@ -1 +1 @@
Subproject commit 9a1c1868b34c2db546cad5895e5974e74ab24763 Subproject commit 658529ec44f30ce210f5cf42d2280e51332fe3d0