Added ZT to System, more ZT validation on zone

This commit is contained in:
Deon George 2021-06-27 01:15:19 +10:00
parent dfc4e305f1
commit 9897c928d9
4 changed files with 35 additions and 9 deletions

View File

@ -200,9 +200,10 @@ class SystemController extends Controller
'mailer_address' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i', 'mailer_address' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
'mailer_port' => 'nullable|digits_between:2,5', 'mailer_port' => 'nullable|digits_between:2,5',
'active' => 'required|boolean', 'active' => 'required|boolean',
'zt_id' => 'nullable|size:10|regex:/^([A-Fa-f0-9]){10}$/|unique:systems,zt_id,'.($o->exists ? $o->id : 0),
]); ]);
foreach (['name','location','sysop','address','port','active','method','notes','mailer_type','mailer_address','mailer_port'] as $key) foreach (['name','location','sysop','address','port','active','method','notes','mailer_type','mailer_address','mailer_port','zt_id'] as $key)
$o->{$key} = $request->post($key); $o->{$key} = $request->post($key);
$o->save(); $o->save();

View File

@ -35,11 +35,27 @@ class ZoneController extends Controller
}) })
], ],
'system_id' => 'required|exists:systems,id', 'system_id' => 'required|exists:systems,id',
'zt_id' => 'nullable|size:10|regex:/^([A-Fa-f0-9]){10}$/', 'zt_id' => 'nullable|size:16|regex:/^([A-Fa-f0-9]){16}$/|unique:zones,zt_id,'.($o->exists ? $o->id : 0),
'zt_ipv4' => 'nullable|ipv4', 'zt_ipv4' => 'nullable|ipv4',
'zt_ipv4_mask' => 'nullable|numeric|lte:31', 'zt_ipv4_mask' => [
'nullable','numeric','lte:31','required_with:zt_ipv4',
Rule::unique('zones')->where(function ($query) use ($request,$o) {
return $query->where('zt_ipv4',$request->post('zt_ipv4'))
->where('zt_ipv4_mask',$request->post('zt_ipv4_mask'))
->when($o->exists,function($query) use ($o) {
return $query->where('id','<>',$o->id);
});
})],
'zt_ipv6' => 'nullable|ipv6', 'zt_ipv6' => 'nullable|ipv6',
'zt_ipv6_mask' => 'nullable|numeric|lte:112', 'zt_ipv6_mask' => [
'nullable','numeric','lte:112','required_with:zt_ipv6',
Rule::unique('zones')->where(function ($query) use ($request,$o) {
return $query->where('zt_ipv6',$request->post('zt_ipv6'))
->where('zt_ipv6_mask',$request->post('zt_ipv6_mask'))
->when($o->exists,function($query) use ($o) {
return $query->where('id','<>',$o->id);
});
})],
'active' => 'required|boolean', 'active' => 'required|boolean',
]); ]);

View File

@ -60,8 +60,17 @@
</div> </div>
</div> </div>
<div class="col-2"> <div class="col-3">
ZeroTier ID <label for="zt_id" class="form-label">ZeroTier ID</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-shield-lock-fill"></i></span>
<input type="text" class="form-control @error('zt_id') is-invalid @enderror" id="zt_id" placeholder="ZeroTier" name="zt_id" value="{{ old('zt_id',$o->zt_id) }}" @cannot('admin',$o)disabled @endcannot>
<span class="invalid-feedback" role="alert">
@error('zt_id')
{{ $message }}
@enderror
</span>
</div>
</div> </div>
</div> </div>

View File

@ -86,7 +86,7 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-2"> <div class="col-3">
<label for="zt_id" class="form-label">ZeroTier Network ID</label> <label for="zt_id" class="form-label">ZeroTier Network ID</label>
<div class="input-group has-validation"> <div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-shield-lock-fill"></i></span> <span class="input-group-text"><i class="bi bi-shield-lock-fill"></i></span>
@ -117,11 +117,11 @@
</div> </div>
</div> </div>
<div class="col-6"> <div class="col-5">
<label for="zt_ipv6" class="form-label">ZeroTier IPv6 Network</label> <label for="zt_ipv6" class="form-label">ZeroTier IPv6 Network</label>
<div class="input-group has-validation"> <div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-broadcast-pin"></i></span> <span class="input-group-text"><i class="bi bi-broadcast-pin"></i></span>
<input type="text" style="width: 65%;" class="form-control @error('zt_ipv6') is-invalid @enderror" id="zt_ipv6" placeholder="fd00:f1d0:0000:0000:0000:0000:0000:0000" name="zt_ipv6" value="{{ old('zt_ipv6',$o->zt_ipv6) }}" @cannot('admin',$o)disabled @endcannot> <input type="text" style="width: 60%;" class="form-control @error('zt_ipv6') is-invalid @enderror" id="zt_ipv6" placeholder="fd00:f1d0:0000:0000:0000:0000:0000:0000" name="zt_ipv6" value="{{ old('zt_ipv6',$o->zt_ipv6) }}" @cannot('admin',$o)disabled @endcannot>
<span class="input-group-text">/</span> <span class="input-group-text">/</span>
<input type="text" class="form-control @error('zt_ipv6_mask') is-invalid @enderror" id="zt_ipv6_mask" placeholder="112" name="zt_ipv6_mask" value="{{ old('zt_ipv6_mask',$o->zt_ipv6_mask) }}" @cannot('admin',$o)disabled @endcannot> <input type="text" class="form-control @error('zt_ipv6_mask') is-invalid @enderror" id="zt_ipv6_mask" placeholder="112" name="zt_ipv6_mask" value="{{ old('zt_ipv6_mask',$o->zt_ipv6_mask) }}" @cannot('admin',$o)disabled @endcannot>
<span class="invalid-feedback" role="alert"> <span class="invalid-feedback" role="alert">