-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: #138 use dird to get the real ip of end-users
- Loading branch information
1 parent
524aaf9
commit 6ca2ccc
Showing
11 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/Events/NodeTasks/UpdateDirdConfig/UpdateDirdConfigCompleted.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTasks\UpdateDirdConfig; | ||
|
||
use App\Events\NodeTasks\BaseTaskEvent; | ||
|
||
class UpdateDirdConfigCompleted extends BaseTaskEvent {} |
7 changes: 7 additions & 0 deletions
7
app/Events/NodeTasks/UpdateDirdConfig/UpdateDirdConfigFailed.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTasks\UpdateDirdConfig; | ||
|
||
use App\Events\NodeTasks\BaseTaskEvent; | ||
|
||
class UpdateDirdConfigFailed extends BaseTaskEvent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/Models/NodeTasks/UpdateDirdConfig/UpdateDirdConfigMeta.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Models\NodeTasks\UpdateDirdConfig; | ||
|
||
use App\Models\NodeTasks\AbstractTaskMeta; | ||
|
||
class UpdateDirdConfigMeta extends AbstractTaskMeta | ||
{ | ||
public function __construct( | ||
public array $nodeAddresses, | ||
public array $dockerServices, | ||
public array $nodePorts, | ||
) {} | ||
|
||
public function formattedHtml(): string | ||
{ | ||
return 'Update DIRD Config'; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/Models/NodeTasks/UpdateDirdConfig/UpdateDirdConfigResult.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Models\NodeTasks\UpdateDirdConfig; | ||
|
||
use App\Models\NodeTasks\AbstractTaskResult; | ||
|
||
class UpdateDirdConfigResult extends AbstractTaskResult | ||
{ | ||
public function __construct( | ||
) { | ||
// | ||
} | ||
|
||
public function formattedHtml(): string | ||
{ | ||
return 'Success.'; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/Models/NodeTasks/UpdateDirdConfiguration/UpdateDirdConfigurationMeta.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace App\Models\NodeTasks\UpdateDirdConfiguration; | ||
|
||
use App\Models\NodeTasks\AbstractTaskMeta; | ||
|
||
class UpdateDirdConfigurationMeta extends AbstractTaskMeta | ||
{ | ||
public function __construct( | ||
public array $nodeAddresses, | ||
public array $dockerServices, | ||
public array $nodePorts, | ||
) { | ||
// | ||
} | ||
|
||
public function formattedHtml(): string | ||
{ | ||
return 'Update DIRD Configuration'; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/Models/NodeTasks/UpdateDirdConfiguration/UpdateDirdConfigurationResult.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Models\NodeTasks\UpdateDirdConfiguration; | ||
|
||
use App\Models\NodeTasks\AbstractTaskResult; | ||
|
||
class UpdateDirdConfigurationResult extends AbstractTaskResult | ||
{ | ||
public function __construct( | ||
) { | ||
// | ||
} | ||
|
||
public function formattedHtml(): string | ||
{ | ||
return 'Success.'; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
database/migrations/2024_08_25_130825_update_node_data_address.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class UpdateNodeDataAddress extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
DB::statement(" | ||
UPDATE nodes | ||
SET data = data || '{\"address\": \"10.0.0.2\"}'::jsonb | ||
WHERE (data->>'address') IS NULL OR (data->>'address') = '' | ||
"); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
DB::statement(" | ||
UPDATE nodes | ||
SET data = data - 'address' | ||
WHERE data ? 'address' | ||
"); | ||
} | ||
} |