Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2021-09-06 17:31:01 +0300
committerLukas Reschke <lukas@statuscode.ch>2021-09-13 18:23:49 +0300
commit201bf52c040bad38cb8a64f86de255cd8025b46e (patch)
tree413a4c8b541b6ce123e1045ab9d57840932b74f9 /core
parent0cfbc41ab77d1c47b63a6b54ecb4f3b93369cf03 (diff)
Add database ratelimiting backend
In case no distributed memory cache is specified this adds a database backend for ratelimit purposes. Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'core')
-rw-r--r--core/Migrations/Version23000Date20210906132259.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/core/Migrations/Version23000Date20210906132259.php b/core/Migrations/Version23000Date20210906132259.php
new file mode 100644
index 00000000000..a6aa4c14e8f
--- /dev/null
+++ b/core/Migrations/Version23000Date20210906132259.php
@@ -0,0 +1,43 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OC\Core\Migrations;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+class Version23000Date20210906132259 extends SimpleMigrationStep {
+ private const TABLE_NAME = 'ratelimit_entries';
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ $hasTable = $schema->hasTable(self::TABLE_NAME);
+
+ if (!$hasTable) {
+ $table = $schema->createTable(self::TABLE_NAME);
+ $table->addColumn('hash', 'string', [
+ 'notnull' => true,
+ 'length' => 128,
+ ]);
+ $table->addColumn('delete_after', 'datetime', [
+ 'notnull' => true,
+ ]);
+ $table->addIndex(['hash'], 'ratelimit_hash');
+ $table->addIndex(['delete_after'], 'ratelimit_delete_after');
+ return $schema;
+ }
+
+ return null;
+ }
+}