Move Domain_Controller::NUMBER_MAX to Address::ADDRESS_FIELD_MAX
This commit is contained in:
parent
77df5746be
commit
1e08c2f6f7
@ -7,7 +7,6 @@ use Illuminate\Support\Str;
|
|||||||
|
|
||||||
use App\Classes\Protocol as BaseProtocol;
|
use App\Classes\Protocol as BaseProtocol;
|
||||||
use App\Classes\Sock\SocketClient;
|
use App\Classes\Sock\SocketClient;
|
||||||
use App\Http\Controllers\DomainController;
|
|
||||||
use App\Models\{Address,Domain,Mailer};
|
use App\Models\{Address,Domain,Mailer};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -328,7 +327,7 @@ final class DNS extends BaseProtocol
|
|||||||
{
|
{
|
||||||
$m = [];
|
$m = [];
|
||||||
|
|
||||||
return (preg_match('/^'.$prefix.'([0-9]+)+/',$label,$m) && ($m[1] <= DomainController::NUMBER_MAX))
|
return (preg_match('/^'.$prefix.'([0-9]+)+/',$label,$m) && ($m[1] <= Address::ADDRESS_FIELD_MAX))
|
||||||
? $m[1]
|
? $m[1]
|
||||||
: NULL;
|
: NULL;
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,6 @@ use App\Models\{Address,Domain,Zone};
|
|||||||
|
|
||||||
class DomainController extends Controller
|
class DomainController extends Controller
|
||||||
{
|
{
|
||||||
// http://ftsc.org/docs/frl-1002.001
|
|
||||||
public const NUMBER_MAX = 0x7fff;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or edit a domain
|
* Add or edit a domain
|
||||||
*/
|
*/
|
||||||
|
@ -242,8 +242,8 @@ class SystemController extends Controller
|
|||||||
'point_id' => [
|
'point_id' => [
|
||||||
'required',
|
'required',
|
||||||
function($attribute,$value,$fail) use ($request) {
|
function($attribute,$value,$fail) use ($request) {
|
||||||
if (! is_numeric($value) || $value > DomainController::NUMBER_MAX)
|
if (! is_numeric($value) || $value > Address::ADDRESS_FIELD_MAX)
|
||||||
$fail(sprintf('Point numbers must be between 0 and %d',DomainController::NUMBER_MAX));
|
$fail(sprintf('Point numbers must be between 0 and %d',Address::ADDRESS_FIELD_MAX));
|
||||||
|
|
||||||
// Check that the host doesnt already exist
|
// Check that the host doesnt already exist
|
||||||
$o = Address::where(function($query) use ($request,$value) {
|
$o = Address::where(function($query) use ($request,$value) {
|
||||||
|
@ -12,7 +12,6 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
use App\Classes\FTN\{Message,Packet};
|
use App\Classes\FTN\{Message,Packet};
|
||||||
use App\Exceptions\InvalidFTNException;
|
use App\Exceptions\InvalidFTNException;
|
||||||
use App\Http\Controllers\DomainController;
|
|
||||||
use App\Traits\ScopeActive;
|
use App\Traits\ScopeActive;
|
||||||
|
|
||||||
class Address extends Model
|
class Address extends Model
|
||||||
@ -38,6 +37,9 @@ class Address extends Model
|
|||||||
public const NODE_UNKNOWN = 1<<15; // Unknown
|
public const NODE_UNKNOWN = 1<<15; // Unknown
|
||||||
public const NODE_ALL = 0xFFF; // Mask to catch all nodes
|
public const NODE_ALL = 0xFFF; // Mask to catch all nodes
|
||||||
|
|
||||||
|
// http://ftsc.org/docs/frl-1002.001
|
||||||
|
public const ADDRESS_FIELD_MAX = 0x7fff; // Maximum value for a field in the address
|
||||||
|
|
||||||
public static function boot()
|
public static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
@ -968,10 +970,10 @@ class Address extends Model
|
|||||||
|
|
||||||
// Check our numbers are correct.
|
// Check our numbers are correct.
|
||||||
foreach ([1,2,3] as $i)
|
foreach ([1,2,3] as $i)
|
||||||
if ((! is_numeric($matches[$i])) || ($matches[$i] > DomainController::NUMBER_MAX))
|
if ((! is_numeric($matches[$i])) || ($matches[$i] > self::ADDRESS_FIELD_MAX))
|
||||||
throw new InvalidFTNException(sprintf('Invalid FTN: [%s] - zone, host, or node address invalid [%d]',$ftn,$matches[$i]));
|
throw new InvalidFTNException(sprintf('Invalid FTN: [%s] - zone, host, or node address invalid [%d]',$ftn,$matches[$i]));
|
||||||
|
|
||||||
if ((! empty($matches[4])) AND ((! is_numeric($matches[$i])) || ($matches[4] > DomainController::NUMBER_MAX)))
|
if ((! empty($matches[4])) AND ((! is_numeric($matches[$i])) || ($matches[4] > self::ADDRESS_FIELD_MAX)))
|
||||||
throw new InvalidFTNException(sprintf('Invalid FTN: [%s] - point address invalid [%d]',$ftn,$matches[4]));
|
throw new InvalidFTNException(sprintf('Invalid FTN: [%s] - point address invalid [%d]',$ftn,$matches[4]));
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -4,13 +4,13 @@ namespace App\Rules;
|
|||||||
|
|
||||||
use Illuminate\Contracts\Validation\Rule;
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
|
|
||||||
use App\Http\Controllers\DomainController;
|
use App\Models\Address;
|
||||||
|
|
||||||
class FidoInteger implements Rule
|
class FidoInteger implements Rule
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Determine if the validation rule passes.
|
* Determine if the validation rule passes.
|
||||||
* This will check that a number used for zone, net, host is between 1 and DomainController::NUMBER_MAX.
|
* This will check that a number used for zone, net, host is between 1 and Address::ADDRESS_FIELD_MAX.
|
||||||
*
|
*
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
@ -18,7 +18,7 @@ class FidoInteger implements Rule
|
|||||||
*/
|
*/
|
||||||
public function passes($attribute,$value)
|
public function passes($attribute,$value)
|
||||||
{
|
{
|
||||||
return (is_numeric($value) && ($value >= 0) && ($value < DomainController::NUMBER_MAX));
|
return (is_numeric($value) && ($value >= 0) && ($value < Address::ADDRESS_FIELD_MAX));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,6 +28,6 @@ class FidoInteger implements Rule
|
|||||||
*/
|
*/
|
||||||
public function message()
|
public function message()
|
||||||
{
|
{
|
||||||
return sprintf('The number must be between 0 and %d.',DomainController::NUMBER_MAX);
|
return sprintf('The number must be between 0 and %d.',Address::ADDRESS_FIELD_MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,13 +4,13 @@ namespace App\Rules;
|
|||||||
|
|
||||||
use Illuminate\Contracts\Validation\Rule;
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
|
|
||||||
use App\Http\Controllers\DomainController;
|
use App\Models\Address;
|
||||||
|
|
||||||
class TwoByteInteger implements Rule
|
class TwoByteInteger implements Rule
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Determine if the validation rule passes.
|
* Determine if the validation rule passes.
|
||||||
* This will check that a number used for zone, net, host is between 1 and DomainController::NUMBER_MAX.
|
* This will check that a number used for zone, net, host is between 1 and Address::ADDRESS_FIELD_MAX.
|
||||||
*
|
*
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
@ -18,7 +18,7 @@ class TwoByteInteger implements Rule
|
|||||||
*/
|
*/
|
||||||
public function passes($attribute,$value)
|
public function passes($attribute,$value)
|
||||||
{
|
{
|
||||||
return (is_numeric($value) && ($value > 0) && ($value < DomainController::NUMBER_MAX));
|
return (is_numeric($value) && ($value > 0) && ($value < Address::ADDRESS_FIELD_MAX));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,6 +28,6 @@ class TwoByteInteger implements Rule
|
|||||||
*/
|
*/
|
||||||
public function message()
|
public function message()
|
||||||
{
|
{
|
||||||
return sprintf('The number must be between 1 and %d.',DomainController::NUMBER_MAX);
|
return sprintf('The number must be between 1 and %d.',Address::ADDRESS_FIELD_MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,13 +4,13 @@ namespace App\Rules;
|
|||||||
|
|
||||||
use Illuminate\Contracts\Validation\Rule;
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
|
|
||||||
use App\Http\Controllers\DomainController;
|
use App\Models\Address;
|
||||||
|
|
||||||
class TwoByteIntegerWithZero implements Rule
|
class TwoByteIntegerWithZero implements Rule
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Determine if the validation rule passes.
|
* Determine if the validation rule passes.
|
||||||
* This will check that a number used for zone, net, host is between 1 and DomainController::NUMBER_MAX.
|
* This will check that a number used for zone, net, host is between 1 and Address::ADDRESS_FIELD_MAX.
|
||||||
*
|
*
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
@ -18,7 +18,7 @@ class TwoByteIntegerWithZero implements Rule
|
|||||||
*/
|
*/
|
||||||
public function passes($attribute,$value)
|
public function passes($attribute,$value)
|
||||||
{
|
{
|
||||||
return (is_numeric($value) && ($value >= 0) && ($value < DomainController::NUMBER_MAX));
|
return (is_numeric($value) && ($value >= 0) && ($value < Address::ADDRESS_FIELD_MAX));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,6 +28,6 @@ class TwoByteIntegerWithZero implements Rule
|
|||||||
*/
|
*/
|
||||||
public function message()
|
public function message()
|
||||||
{
|
{
|
||||||
return sprintf('The number must be between 1 and %d.',DomainController::NUMBER_MAX);
|
return sprintf('The number must be between 1 and %d.',Address::ADDRESS_FIELD_MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,6 @@ namespace App\Traits;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
use App\Http\Controllers\DomainController;
|
|
||||||
use App\Models\{Address,System,Zone};
|
use App\Models\{Address,System,Zone};
|
||||||
|
|
||||||
trait ParseAddresses
|
trait ParseAddresses
|
||||||
@ -37,13 +36,13 @@ trait ParseAddresses
|
|||||||
|
|
||||||
// If domain should be flattened, look for node regardless of zone (within the list of zones for the domain)
|
// If domain should be flattened, look for node regardless of zone (within the list of zones for the domain)
|
||||||
$ao = ($zone->domain->flatten)
|
$ao = ($zone->domain->flatten)
|
||||||
? Address::findZone($zone->domain,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX,0)
|
? Address::findZone($zone->domain,$net&Address::ADDRESS_FIELD_MAX,$node&Address::ADDRESS_FIELD_MAX,0)
|
||||||
: Address::findFTN(sprintf('%d:%d/%d@%s',$zone->zone_id,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX,$zone->domain->name));
|
: Address::findFTN(sprintf('%d:%d/%d@%s',$zone->zone_id,$net&Address::ADDRESS_FIELD_MAX,$node&Address::ADDRESS_FIELD_MAX,$zone->domain->name));
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'seenby':
|
case 'seenby':
|
||||||
if (! $ao)
|
if (! $ao)
|
||||||
$rogue->push(sprintf('%d:%d/%d',$zone->domain->flatten ? 0 : $zone->zone_id,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX));
|
$rogue->push(sprintf('%d:%d/%d',$zone->domain->flatten ? 0 : $zone->zone_id,$net&Address::ADDRESS_FIELD_MAX,$node&Address::ADDRESS_FIELD_MAX));
|
||||||
else
|
else
|
||||||
$nodes->push($ao->id);
|
$nodes->push($ao->id);
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ trait ParseAddresses
|
|||||||
|
|
||||||
case 'path':
|
case 'path':
|
||||||
if (! $ao) {
|
if (! $ao) {
|
||||||
$ftn = sprintf('%d:%d/%d@%s',$zone->zone_id,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX,$zone->domain->name);
|
$ftn = sprintf('%d:%d/%d@%s',$zone->zone_id,$net&Address::ADDRESS_FIELD_MAX,$node&Address::ADDRESS_FIELD_MAX,$zone->domain->name);
|
||||||
|
|
||||||
Log::info(sprintf('%s:- Creating address [%s] for path',self::LOGKEY,$ftn));
|
Log::info(sprintf('%s:- Creating address [%s] for path',self::LOGKEY,$ftn));
|
||||||
$ao = Address::createFTN($ftn,System::createUnknownSystem());
|
$ao = Address::createFTN($ftn,System::createUnknownSystem());
|
||||||
|
Loading…
Reference in New Issue
Block a user