2023-12-11 07:31:38 +00:00
|
|
|
<?php
|
|
|
|
|
2024-04-21 12:10:12 +00:00
|
|
|
namespace App\Console\Commands\Debug;
|
2023-12-11 07:31:38 +00:00
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
2024-05-09 11:22:30 +00:00
|
|
|
use App\Models\Domain;
|
2024-04-21 12:10:12 +00:00
|
|
|
|
2023-12-11 07:31:38 +00:00
|
|
|
class ZoneCheck extends Command
|
|
|
|
{
|
2024-04-21 12:10:12 +00:00
|
|
|
protected $signature = 'debug:zone:check'
|
2023-12-11 07:31:38 +00:00
|
|
|
.' {domain : Domain Name}'
|
|
|
|
.' {--Z|zone= : Zone}';
|
|
|
|
|
|
|
|
protected $description = 'Check that the addresses in a zone are configured correctly';
|
|
|
|
|
2024-05-27 05:08:39 +00:00
|
|
|
public function handle(): int
|
2023-12-11 07:31:38 +00:00
|
|
|
{
|
2024-11-08 12:31:21 +00:00
|
|
|
$do = Domain::where('name',$this->argument('domain'))->sole();
|
2023-12-11 07:31:38 +00:00
|
|
|
|
2023-12-12 21:41:15 +00:00
|
|
|
foreach ($do->zones->sortby('zone_id') as $zo) {
|
2023-12-11 07:31:38 +00:00
|
|
|
if ($this->option('zone') && ($this->option('zone') != $zo->zone_id))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
$this->warn('Zone: '.$zo->zone_id);
|
2023-12-12 21:41:15 +00:00
|
|
|
$this->info(sprintf('- Our address(es): %s',our_address($do)->pluck('ftn4d')->join(',')));
|
2023-12-11 07:31:38 +00:00
|
|
|
|
2024-11-25 02:46:16 +00:00
|
|
|
$this->table(['id','ftn','role','parent','children','downlinks','uplink','send from','region_id','system','notes'],$zo->addresses()->FTNorder()->active()->with(['system'])->get()->transform(function($item) {
|
2023-12-11 07:31:38 +00:00
|
|
|
return [
|
|
|
|
'id'=>$item->id,
|
|
|
|
'ftn'=>$item->ftn4d,
|
|
|
|
'role'=>$item->role_name,
|
2024-05-09 11:22:30 +00:00
|
|
|
'parent'=>$item->parent()?->ftn4d,
|
|
|
|
'children'=>$item->children()->count(),
|
|
|
|
'downlinks'=>$item->downlinks()->count(),
|
|
|
|
'uplink'=>($x=$item->uplink())?->ftn4d,
|
|
|
|
'send from'=>$x ? our_address($item->uplink())?->ftn4d : '',
|
2023-12-11 07:31:38 +00:00
|
|
|
'region_id'=>$item->region_id,
|
|
|
|
'system'=>$item->system->name,
|
2024-05-09 11:22:30 +00:00
|
|
|
'notes'=>$item->isRoleOverride() ? 'Role Override' : '',
|
2023-12-11 07:31:38 +00:00
|
|
|
];
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2024-05-27 05:08:39 +00:00
|
|
|
return self::SUCCESS;
|
2023-12-11 07:31:38 +00:00
|
|
|
}
|
|
|
|
}
|