peer add ipv6

This commit is contained in:
xiaomlove
2022-04-21 16:14:08 +08:00
parent 541f0eb46f
commit 06cb452fdd
11 changed files with 182 additions and 90 deletions

View File

@@ -36,7 +36,7 @@ class CreatePeersTable extends Migration
$table->unsignedBigInteger('downloadoffset')->default(0);
$table->unsignedBigInteger('uploadoffset')->default(0);
$table->char('passkey', 32)->default('');
$table->unique(['torrent', 'peer_id', 'ip']);
$table->unique(['torrent', 'peer_id']);
});
}

View File

@@ -28,7 +28,7 @@ return new class extends Migration
}
Schema::table($tableName, function (Blueprint $table) {
$table->unique(['torrent', 'peer_id', 'ip']);
$table->unique(['torrent', 'peer_id']);
$table->index('peer_id');
});
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('peers', function (Blueprint $table) {
if (!Schema::hasColumn('peers', 'ipv4')) {
$table->string('ipv4', 64)->default('');
}
if (!Schema::hasColumn('peers', 'ipv6')) {
$table->string('ipv6', 64)->default('');
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('peers', function (Blueprint $table) {
$table->dropColumn(['ipv4', 'ipv6']);
});
}
};