From 7ce31c77c5c588d6eeda78bc5124579b5a8b3d7d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 14 Jun 2023 08:57:17 +0200 Subject: [PATCH] updates --- ...20_112814_create_instance_settings_table.php | 3 ++- database/seeders/ProductionSeeder.php | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/database/migrations/2023_03_20_112814_create_instance_settings_table.php b/database/migrations/2023_03_20_112814_create_instance_settings_table.php index 8d30c2b2c..c0fc8a6fb 100644 --- a/database/migrations/2023_03_20_112814_create_instance_settings_table.php +++ b/database/migrations/2023_03_20_112814_create_instance_settings_table.php @@ -13,7 +13,8 @@ return new class extends Migration { Schema::create('instance_settings', function (Blueprint $table) { $table->id(); - $table->string('public_ip_address')->nullable(); + $table->string('public_ipv4')->nullable(); + $table->string('public_ipv6')->nullable(); $table->string('fqdn')->nullable(); $table->string('wildcard_domain')->nullable(); $table->string('default_redirect_404')->nullable(); diff --git a/database/seeders/ProductionSeeder.php b/database/seeders/ProductionSeeder.php index 50aa2fefa..4e4bfaf8c 100644 --- a/database/seeders/ProductionSeeder.php +++ b/database/seeders/ProductionSeeder.php @@ -107,12 +107,19 @@ class ProductionSeeder extends Seeder ]); } try { - $ip = Process::run('curl -4s https://ifconfig.io')->output; - $ip = trim($ip); - $ip = filter_var($ip, FILTER_VALIDATE_IP); + $ipv4 = Process::run('curl -4s https://ifconfig.io')->output; + $ipv4 = trim($ipv4); + $ipv4 = filter_var($ipv4, FILTER_VALIDATE_IP); $settings = InstanceSettings::get(); - if ($settings->public_ip_address !== $ip) { - $settings->update(['public_ip_address' => $ip]); + if (is_null($settings->public_ipv4)) { + $settings->update(['public_ipv4' => $ipv4]); + } + $ipv6 = Process::run('curl -6s https://ifconfig.io')->output; + $ipv6 = trim($ipv6); + $ipv6 = filter_var($ipv6, FILTER_VALIDATE_IP); + $settings = InstanceSettings::get(); + if (is_null($settings->public_ipv6)) { + $settings->update(['public_ipv6' => $ipv6]); } } catch (\Exception $e) { echo "Error: {$e->getMessage()}\n";