Mail routing parent/children, domain name validation, nodelist import changes and other fixes

This commit is contained in:
Deon George
2021-07-26 21:21:58 +10:00
parent 49bc946024
commit b179b1b3e9
15 changed files with 537 additions and 171 deletions

View File

@@ -14,9 +14,10 @@ class DomainController extends Controller
public const NODE_RC = 1<<1; // Region
public const NODE_NC = 1<<2; // Host
public const NODE_HC = 1<<3; // Hub
public const NODE_PVT = 1<<4; // Pvt
public const NODE_HOLD = 1<<5; // Hold
public const NODE_DOWN = 1<<6; // Down
public const NODE_POINT = 1<<4; // Point
public const NODE_PVT = 1<<5; // Pvt
public const NODE_HOLD = 1<<6; // Hold
public const NODE_DOWN = 1<<7; // Down
// http://ftsc.org/docs/frl-1002.001
public const NUMBER_MAX = 0x7fff;
@@ -27,7 +28,7 @@ class DomainController extends Controller
}
/**
* Add or edit a node
* Add or edit a domain
*/
public function add_edit(Request $request,Domain $o)
{
@@ -35,7 +36,8 @@ class DomainController extends Controller
$this->authorize('admin',$o);
$request->validate([
'name' => 'required|max:8|unique:domains,name,'.($o->exists ? $o->id : 0),
// http://ftsc.org/docs/old/fsp-1028.002
'name' => 'required|max:8|regex:/^[a-z-_~]{1,8}$/|unique:domains,name,'.($o->exists ? $o->id : 0),
'dnsdomain' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i|unique:domains,dnsdomain,'.($o->exists ? $o->id : NULL),
'active' => 'required|boolean',
'public' => 'required|boolean',

View File

@@ -121,6 +121,32 @@ class SystemController extends Controller
]
]);
// Find the Hub address
// Find the zones <HOST>/0 address, and assign it to this host.
$oo = Address::where('zone_id',$request->zone_id)
->where('region_id',$request->region_id)
->where('host_id',$request->host_id_new)
->where('node_id',0)
->where('point_id',0)
->single();
// Its not defined, so we'll create it.
if (! $oo) {
$oo = new Address;
$oo->forceFill([
'zone_id'=>$request->zone_id,
'region_id'=>$request->region_id,
'host_id'=>$request->host_id_new,
'node_id'=>0,
'point_id'=>0,
'role'=>DomainController::NODE_NC,
]);
}
$oo->system_id = $request->system_id;
$oo->active = TRUE;
$o->addresses()->save($oo);
$oo = new Address;
$oo->zone_id = $request->post('zone_id');
$oo->region_id = $request->post('region_id');
@@ -200,8 +226,8 @@ class SystemController extends Controller
$validate = $request->validate([
'zone_id' => 'required|exists:zones,id',
'sespass' => 'required|string|min:4',
'pktpass' => 'required|string|min:4|max:8',
'ticpass' => 'required|string|min:4',
'pktpass' => 'nullable|string|min:4|max:8',
'ticpass' => 'nullable|string|min:4',
'fixpass' => 'required|string|min:4',
]);
@@ -242,6 +268,8 @@ class SystemController extends Controller
return redirect()->action([self::class,'home']);
}
$o->load(['addresses.zone.domain']);
return view('system.addedit')
->with('o',$o);
}

View File

@@ -5,7 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use App\Models\Zone;
use App\Models\{Address,Zone};
class ZoneController extends Controller
{
@@ -64,6 +64,30 @@ class ZoneController extends Controller
$o->save();
// Find the zones 0/0 address, and assign it to this host.
$ao = Address::where('zone_id',$request->zone_id)
->where('region_id',0)
->where('host_id',0)
->where('node_id',0)
->where('point_id',0)
->single();
// Its not defined, so we'll create it.
if (! $ao) {
$ao = new Address;
$ao->forceFill([
'region_id'=>0,
'host_id'=>0,
'node_id'=>0,
'point_id'=>0,
'role'=>DomainController::NODE_ZC,
]);
}
$ao->system_id = $request->system_id;
$ao->active = TRUE;
$o->addresses()->save($ao);
return redirect()->action([self::class,'home']);
}