Compare commits
No commits in common. "be1ef4b2930f21fe460194f51068908e18aaf8da" and "90c65fd5e176178336a12a5480721f3b3b485fe1" have entirely different histories.
be1ef4b293
...
90c65fd5e1
@ -93,6 +93,9 @@ class Message extends FTNBase
|
||||
private Echomail|Netmail $mo; // The object storing this packet message
|
||||
private Address $us; // Our address for this message
|
||||
|
||||
/** @deprecated Not sure why this is needed? */
|
||||
public bool $packed = FALSE; // Has the message been packed successfully
|
||||
|
||||
// Convert characters into printable chars
|
||||
// https://int10h.org/oldschool-pc-fonts/readme/#437_charset
|
||||
private const CP437 = [
|
||||
@ -376,6 +379,17 @@ class Message extends FTNBase
|
||||
case 'tftn':
|
||||
return parent::__get($key);
|
||||
|
||||
// For 5D we need to include the domain
|
||||
/* @deprecated - is this required? */
|
||||
case 'fboss':
|
||||
return sprintf('%d:%d/%d',$this->fz,$this->fn,$this->ff).(($x=$this->fdomain) ? '@'.$x->name : '');
|
||||
case 'tboss':
|
||||
return sprintf('%d:%d/%d',$this->tz,$this->tn,$this->tf).(($x=$this->tdomain) ? '@'.$x->name : '');
|
||||
case 'fboss_o':
|
||||
return Address::findFTN($this->fboss);
|
||||
case 'tboss_o':
|
||||
return Address::findFTN($this->tboss);
|
||||
|
||||
// Convert our message (header[datetime]) with our TZUTC into a Carbon date
|
||||
case 'datetime':
|
||||
try {
|
||||
@ -480,6 +494,16 @@ class Message extends FTNBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When we serialise this object, we'll need to utf8_encode some values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function __serialize(): array
|
||||
{
|
||||
return $this->encode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Export an FTN message, ready for sending.
|
||||
*
|
||||
@ -578,6 +602,16 @@ class Message extends FTNBase
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* When we unserialize, we'll restore (utf8_decode) some values
|
||||
*
|
||||
* @param array $values
|
||||
*/
|
||||
public function __unserialize(array $values): void
|
||||
{
|
||||
$this->decode($values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce our PATH/SEEN-BY for messages as per FSC-0068
|
||||
*
|
||||
|
@ -340,6 +340,53 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
|
||||
|
||||
/* METHODS */
|
||||
|
||||
/**
|
||||
* When creating a new packet, set the header.
|
||||
*
|
||||
* @param Address $oo
|
||||
* @param Address $o
|
||||
* @param string|null $passwd Override the password used in the packet
|
||||
* @deprecated Use Packet::generate(), which should generate a packet of the right type
|
||||
*/
|
||||
public function addressHeader(Address $oo,Address $o,string $passwd=NULL): void
|
||||
{
|
||||
Log::debug(sprintf('%s:+ Creating packet for [%s]',self::LOGKEY,$o->ftn));
|
||||
|
||||
$date = Carbon::now();
|
||||
|
||||
// Create Header
|
||||
$this->header = [
|
||||
'ozone' => $oo->zone->zone_id, // Orig Zone
|
||||
'dzone' => $o->zone->zone_id, // Dest Zone
|
||||
'onet' => $oo->host_id ?: $oo->region_id, // Orig Net
|
||||
'dnet' => $o->host_id ?: $o->region_id, // Dest Net
|
||||
'onode' => $oo->node_id, // Orig Node
|
||||
'dnode' => $o->node_id, // Dest Node
|
||||
'opoint' => $oo->point_id, // Orig Point
|
||||
'dpoint' => $o->point_id, // Dest Point
|
||||
'odomain' => $oo->zone->domain->name, // Orig Domain
|
||||
'ddomain' => $o->zone->domain->name, // Dest Domain
|
||||
'y' => $date->format('Y'), // Year
|
||||
'm' => $date->format('m')-1, // Month
|
||||
'd' => $date->format('d'), // Day
|
||||
'H' => $date->format('H'), // Hour
|
||||
'M' => $date->format('i'), // Minute
|
||||
'S' => $date->format('s'), // Second
|
||||
'password' => strtoupper((! is_null($passwd)) ? $passwd : $o->session('pktpass')), // Packet Password
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a message to this packet
|
||||
*
|
||||
* @param Message $o
|
||||
* @deprecated No longer used when Address::class is updated
|
||||
*/
|
||||
public function addMail(Message $o): void
|
||||
{
|
||||
$this->messages->push($o);
|
||||
}
|
||||
|
||||
public function for(Address $ao): self
|
||||
{
|
||||
$this->tftn_p = $ao;
|
||||
@ -458,8 +505,15 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
|
||||
public function password(string $password=NULL): self
|
||||
{
|
||||
if ($password && (strlen($password) < 9))
|
||||
$this->pass_p = strtoupper($password);
|
||||
$this->pass_p = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @deprecated Is this used? */
|
||||
public function pluck(string $key): Collection
|
||||
{
|
||||
throw new \Exception(sprintf('%s:! This function is deprecated - [%s]',self::LOGKEY,$key));
|
||||
return $this->messages->pluck($key);
|
||||
}
|
||||
}
|
@ -82,7 +82,7 @@ final class FSC39 extends Packet
|
||||
$this->tftn_p->host_id, // Dest Net
|
||||
(Setup::PRODUCT_ID & 0xff), // Product Code Lo
|
||||
Setup::PRODUCT_VERSION_MAJ, // Product Version Major
|
||||
$this->pass_p ?: $this->tftn_p->pass_packet, // Packet Password
|
||||
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password
|
||||
$this->fftn_p->zone->zone_id, // Orig Zone
|
||||
$this->tftn_p->zone->zone_id, // Dest Zone
|
||||
'', // Reserved
|
||||
|
@ -69,7 +69,7 @@ final class FSC45 extends Packet
|
||||
$this->tftn_p->host_id, // Dest Net
|
||||
(Setup::PRODUCT_ID & 0xff), // Product Code
|
||||
Setup::PRODUCT_VERSION_MAJ, // Product Version
|
||||
$this->pass_p ?: $this->tftn_p->pass_packet, // Packet Password
|
||||
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password
|
||||
$this->fftn_p->zone->zone_id, // Orig Zone
|
||||
$this->tftn_p->zone->zone_id, // Dest Zone
|
||||
$this->fftn_p->zone->domain->name, // Orig Domain
|
||||
|
@ -82,7 +82,7 @@ final class FSC48 extends Packet
|
||||
$this->tftn_p->host_id, // Dest Net
|
||||
(Setup::PRODUCT_ID & 0xff), // Product Code Lo
|
||||
Setup::PRODUCT_VERSION_MAJ, // Product Version Major
|
||||
$this->pass_p ?: $this->tftn_p->pass_packet, // Packet Password
|
||||
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password
|
||||
$this->fftn_p->zone->zone_id, // Orig Zone
|
||||
$this->tftn_p->zone->zone_id, // Dest Zone
|
||||
$this->fftn_p->point_id ? $this->fftn_p->host_id : 0x00, // Aux Net
|
||||
|
@ -75,7 +75,7 @@ final class FTS1 extends Packet
|
||||
$this->tftn_p->host_id, // Dest Net
|
||||
(Setup::PRODUCT_ID & 0xff), // Product Code Lo
|
||||
Setup::PRODUCT_VERSION_MAJ, // Product Version Major
|
||||
$this->pass_p ?: $this->tftn_p->pass_packet, // Packet Password
|
||||
$this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password
|
||||
$this->fftn_p->zone->zone_id, // Orig Zone
|
||||
$this->tftn_p->zone->zone_id, // Dest Zone
|
||||
'', // Reserved
|
||||
|
@ -106,7 +106,7 @@ class Tic extends FTNBase
|
||||
$result->put('REPLACES',$this->file->replaces);
|
||||
$result->put('AREA',$this->file->filearea->name);
|
||||
$result->put('AREADESC',$this->file->filearea->description);
|
||||
if ($x=$this->to->pass_tic)
|
||||
if ($x=strtoupper($this->to->session('ticpass')))
|
||||
$result->put('PW',$x);
|
||||
$result->put('CRC',sprintf("%X",$this->file->crc));
|
||||
|
||||
@ -351,7 +351,7 @@ class Tic extends FTNBase
|
||||
throw new SizeMismatchException(sprintf('TIC file size [%d] doesnt match file [%s] (%d)',$this->file->size,$fs->path($rel_path_name),$y));
|
||||
|
||||
// Validate Password
|
||||
if (strtoupper($pw) !== ($y=$this->file->fftn->pass_tic))
|
||||
if (strtoupper($pw) !== ($y=strtoupper($this->file->fftn->session('ticpass'))))
|
||||
throw new InvalidPasswordException(sprintf('TIC file PASSWORD [%s] doesnt match system [%s] (%s)',$pw,$this->file->fftn->ftn,$y));
|
||||
|
||||
// Validate Sender is linked
|
||||
|
@ -86,9 +86,9 @@ class Node
|
||||
case 'password':
|
||||
// If we have already authed, we'll use that password.
|
||||
if ($this->ftns_authed->count())
|
||||
return $this->ftns_authed->first()->pass_session;
|
||||
return $this->ftns_authed->first()->session('sespass');
|
||||
else
|
||||
return ($this->ftns->count() && ($x=$this->ftns->first()->pass_session)) ? $x : '-';
|
||||
return ($this->ftns->count() && ($x=$this->ftns->first()->session('sespass'))) ? $x : '-';
|
||||
|
||||
// Return how long our session has been connected
|
||||
case 'session_time':
|
||||
@ -194,7 +194,7 @@ class Node
|
||||
throw new Exception('Already authed');
|
||||
|
||||
foreach ($this->ftns as $o) {
|
||||
if (! $sespass=$o->pass_session)
|
||||
if (! $sespass=$o->session('sespass'))
|
||||
continue;
|
||||
|
||||
// If we have challenge, then we are doing MD5
|
||||
|
@ -1540,6 +1540,25 @@ final class Binkp extends BaseProtocol
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip blanks at the beginning of a string
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
* @deprecated - use ltrim instead
|
||||
*/
|
||||
private function skip_blanks(string $str): string
|
||||
{
|
||||
$c = 0;
|
||||
|
||||
if ($str != NULL)
|
||||
while ($this->isSpace(substr($str,$c,1)))
|
||||
$c++;
|
||||
|
||||
return substr($str,$c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string delimited by char and shorten the input to the remaining characters
|
||||
*
|
||||
@ -1560,4 +1579,20 @@ final class Binkp extends BaseProtocol
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the string is a space
|
||||
*
|
||||
* @param string $str
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @deprecated No longer required since we are using ltrim
|
||||
*/
|
||||
private function isSpace(string $str):bool
|
||||
{
|
||||
if (strlen($str) > 1)
|
||||
throw new \Exception('String is more than 1 char');
|
||||
|
||||
return $str && in_array($str,[' ',"\n","\r","\v","\f","\t"]);
|
||||
}
|
||||
}
|
@ -36,15 +36,22 @@ class NodelistImport extends Command
|
||||
*/
|
||||
public function handle():int
|
||||
{
|
||||
return Job::dispatchSync(
|
||||
is_numeric($x=$this->argument('file'))
|
||||
? File::findOrFail($x)
|
||||
: sprintf('%s/%s',config('fido.dir'),$this->argument('file')),
|
||||
$this->argument('domain'),
|
||||
$this->option('delete'),
|
||||
$this->option('unlink'),
|
||||
$this->option('test'),
|
||||
$this->option('ignorecrc'),
|
||||
);
|
||||
try {
|
||||
return Job::dispatchSync(
|
||||
is_numeric($x=$this->argument('file'))
|
||||
? File::findOrFail($x)
|
||||
: sprintf('%s/%s',config('fido.dir'),$this->argument('file')),
|
||||
$this->argument('domain'),
|
||||
$this->option('delete'),
|
||||
$this->option('unlink'),
|
||||
$this->option('test'),
|
||||
$this->option('ignorecrc'),
|
||||
);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
@ -575,7 +575,7 @@ class SystemController extends Controller
|
||||
session()->flash('accordion','filearea');
|
||||
|
||||
// Ensure we have session details for this address.
|
||||
if (! $ao->pass_session)
|
||||
if (! $ao->session('sespass'))
|
||||
return redirect()->back()->withErrors('System doesnt belong to this network');
|
||||
|
||||
$ao->fileareas()->syncWithPivotValues($request->get('id',[]),['subscribed'=>Carbon::now()]);
|
||||
|
@ -10,10 +10,12 @@ use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Models\{Domain,Echoarea};
|
||||
use App\Traits\Import as ImportTrait;
|
||||
|
||||
class EchoareaImport implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use ImportTrait;
|
||||
|
||||
protected const LOGKEY = 'JEI';
|
||||
private const importkey = 'echoarea';
|
||||
@ -100,4 +102,4 @@ class EchoareaImport implements ShouldQueue
|
||||
|
||||
Log::info(sprintf('%s:= Updated %d records',self::LOGKEY,$p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,12 @@ use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Models\{Domain,Filearea};
|
||||
use App\Traits\Import as ImportTrait;
|
||||
|
||||
class FileareaImport implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use ImportTrait;
|
||||
|
||||
protected const LOGKEY = 'JFI';
|
||||
private const importkey = 'filearea';
|
||||
@ -100,4 +102,4 @@ class FileareaImport implements ShouldQueue
|
||||
|
||||
Log::info(sprintf('%s:= Updated %d records',self::LOGKEY,$p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,13 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use App\Models\{Address,Domain,File,Mailer,Nodelist,System,Zone};
|
||||
use App\Models\{Address,Domain,File,Mailer,Nodelist,Setup,System,SystemZone,User,Zone};
|
||||
use App\Traits\Import as ImportTrait;
|
||||
|
||||
class NodelistImport implements ShouldQueue
|
||||
{
|
||||
use Dispatchable,InteractsWithQueue,Queueable,SerializesModels,ImportTrait;
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use ImportTrait;
|
||||
|
||||
protected const LOGKEY = 'JNI';
|
||||
private const importkey = 'nodelist';
|
||||
@ -33,11 +34,7 @@ class NodelistImport implements ShouldQueue
|
||||
private bool $ignore_crc;
|
||||
|
||||
/**
|
||||
* Import Nodelist from a file.
|
||||
*
|
||||
* A nodelist is treated as authoritative (it will add/update/delete details of existing entries), except where:
|
||||
* + The system has a user owner (the user provides the authoritative information)
|
||||
* + The system is a node of this instance (the admin provides the authoritative information)
|
||||
* Import Nodelist constructor.
|
||||
*
|
||||
* @param File|string $file
|
||||
* @param string|null $domain
|
||||
@ -77,30 +74,35 @@ class NodelistImport implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$our_systems = SystemZone::select('system_id')
|
||||
->get()
|
||||
->pluck('system')
|
||||
->flatten()
|
||||
->pluck('addresses')
|
||||
->flatten()
|
||||
->filter(function($item) { return $item->active; })
|
||||
->pluck('id');
|
||||
|
||||
$our_users = User::with(['systems.addresses'])
|
||||
->get()
|
||||
->pluck('systems')
|
||||
->flatten()
|
||||
->pluck('addresses')
|
||||
->flatten()
|
||||
->filter(function($item) { return $item->active; })
|
||||
->pluck('id')
|
||||
->diff($our_systems);
|
||||
|
||||
$our_addresses = our_address()->pluck('id');
|
||||
|
||||
// Get the file from the host
|
||||
$file = $this->getFileFromHost(self::importkey,$this->file);
|
||||
Log::debug(sprintf('%s:+ Loading file [%s].',static::LOGKEY,$file));
|
||||
$z = $this->openFile($file);
|
||||
|
||||
$c = 0;
|
||||
$fh = NULL;
|
||||
while ($c < $z->count()) {
|
||||
// Nodelist files have an extension of numbers, between 1-365
|
||||
if (preg_match('/^.+\.[0-3][0-9][0-9]$/',$z->getNameIndex($c))) {
|
||||
$fh = $z->getStreamIndex($c);
|
||||
break;
|
||||
}
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
if (is_null($fh))
|
||||
throw new \Exception('Couldnt find nodelist in file');
|
||||
|
||||
$lines = $this->getFileLines($fh);
|
||||
Log::debug(sprintf('%s:+ Loading file [%s] (%s).',static::LOGKEY,$file,getcwd()));
|
||||
$lines = $this->getFileLines($file);
|
||||
Log::debug(sprintf('%s:- Processing [%d] lines.',static::LOGKEY,$lines));
|
||||
// Rewind
|
||||
$fh = $z->getStreamIndex($c);
|
||||
|
||||
$fh = NULL;
|
||||
$z = $this->openFile($file,$fh);
|
||||
|
||||
// Line 1 tells us the nodelist and the CRC
|
||||
$line = stream_get_line($fh,0,"\r\n");
|
||||
@ -123,53 +125,49 @@ class NodelistImport implements ShouldQueue
|
||||
|
||||
$date = Carbon::createFromFormat('D, M d, Y H:i',$matches[2].'0:00');
|
||||
|
||||
if ($date->dayOfYear !== (int)$matches[3]) {
|
||||
if ($date->dayOfYear != $matches[3]) {
|
||||
Log::error(sprintf('%s:! Nodelist date doesnt match [%d] (%d:%s).',static::LOGKEY,$matches[3],$date->dayOfYear,$date->format('Y-m-d')));
|
||||
|
||||
throw new \Exception('Nodelist date doesnt match for file: '.$this->file->id);
|
||||
}
|
||||
|
||||
Log::info(sprintf('%s:- Importing nodelist for [%s] dated [%s].',static::LOGKEY,$do->name,$date->format('Y-m-d')));
|
||||
Log::alert(sprintf('%s:- Importing nodelist for [%s] dated [%s].',static::LOGKEY,$do->name,$date->format('Y-m-d')));
|
||||
|
||||
// We'll only commit this if there were no errors
|
||||
DB::beginTransaction();
|
||||
$no = Nodelist::firstOrCreate(['date'=>$date,'domain_id'=>$do->id]);
|
||||
|
||||
if ($this->delete_recs)
|
||||
$no->addresses()->detach();
|
||||
|
||||
elseif ($no->addresses->count()) {
|
||||
Log::error(sprintf('%s:! Nodelist [%s] for [%s] has existing records [%d]',self::LOGKEY,$date,$do->name,$no->addresses->count()));
|
||||
Log::error($x=sprintf('%s:! Nodelist [%s] for [%s] has existing records [%d]',self::LOGKEY,$date,$do->name,$no->addresses->count()));
|
||||
|
||||
return;
|
||||
throw new \Exception($x);
|
||||
}
|
||||
|
||||
$mailer_binkp = Mailer::where('name','BINKP')->singleOrFail();
|
||||
$mailer_emsi = Mailer::where('name','EMSI')->singleOrFail();
|
||||
|
||||
$p = $c = 0;
|
||||
|
||||
$region = NULL;
|
||||
$host = NULL;
|
||||
$ishub = FALSE;
|
||||
$hub_id = NULL;
|
||||
$zo = NULL;
|
||||
$ho = NULL;
|
||||
$crc_check = '';
|
||||
$tocrc = '';
|
||||
$mailer_binkp = Mailer::where('name','BINKP')->singleOrFail();
|
||||
$mailer_emsi = Mailer::where('name','EMSI')->singleOrFail();
|
||||
|
||||
while (! feof($fh)) {
|
||||
$line = stream_get_line($fh,0,"\r\n");
|
||||
$crc_check .= $line."\r\n";
|
||||
$tocrc .= $line."\r\n";
|
||||
|
||||
// Lines beginning with a semicolon(;) are comments
|
||||
if ((! $line) OR preg_match('/^;/',$line) OR ($line === chr(0x1a)))
|
||||
continue;
|
||||
|
||||
// Remove any embedded CR and UTF-8 BOM
|
||||
// Remove any embedded CR and BOM
|
||||
$line = str_replace("\r",'',$line);
|
||||
$line = preg_replace('/^\x{feff}/u','',$line);
|
||||
$c++;
|
||||
|
||||
Log::debug(sprintf('%s:| %s',self::LOGKEY,$line));
|
||||
Log::debug(sprintf('%s:%s',self::LOGKEY,$line));
|
||||
|
||||
$fields = str_getcsv(trim($line));
|
||||
|
||||
@ -184,9 +182,10 @@ class NodelistImport implements ShouldQueue
|
||||
|
||||
switch ($fields[0]) {
|
||||
case 'Zone':
|
||||
$zone = (int)$fields[1];
|
||||
Zone::unguard();
|
||||
$zo = Zone::firstOrNew([
|
||||
'zone_id'=>(int)$fields[1],
|
||||
'zone_id'=>$zone,
|
||||
'domain_id'=>$do->id,
|
||||
'active'=>TRUE,
|
||||
]);
|
||||
@ -194,30 +193,26 @@ class NodelistImport implements ShouldQueue
|
||||
|
||||
$region = 0;
|
||||
$host = 0;
|
||||
$ishub = FALSE;
|
||||
$ho = NULL;
|
||||
$hub_id = NULL;
|
||||
|
||||
break;
|
||||
|
||||
case 'Region':
|
||||
$region = (int)$fields[1];
|
||||
$host = (int)$fields[1];
|
||||
$ishub = FALSE;
|
||||
$ho = NULL;
|
||||
$hub_id = NULL;
|
||||
|
||||
break;
|
||||
|
||||
case 'Host':
|
||||
$host = (int)$fields[1];
|
||||
$ishub = FALSE;
|
||||
$ho = NULL;
|
||||
$hub_id = NULL;
|
||||
|
||||
break;
|
||||
|
||||
case 'Hub':
|
||||
$node = (int)$fields[1];
|
||||
$ishub = TRUE;
|
||||
$ho = NULL;
|
||||
$role = Address::NODE_HC;
|
||||
|
||||
break;
|
||||
|
||||
@ -239,7 +234,6 @@ class NodelistImport implements ShouldQueue
|
||||
|
||||
break;
|
||||
|
||||
// Normal Node
|
||||
case '':
|
||||
$node = $fields[1];
|
||||
break;
|
||||
@ -249,15 +243,14 @@ class NodelistImport implements ShouldQueue
|
||||
continue 2;
|
||||
}
|
||||
|
||||
if (! $zo) {
|
||||
if (! $zone) {
|
||||
Log::error(sprintf('%s:! Zone NOT set, ignoring record...',self::LOGKEY));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Find or load an existing entry
|
||||
Address::unguard();
|
||||
$ao = Address::firstOrNew([
|
||||
'zone_id' => $zo?->id,
|
||||
'zone_id' => $zo->id,
|
||||
'host_id' => $host,
|
||||
'node_id' => $node,
|
||||
'point_id' => 0,
|
||||
@ -265,46 +258,42 @@ class NodelistImport implements ShouldQueue
|
||||
]);
|
||||
Address::reguard();
|
||||
|
||||
// If the address doesnt exist, we'll need to add in the region
|
||||
if (! $ao->exists)
|
||||
$ao->region_id = $region;
|
||||
|
||||
// Address moved regions
|
||||
if ($ao->region_id && ($ao->region_id !== $region)) {
|
||||
if ($ao->region_id && ($ao->region_id !== $region))
|
||||
Log::alert(sprintf('%s:%% Address [%s] changing regions [%d->%d]',self::LOGKEY,$ao->ftn,$ao->region_id,$region));
|
||||
$ao->region_id = $region;
|
||||
}
|
||||
|
||||
// Hub details changed
|
||||
if ($ao->hub_id && ($ao->hub_id !== $ho?->id)) {
|
||||
Log::alert(sprintf('%s:%% Address [%s] changing hubs [%d->%s]',self::LOGKEY,$ao->ftn,$ao->hub_id,$ho?->id));
|
||||
$ao->hub_id = $ho?->id;
|
||||
}
|
||||
$ao->region_id = $region;
|
||||
$ao->role = $role;
|
||||
$ao->hub_id = $hub_id;
|
||||
|
||||
$sysop = trim(str_replace('_',' ',$fields[4]));
|
||||
$system = trim(str_replace('_',' ',$fields[2]));
|
||||
|
||||
$protect = FALSE;
|
||||
if ($ao->exists) {
|
||||
Log::info(sprintf('%s:- Processing existing address [%s] (%d)',self::LOGKEY,$ao->ftn,$ao->id));
|
||||
|
||||
// If the address is linked to a user's system, or our system, we'll not process it any further
|
||||
if (our_address()->contains($ao->id)) {
|
||||
Log::info(sprintf('%s:! Limiting update to an address belonging to me',self::LOGKEY));
|
||||
$protect = TRUE;
|
||||
|
||||
} elseif ($ao->is_hosted) {
|
||||
Log::info(sprintf('%s:! Limiting update to a system managed by this site',self::LOGKEY));
|
||||
$protect = TRUE;
|
||||
|
||||
} elseif ($ao->is_owned) {
|
||||
Log::info(sprintf('%s:! Limiting update to a system managed by a user',self::LOGKEY));
|
||||
$protect = TRUE;
|
||||
$skip = FALSE;
|
||||
if ($our_addresses->contains($ao->id)) {
|
||||
Log::info(sprintf('%s:! Ignoring updating an address belonging to me',self::LOGKEY));
|
||||
$skip = TRUE;
|
||||
}
|
||||
|
||||
$so = $ao->system;
|
||||
if ($our_systems->contains($ao->id)) {
|
||||
Log::info(sprintf('%s:! Ignoring a system managed by this site',self::LOGKEY));
|
||||
$skip = TRUE;
|
||||
}
|
||||
|
||||
if ($our_users->contains($ao->id)) {
|
||||
Log::info(sprintf('%s:! Ignoring a system managed by a user',self::LOGKEY));
|
||||
$skip = TRUE;
|
||||
}
|
||||
|
||||
if ($skip) {
|
||||
$no->addresses()->attach($ao,['role'=>$ao->role]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$sysop = trim(str_replace('_',' ',$fields[4]));
|
||||
$system = trim(str_replace('_',' ',$fields[2]));
|
||||
|
||||
// Flags
|
||||
$methods = collect();
|
||||
$address = '';
|
||||
@ -372,160 +361,155 @@ class NodelistImport implements ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
// If we are a zone/region/host record, then the system servicing that address may change
|
||||
switch ($ao->role_id) {
|
||||
// Get the System
|
||||
// If we are a zone/region record, then the system may change
|
||||
switch ($role) {
|
||||
case Address::NODE_ZC:
|
||||
case Address::NODE_RC:
|
||||
case Address::NODE_NC:
|
||||
// For new address, we'll need to add/link to a system
|
||||
if ($ao->exists) {
|
||||
if (($ao->system->address !== $address) || ($ao->system->name !== $system) || ($ao->system->sysop !== $sysop)) {
|
||||
Log::alert(sprintf('%s:! System has changed for [%s], no longer [%s]',self::LOGKEY,$ao->ftn,$ao->system->name));
|
||||
|
||||
$ao->active = FALSE;
|
||||
$ao->save();
|
||||
|
||||
$ao = $ao->replicate();
|
||||
$ao->active = TRUE;
|
||||
$ao->system_id = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $ao->system_id) {
|
||||
// When searching for a system, we prioritise in this order:
|
||||
// - the mailer address is correct
|
||||
// - the system name is correct
|
||||
$so = System::select('systems.*')
|
||||
->join('mailer_system',['mailer_system.system_id'=>'systems.id'])
|
||||
->when($address,
|
||||
fn($query)=>$query->where(
|
||||
fn($query)=>$query
|
||||
->where('systems.address',$address)
|
||||
->orWhere('mailer_system.address',$address)
|
||||
),
|
||||
fn($query)=>$query->where('systems.name',$system))
|
||||
->single();
|
||||
|
||||
// If no system, we'll need to create one
|
||||
if (! $so) {
|
||||
Log::info(sprintf('%s:= New System for ZC/RC/NC [%s] - System [%s] Sysop [%s]',self::LOGKEY,$ao->ftn,$system,$sysop));
|
||||
$so = new System;
|
||||
$so->sysop = $sysop;
|
||||
$so->name = $system;
|
||||
$so->address = $address;
|
||||
$so->location = 'TBA';
|
||||
$so->notes = sprintf('Created by Nodelist Import: %d',$no->id);
|
||||
$so->active = TRUE;
|
||||
|
||||
$so->save();
|
||||
}
|
||||
|
||||
$ao->system_id = $so->id;
|
||||
}
|
||||
|
||||
$ao->save();
|
||||
|
||||
$no->addresses()->attach($ao,['role'=>$ao->role_id]);
|
||||
continue 2;
|
||||
}
|
||||
|
||||
if (! $protect) {
|
||||
// Normal Node
|
||||
if ($ao->system_id && (
|
||||
(($ao->system->sysop === $sysop) || ($ao->system->name === $system))
|
||||
&& (($ao->system->address === $address) || $methods->pluck('address')->contains($address))))
|
||||
{
|
||||
Log::info(sprintf('%s:= Matched [%s] to existing system [%s] with address [%s]',self::LOGKEY,$ao->ftn,$ao->system->name,$ao->system->address));
|
||||
$so = $ao->system;
|
||||
|
||||
// If the sysop name is different
|
||||
if ($so->sysop !== $sysop) {
|
||||
Log::alert(sprintf('%s:! Sysop Name changed for BBS [%s:%s] from [%s] to [%s]',self::LOGKEY,$so->id,$so->name,$so->sysop,$sysop));
|
||||
|
||||
$so->sysop = $sysop;
|
||||
|
||||
// We have the same name has changed (except for ZC/RC addresses)
|
||||
} elseif ($so->name !== $system) {
|
||||
Log::alert(sprintf('%s:! System Name changed for BBS [%s:%s] to [%s]',self::LOGKEY,$so->id,$so->name,$system));
|
||||
|
||||
$so->name = $system;
|
||||
}
|
||||
|
||||
// We'll search and see if we already have that system
|
||||
} else {
|
||||
Log::debug(sprintf('%s:- Looking for existing system [%s] with address [%s]',self::LOGKEY,$system,$address));
|
||||
// When searching for a system, we prioritise in this order:
|
||||
// - the mailer address is correct
|
||||
// - the system name is correct
|
||||
$so = System::select('systems.*')
|
||||
$so = ($x=System::distinct('systems.*')
|
||||
->join('mailer_system',['mailer_system.system_id'=>'systems.id'])
|
||||
->when($address,
|
||||
fn($query)=>$query->where(
|
||||
fn($query)=>$query
|
||||
->where('systems.address',$address)
|
||||
->orWhere('mailer_system.address',$address)
|
||||
),
|
||||
fn($query)=>$query->where('systems.name',$system))
|
||||
->where('sysop',$sysop)
|
||||
->where(function($query) use ($address,$methods) {
|
||||
return $query->where('systems.address',$address)
|
||||
->when($methods->pluck('address')->filter()->count(),function ($query) use ($methods) {
|
||||
return $query->whereIN('mailer_system.address',$methods->pluck('address'));
|
||||
});
|
||||
})
|
||||
->when($methods->pluck('port')->filter()->count(),function ($query) use ($methods) {
|
||||
return $query->whereIN('mailer_system.port',$methods->pluck('port'));
|
||||
}))
|
||||
->single();
|
||||
|
||||
if (! $so) {
|
||||
Log::debug(sprintf('%s:- Didnt match on system address, looking for System [%s] AND Sysop [%s]',self::LOGKEY,$system,$sysop));
|
||||
Log::info(sprintf('%s:= New System for ZC/RC/NC [%s] - System [%s] Sysop [%s]',self::LOGKEY,$ao->ftn,$system,$sysop));
|
||||
$so = new System;
|
||||
$so->sysop = $sysop;
|
||||
$so->name = $system;
|
||||
$so->address = $address;
|
||||
$so->location = 'TBA';
|
||||
$so->notes = sprintf('Created by Nodelist Import: %d',$no->id);
|
||||
$so->active = TRUE;
|
||||
|
||||
$so = System::where('name',$system)
|
||||
->where('sysop',$sysop)
|
||||
->firstOrNew();
|
||||
|
||||
} else {
|
||||
Log::debug(sprintf('%s:- Matched on system [%d] address',self::LOGKEY,$so->id));
|
||||
$so->save();
|
||||
}
|
||||
|
||||
if ($so->exists)
|
||||
Log::info(sprintf('%s:= Linking address [%d:%d/%d] to [%s:%s]',self::LOGKEY,$zo->zone_id,$ao->host_id,$ao->node_id,$so->id,$so->name));
|
||||
else
|
||||
Log::info(sprintf('%s:= New System [%s] with FTN [%d:%d/%d]',self::LOGKEY,$system,$zo->zone_id,$ao->host_id,$ao->node_id));
|
||||
// If the address exists, but it was discovered, assign it to this new host
|
||||
if ($ao->system_id && ($ao->system_id !== $so->id) && ($ao->system->name === System::default)) {
|
||||
Log::info(sprintf('%s:= Re-assigning discovered address to [%s]',self::LOGKEY,$so->id));
|
||||
|
||||
$so->name = $system;
|
||||
$so->sysop = $sysop;
|
||||
$so->active = TRUE;
|
||||
} elseif (! $ao->system_id) {
|
||||
Log::alert(sprintf('%s:%% [%s] address not assigned to any system [%s:%s]',self::LOGKEY,$ao->ftn,$system,$sysop));
|
||||
|
||||
if (! $so->exists)
|
||||
$so->notes = sprintf('Created by Nodelist Import: %d',$no->id);
|
||||
}
|
||||
} elseif ($ao->system_id !== $so->id) {
|
||||
Log::alert(sprintf('%s:%% [%s] hosted by new system [%s:%s] (was %s:%s)',self::LOGKEY,$ao->ftn,$system,$sysop,$ao->system->name,$ao->system->sysop));
|
||||
$ao->active = FALSE;
|
||||
$ao->save();
|
||||
|
||||
$so->phone = $fields[5] != '-Unpublished-' ? $fields[5] : NULL;
|
||||
$so->location = trim(str_replace('_',' ',$fields[3]));
|
||||
$ao = $ao->replicate();
|
||||
$ao->active = TRUE;
|
||||
}
|
||||
|
||||
// Save the system record
|
||||
try {
|
||||
$so->save();
|
||||
$ao->system_id = $so->id;
|
||||
$ao->save();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error(sprintf('%s:! Error with line [%s] (%s)',self::LOGKEY,$line,$e->getMessage()),['fields'=>$fields]);
|
||||
|
||||
DB::rollBack();
|
||||
throw new \Exception($e->getMessage());
|
||||
}
|
||||
|
||||
$ao->system_id = $so->id;
|
||||
$ao->load('system');
|
||||
}
|
||||
|
||||
if ($methods->count() && (! $ao->is_private)) {
|
||||
$methods->transform(function($item) {
|
||||
$item['active'] = Arr::get($item,'active',TRUE);
|
||||
return $item;
|
||||
});
|
||||
if ($ao->system_id && ((($ao->system->sysop === $sysop) || ($ao->system->name === $system)) && (($ao->system->address === $address) || ($methods->pluck('address')->search($address) !== FALSE)))) {
|
||||
Log::info(sprintf('%s:= Matched [%s] to existing system [%s] with address [%s]',self::LOGKEY,$ao->ftn,$ao->system->name,$ao->system->address));
|
||||
$so = $ao->system;
|
||||
|
||||
// If the sysop name is different
|
||||
if ($so->sysop !== $sysop) {
|
||||
Log::alert(sprintf('%s:! Sysop Name changed for BBS [%s:%s] from [%s] to [%s]',
|
||||
self::LOGKEY,$so->id,$so->name,$so->sysop,$sysop));
|
||||
|
||||
$so->sysop = $sysop;
|
||||
|
||||
// We have the same name has changed (except for ZC/RC addresses)
|
||||
} elseif (($so->name !== $system) && (! ((Address::NODE_ZC|Address::NODE_RC|Address::NODE_NC) & $ao->role_id))) {
|
||||
Log::alert(sprintf('%s:! System Name changed for BBS [%s:%s] to [%s]',
|
||||
self::LOGKEY,$so->id,$so->name,$system));
|
||||
|
||||
$so->name = $system;
|
||||
}
|
||||
|
||||
// We'll search and see if we already have that system
|
||||
} else {
|
||||
Log::debug(sprintf('%s:- Looking for existing system [%s] with address [%s]',self::LOGKEY,$system,$address));
|
||||
// If we dont have $address/port
|
||||
$so = NULL;
|
||||
|
||||
if ($address) {
|
||||
$so = System::select('systems.*')
|
||||
->distinct()
|
||||
->join('mailer_system',['mailer_system.system_id'=>'systems.id'])
|
||||
->where(function($query) use ($address) {
|
||||
return $query->where('systems.address',$address)
|
||||
->orWhere('mailer_system.address',$address);
|
||||
})
|
||||
->single();
|
||||
}
|
||||
|
||||
if (! $so) {
|
||||
Log::debug(sprintf('%s:- Didnt match on system address, looking for System [%s] AND Sysop [%s]',self::LOGKEY,$system,$sysop));
|
||||
|
||||
$so = System::where('name',$system)
|
||||
->where('sysop',$sysop)
|
||||
->firstOrNew();
|
||||
|
||||
} else {
|
||||
Log::debug(sprintf('%s:- Matched on system [%d] address',self::LOGKEY,$so->id));
|
||||
}
|
||||
|
||||
if ($so->exists)
|
||||
Log::info(sprintf('%s:= Linking address [%d:%d/%d] to [%s:%s]',self::LOGKEY,$zo->zone_id,$ao->host_id,$ao->node_id,$so->id,$so->name));
|
||||
else
|
||||
Log::info(sprintf('%s:= New System [%s] with FTN [%d:%d/%d]',self::LOGKEY,$system,$zo->zone_id,$ao->host_id,$ao->node_id));
|
||||
|
||||
$so->name = $system;
|
||||
$so->sysop = $sysop;
|
||||
$so->active = TRUE;
|
||||
|
||||
if (! $so->exists)
|
||||
$so->notes = sprintf('Created by Nodelist Import: %d',$no->id);
|
||||
}
|
||||
|
||||
$so->phone = $fields[5] != '-Unpublished-' ? $fields[5] : NULL;
|
||||
$so->location = trim(str_replace('_',' ',$fields[3]));
|
||||
/*
|
||||
if (! in_array($fields[5],['-Unpublished-']))
|
||||
$so->phone = $fields[5];
|
||||
|
||||
$so->baud = $fields[6];
|
||||
*/
|
||||
|
||||
// Save the system record
|
||||
try {
|
||||
$so->save();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error(sprintf('%s:! Error with line [%s] (%s)',self::LOGKEY,$line,$e->getMessage()),['fields'=>$fields]);
|
||||
|
||||
DB::rollBack();
|
||||
throw new \Exception($e->getMessage());
|
||||
}
|
||||
|
||||
// @todo This should be a bit test ($ao->rule & Address::NODE_PVT)?
|
||||
if ($methods->count() && ($ao->role != Address::NODE_PVT)) {
|
||||
$methods->transform(function($item) { $item['active'] = Arr::get($item,'active',TRUE); return $item; });
|
||||
$so->mailers()->sync($methods);
|
||||
}
|
||||
|
||||
// If our zone didnt exist, we'll create it with this system
|
||||
if (! $zo->exists) {
|
||||
$zo->system_id = $ao->system_id;
|
||||
$zo->system_id = $so->id;
|
||||
$zo->save();
|
||||
}
|
||||
|
||||
$ao->zone_id = $zo->id;
|
||||
$ao->role = $role;
|
||||
$ao->validated = TRUE;
|
||||
|
||||
if ($ao->getDirty())
|
||||
$p++;
|
||||
@ -533,13 +517,10 @@ class NodelistImport implements ShouldQueue
|
||||
try {
|
||||
$so->addresses()->save($ao);
|
||||
|
||||
// If we were the hub
|
||||
if ($ishub) {
|
||||
$ho = $ao;
|
||||
$ishub = FALSE;
|
||||
}
|
||||
if ($ao->role_id === Address::NODE_HC)
|
||||
$hub_id = $ao->id;
|
||||
|
||||
$no->addresses()->attach($ao,['role'=>($ao->role_id & $role)]);
|
||||
$no->addresses()->attach($ao,['role'=>$ao->role]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error(sprintf('%s:! Error with line [%s] (%s)',self::LOGKEY,$line,$e->getMessage()),['fields'=>$fields]);
|
||||
@ -555,34 +536,27 @@ class NodelistImport implements ShouldQueue
|
||||
|
||||
// Remove addresses not recorded;
|
||||
$no->load('addresses');
|
||||
|
||||
$remove = $zo
|
||||
->addresses->pluck('id')
|
||||
->diff($no->addresses->pluck('id'))
|
||||
->diff(our_address($do)->pluck('id'))
|
||||
->diff(our_nodes($do)->pluck('id'));
|
||||
|
||||
$remove = Address::whereIn('id',$remove)->get();
|
||||
$remove = $zo->addresses->diff($no->addresses)->except($our_systems->toArray())->except($our_users->toArray());
|
||||
Log::alert(sprintf('%s:%% Deleting [%d] addresses [%s]',self::LOGKEY,$remove->count(),$remove->pluck('ftn2d')->join(',')));
|
||||
Address::whereIN('id',$remove->pluck('id')->toArray())->update(['active'=>FALSE]);
|
||||
Address::whereIN('id',$remove->pluck('id')->toArray())->delete();
|
||||
|
||||
Address::whereIN('id',$remove->pluck('id'))->update(['active'=>FALSE]);
|
||||
Address::whereIN('id',$remove->pluck('id'))->delete();
|
||||
|
||||
Log::info(sprintf('%s:= Updated %d AKA records from %d Systems',self::LOGKEY,$p,$c));
|
||||
$crc = crc16(substr($crc_check,0,-3));
|
||||
$crc = crc16(substr($tocrc,0,-3));
|
||||
|
||||
if ((! $this->testmode) && ($this->ignore_crc || ($crc === $file_crc))) {
|
||||
Log::info(sprintf('%s:= Committing nodelist',self::LOGKEY));
|
||||
DB::commit();
|
||||
|
||||
if ($this->delete_file and $c)
|
||||
unlink($file);
|
||||
|
||||
} else {
|
||||
Log::error(sprintf('%s:! Rolling back nodelist, CRC doesnt match [%s != %s] or TEST mode',self::LOGKEY,$crc,$file_crc));
|
||||
Log::error(sprintf('%s:! Rolling back nodelist, CRC doesnt match [%s](%s) or test mode',self::LOGKEY,$crc,$file_crc));
|
||||
DB::rollBack();
|
||||
}
|
||||
|
||||
fclose($fh);
|
||||
|
||||
if ($this->delete_file and $c)
|
||||
unlink($file);
|
||||
|
||||
Log::info(sprintf('%s:= Updated %d records from %d systems',self::LOGKEY,$p,$c));
|
||||
}
|
||||
}
|
@ -95,7 +95,7 @@ class PacketProcess implements ShouldQueue
|
||||
}
|
||||
|
||||
// Check the packet password
|
||||
if ($pkt->fftn->pass_packet !== strtoupper($pkt->password)) {
|
||||
if (strtoupper($pkt->fftn->session('pktpass')) !== strtoupper($pkt->password)) {
|
||||
Log::error(sprintf('%s:! Packet from [%s] with password [%s] is invalid.',self::LOGKEY,$pkt->fftn->ftn,$pkt->password));
|
||||
|
||||
Notification::route('netmail',$pkt->fftn)->notify(new PacketPasswordInvalid($pkt->password,$f->pktName()));
|
||||
|
@ -40,6 +40,7 @@ use App\Traits\{QueryCacheableConfig,ScopeActive};
|
||||
class Address extends Model
|
||||
{
|
||||
use QueryCacheableConfig,ScopeActive,SoftDeletes;
|
||||
const CACHE_KEY = 0;
|
||||
|
||||
private const LOGKEY = 'MA-';
|
||||
|
||||
@ -357,12 +358,12 @@ class Address extends Model
|
||||
}
|
||||
|
||||
return [
|
||||
'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],
|
||||
'd' => $matches[5] ?? NULL
|
||||
'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],
|
||||
'd'=>$matches[5] ?? NULL
|
||||
];
|
||||
}
|
||||
|
||||
@ -385,18 +386,6 @@ class Address extends Model
|
||||
->FTNorder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Select to support returning FTN address
|
||||
*
|
||||
* @param $query
|
||||
* @return void
|
||||
*/
|
||||
public function scopeFTN($query)
|
||||
{
|
||||
return $query->select(['addresses.zone_id','host_id','node_id','point_id'])
|
||||
->with('zone.domain');
|
||||
}
|
||||
|
||||
public function scopeFTNOrder($query)
|
||||
{
|
||||
return $query
|
||||
@ -566,6 +555,21 @@ class Address extends Model
|
||||
->withPivot(['export_at','sent_at','sent_pkt']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use echomail_seen()
|
||||
*/
|
||||
public function echomails() {
|
||||
return $this->echomail_seen();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use file_seen
|
||||
*/
|
||||
public function files()
|
||||
{
|
||||
return $this->file_seen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Files that this address has seen
|
||||
*
|
||||
@ -740,31 +744,16 @@ class Address extends Model
|
||||
return sprintf('%s.%d',$this->getFTN3DAttribute(),$this->point_id);
|
||||
}
|
||||
|
||||
public function getIsDefaultRouteAttribute(): bool
|
||||
{
|
||||
return ! is_null($this->session('default'));
|
||||
}
|
||||
|
||||
public function getIsDownAttribute(): bool
|
||||
{
|
||||
return $this->role & self::NODE_DOWN;
|
||||
}
|
||||
|
||||
public function getIsHostedAttribute(): bool
|
||||
{
|
||||
return ! is_null($this->getPassSessionAttribute());
|
||||
}
|
||||
|
||||
public function getIsHoldAttribute(): bool
|
||||
{
|
||||
return $this->role & self::NODE_HOLD;
|
||||
}
|
||||
|
||||
public function getIsOwnedAttribute(): bool
|
||||
{
|
||||
return $this->system->is_owned;
|
||||
}
|
||||
|
||||
public function getIsPrivateAttribute(): bool
|
||||
{
|
||||
return (! $this->system->address);
|
||||
@ -778,12 +767,12 @@ class Address extends Model
|
||||
*/
|
||||
public function getRoleIdAttribute(): int
|
||||
{
|
||||
static $warn = FALSE;
|
||||
static $warn= FALSE;
|
||||
|
||||
$val = ($this->role & self::NODE_ALL);
|
||||
$role = $this->ftn_role();
|
||||
|
||||
if ($this->isRoleOverride($role)) {
|
||||
if ($this->isRoleOverride()) {
|
||||
if (! $warn) {
|
||||
$warn = TRUE;
|
||||
Log::alert(sprintf('%s:! Address ROLE [%d] is not consistent with what is expected [%d] for [%s]',self::LOGKEY,$val,$role,$this->ftn));
|
||||
@ -827,26 +816,6 @@ class Address extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function getPassFixAttribute(): ?string
|
||||
{
|
||||
return strtoupper($this->session('fixpass'));
|
||||
}
|
||||
|
||||
public function getPassPacketAttribute(): ?string
|
||||
{
|
||||
return strtoupper($this->session('pktpass'));
|
||||
}
|
||||
|
||||
public function getPassSessionAttribute(): ?string
|
||||
{
|
||||
return $this->session('sesspass');
|
||||
}
|
||||
|
||||
public function getPassTicAttribute(): ?string
|
||||
{
|
||||
return strtoupper($this->session('ticpass'));
|
||||
}
|
||||
|
||||
/* METHODS */
|
||||
|
||||
/**
|
||||
@ -933,11 +902,11 @@ class Address extends Model
|
||||
public function downlinks(): Collection
|
||||
{
|
||||
// We have no session data for this address, by definition it has no children
|
||||
if (! $this->is_hosted && (! our_address()->pluck('id')->contains($this->id)))
|
||||
if (! $this->session('sespass') && (! our_address()->pluck('id')->contains($this->id)))
|
||||
return new Collection;
|
||||
|
||||
// If this system is not marked to default route for this address
|
||||
if (! $this->is_default_route) {
|
||||
if (! $this->session('default')) {
|
||||
$children = $this->children();
|
||||
|
||||
// We route everything for this domain
|
||||
@ -1021,7 +990,7 @@ class Address extends Model
|
||||
*/
|
||||
public function filesWaiting(): Collection
|
||||
{
|
||||
return $this->file_seen()
|
||||
return $this->files()
|
||||
->whereNull('sent_at')
|
||||
->whereNotNull('export_at')
|
||||
->get();
|
||||
@ -1089,6 +1058,18 @@ class Address extends Model
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get files for this node (including it's children)
|
||||
*
|
||||
* @param bool $update
|
||||
* @return Collection
|
||||
* @deprecated use filesWaiting() directly
|
||||
*/
|
||||
public function getFiles(bool $update=TRUE): Collection
|
||||
{
|
||||
return $this->filesWaiting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get netmail for this node (including it's children)
|
||||
*
|
||||
@ -1135,10 +1116,47 @@ class Address extends Model
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public function isRoleOverride(int $role=NULL): bool
|
||||
/**
|
||||
* Return a packet of mail
|
||||
*
|
||||
* @param Collection $msgs of message models (Echomail/Netmail)
|
||||
* @param string|null $passwd Override password used in packet
|
||||
* @return Packet|null
|
||||
* @throws \Exception
|
||||
* @deprecated
|
||||
*/
|
||||
private function getPacket(Collection $msgs,string $passwd=NULL): ?Packet
|
||||
{
|
||||
$s = Setup::findOrFail(config('app.id'));
|
||||
$ao = our_address($this);
|
||||
|
||||
// If we dont match on the address, we cannot pack mail for that system
|
||||
if (! $ao) {
|
||||
Log::alert(sprintf('%s:! We didnt match an address in zone [%d] for [%s]',self::LOGKEY,$this->zone->zone_id,$this->ftn));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Get packet type
|
||||
$o = $ao->system->packet($this);
|
||||
$o->addressHeader($ao,$this,$passwd);
|
||||
|
||||
// $oo = Netmail/Echomail Model
|
||||
$c = 0;
|
||||
foreach ($msgs as $oo) {
|
||||
// Only bundle up to max messages
|
||||
if (++$c > $s->pkt_msgs)
|
||||
break;
|
||||
|
||||
$o->addMail($oo->packet($this,$passwd));
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
public function isRoleOverride(): bool
|
||||
{
|
||||
$val = ($this->role & self::NODE_ALL);
|
||||
$role = $role ?: $this->ftn_role();
|
||||
$role = $this->ftn_role();
|
||||
|
||||
return ($val && ($role !== $val)) || (! $role);
|
||||
}
|
||||
@ -1266,7 +1284,7 @@ class Address extends Model
|
||||
* @param string $type
|
||||
* @return string|null
|
||||
*/
|
||||
private function session(string $type): ?string
|
||||
public function session(string $type): ?string
|
||||
{
|
||||
return ($this->exists && ($x=$this->system->sessions->where('id',$this->zone_id)->first())) ? ($x->pivot->{$type} ?: '') : NULL;
|
||||
}
|
||||
@ -1284,7 +1302,7 @@ class Address extends Model
|
||||
return NULL;
|
||||
|
||||
// If we have session password, then we are the parent
|
||||
if ($this->is_hosted)
|
||||
if ($x=$this->session('sespass'))
|
||||
return $this;
|
||||
|
||||
if ($x=$this->parent()?->uplink()) {
|
||||
|
@ -170,11 +170,6 @@ class System extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function getIsOwnedAttribute(): bool
|
||||
{
|
||||
return $this->users->count();
|
||||
}
|
||||
|
||||
public function getPktMsgsAttribute(?int $val): int
|
||||
{
|
||||
return $val ?: Setup::findOrFail(config('app.id'))->msgs_pkt;
|
||||
|
@ -102,17 +102,17 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this user have systems with points
|
||||
*
|
||||
* @return Collection
|
||||
* @deprecated not used - but if it is, probably could use Address::points()?
|
||||
*/
|
||||
public function points(): Collection
|
||||
{
|
||||
return $this
|
||||
->systems
|
||||
->pluck('addresses')
|
||||
->flatten()
|
||||
->where('point_id','>',0);
|
||||
$result = collect();
|
||||
|
||||
foreach($this->systems->pluck('addresses')->flatten()->where('role','>',Address::NODE_HC) as $ao)
|
||||
$result = $result->merge($ao->children());
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,7 @@
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
use App\Models\File;
|
||||
@ -18,27 +19,42 @@ trait Import
|
||||
* Count the lines in a file
|
||||
* Assumes $file is compressed with ZIP
|
||||
*/
|
||||
private function getFileLines(mixed $f): int
|
||||
private function getFileLines(string $file): int
|
||||
{
|
||||
$c = 0;
|
||||
|
||||
$f = NULL;
|
||||
$z = $this->openFile($file,$f);
|
||||
|
||||
while (! feof($f)) {
|
||||
fgets($f);
|
||||
$c++;
|
||||
}
|
||||
|
||||
fclose($f);
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
private function openFile(string $file): \ZipArchive
|
||||
private function openFile(string $file,&$f): \ZipArchive
|
||||
{
|
||||
$z = new \ZipArchive;
|
||||
|
||||
if ($z->open($file,\ZipArchive::RDONLY) === TRUE) {
|
||||
return $z;
|
||||
if ($z->count() !== 1)
|
||||
throw new \Exception(sprintf('%s:File [%s] has more than 1 file (%d)', self::LOGKEY, $file, $z->count()));
|
||||
|
||||
$zipfile = $z->statIndex(0, \ZipArchive::FL_UNCHANGED);
|
||||
Log::debug(sprintf('%s:Looking at [%s] in archive [%s]', self::LOGKEY,$zipfile['name'],$file));
|
||||
|
||||
$f = $z->getStream($zipfile['name']);
|
||||
if (! $f)
|
||||
throw new \Exception(sprintf('%s:Failed getting ZipArchive::stream (%s)',self::LOGKEY,$z->getStatusString()));
|
||||
else
|
||||
return $z;
|
||||
|
||||
} else {
|
||||
throw new \Exception(sprintf('%s:! Failed opening ZipArchive [%s] (%s)',self::LOGKEY,$file,$z->getStatusString()));
|
||||
throw new \Exception(sprintf('%s:Failed opening ZipArchive [%s] (%s)',self::LOGKEY,$file,$z->getStatusString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@
|
||||
@foreach ($o->zones->sortBy('zone_id') as $oz)
|
||||
@foreach ($oz->addresses as $ao)
|
||||
<tr>
|
||||
<td><a href="{{ url('system/addedit',[$ao->system_id]) }}">{{ $ao->system->full_name($ao) }}</a> @auth<span class="float-end"><small>@if($ao->is_hosted)<sup>{{ $ao->is_default ? '**' : '*' }}</sup>@elseif($ao->system->setup)<sup class="success">+</sup>@endif[{{ $ao->system_id }}]</small></span>@endauth</td>
|
||||
<td><a href="{{ url('system/addedit',[$ao->system_id]) }}">{{ $ao->system->full_name($ao) }}</a> @auth<span class="float-end"><small>@if($ao->session('sespass'))<sup>{{ $ao->session('default') ? '**' : '*' }}</sup>@elseif($ao->system->setup)<sup class="success">+</sup>@endif[{{ $ao->system_id }}]</small></span>@endauth</td>
|
||||
<td>{{ $ao->system->sysop }}</td>
|
||||
<td>{{ $ao->system->location }}</td>
|
||||
<td>{{ $ao->ftn4d }}</td>
|
||||
|
@ -178,7 +178,7 @@
|
||||
<tbody>
|
||||
@foreach ($o->addresses as $ao)
|
||||
<tr>
|
||||
<td><a href="{{ url('system/addedit',[$ao->system_id]) }}">{{ $ao->system->full_name($ao) }}</a> @auth<span class="float-end"><small>@if($ao->is_hosted)<sup>{{ $ao->is_default ? '**' : '*' }}</sup>@elseif($ao->system->setup)<sup class="success">+</sup>@endif[{{ $ao->system_id }}]</small></span>@endauth</td>
|
||||
<td><a href="{{ url('system/addedit',[$ao->system_id]) }}">{{ $ao->system->full_name($ao) }}</a> @auth<span class="float-end"><small>@if($ao->session('sespass'))<sup>{{ $ao->session('default') ? '**' : '*' }}</sup>@elseif($ao->system->setup)<sup class="success">+</sup>@endif[{{ $ao->system_id }}]</small></span>@endauth</td>
|
||||
<td>{{ $ao->ftn_3d }}</td>
|
||||
<td>{{ $ao->system->last_session ? $ao->system->last_session->format('Y-m-d H:i') : '-' }}</td>
|
||||
<td>{{ ($x=$o->waiting($ao))->count() ? $x->first()->datetime->format('Y-m-d H:i') : '-' }}</td>
|
||||
|
@ -57,7 +57,7 @@
|
||||
<label for="subject" class="form-label">Subject</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text @error('subject') is-invalid @enderror"><i class="bi bi-wifi"></i></span>
|
||||
<input type="text" class="form-control" id="subject" placeholder="Areafix Password" name="subject" value="{{ old('subject',$ao->pass_fix) }}">
|
||||
<input type="text" class="form-control" id="subject" placeholder="Areafix Password" name="subject" value="{{ old('subject',$ao->session('fixpass')) }}">
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('subject')
|
||||
{{ $message }}
|
||||
|
@ -62,7 +62,7 @@ Move Address
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@if ($o->is_hosted)
|
||||
@if ($o->session('sespass'))
|
||||
<div class="col-3" id="session-remove">
|
||||
<label for="remsess" class="form-label">Remove Session Details for Zone</label>
|
||||
<div class="input-group has-validation">
|
||||
@ -119,7 +119,7 @@ Move Address
|
||||
$(document).ready(function() {
|
||||
$('#system_id').select2();
|
||||
|
||||
@if ($o->is_hosted)
|
||||
@if ($o->session('sespass'))
|
||||
$('#remove_yes').on('change',function() {
|
||||
if (! $('#session-remove').hasClass('d-none'))
|
||||
$('#session-remove').addClass('d-none');
|
||||
|
Loading…
Reference in New Issue
Block a user