More complete rework of packet parsing and packet generation with f279d85
- and testing passes
This commit is contained in:
@@ -154,7 +154,7 @@ class Address extends Model
|
||||
$o = new self;
|
||||
$o->active = TRUE;
|
||||
$o->zone_id = $zo->id;
|
||||
$o->region_id = 0; // @todo Automatically determine region
|
||||
$o->region_id = $ftn['r'];
|
||||
$o->host_id = $ftn['n'];
|
||||
$o->node_id = $ftn['f'];
|
||||
$o->point_id = $ftn['p'];
|
||||
@@ -307,8 +307,39 @@ class Address extends Model
|
||||
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]));
|
||||
|
||||
// Work out region
|
||||
$region_id = 0;
|
||||
$zone_id = NULL;
|
||||
|
||||
// We can only work out region if we have a domain
|
||||
if ($matches[5] ?? NULL) {
|
||||
$o = new self;
|
||||
$o->host_id = $matches[2];
|
||||
$o->node_id = $matches[3];
|
||||
$o->point_id = empty($matches[4]) ? 0 : (int)$matches[4];
|
||||
|
||||
$zo = Zone::select('zones.*')->where('zone_id',$matches[1])->join('domains',['domains.id'=>'zones.domain_id'])->where('domains.name',$matches[5])->single();
|
||||
$o->zone_id = $zo?->id;
|
||||
$parent = $o->parent();
|
||||
$zone_id = $parent?->zone->zone_id;
|
||||
|
||||
// For flattened domains
|
||||
if ($zo->domain->flatten && is_null($zone_id))
|
||||
foreach ($zo->domain->zones as $zoo) {
|
||||
$o->zone_id = $zoo->id;
|
||||
$parent = $o->parent();
|
||||
|
||||
if ($parent)
|
||||
break;
|
||||
}
|
||||
|
||||
$region_id = $parent?->region_id;
|
||||
$zone_id = $parent?->zone->zone_id;
|
||||
}
|
||||
|
||||
return [
|
||||
'z'=>(int)$matches[1],
|
||||
'z'=>(int)$zone_id ?: $matches[1],
|
||||
'r'=>(int)$region_id,
|
||||
'n'=>(int)$matches[2],
|
||||
'f'=>(int)$matches[3],
|
||||
'p'=>empty($matches[4]) ? 0 : (int)$matches[4],
|
||||
|
@@ -59,6 +59,7 @@ final class Echomail extends Model implements Packet
|
||||
$this->{$key} = $value;
|
||||
break;
|
||||
|
||||
case 'set_fftn':
|
||||
// Values that we pass to boot() to record how we got this echomail
|
||||
case 'set_pkt':
|
||||
case 'set_recvtime':
|
||||
|
@@ -55,6 +55,8 @@ final class Netmail extends Model implements Packet
|
||||
|
||||
break;
|
||||
|
||||
case 'set_fftn':
|
||||
case 'set_tftn':
|
||||
// Values that we pass to boot() to record how we got this netmail
|
||||
case 'set_pkt':
|
||||
case 'set_recvtime':
|
||||
|
Reference in New Issue
Block a user