Fix for EMSI aborting with $rc undefined, Fix for idle nodes updates failing on updated_at column and change text used when nodes have never polled

This commit is contained in:
Deon George 2025-01-29 08:45:46 +11:00
parent 35c5b3da8d
commit 8cc561ea2b
4 changed files with 28 additions and 16 deletions

View File

@ -929,6 +929,8 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
} catch (SocketException $e) {
if ($c++ > 2)
return self::TIMEOUT;
else
$ch = -2;
}
if (static::DEBUG)

View File

@ -489,7 +489,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
* @param Send $send
* @return int
*/
public function zmodem_sendfile(Send $send,Node $node): int
public function zmodem_sendfile(Send $send,Node $node): void
{
Log::debug(sprintf('%s:+ zmodem_sendfile',self::LOGKEY));
@ -513,16 +513,16 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break;
}
return $rc;
return;
} catch (\Exception $e) {
Log::error(sprintf('%s:! Error [%s]',self::LOGKEY,$e->getMessage()),['rc'=>$rc]);
Log::error(sprintf('%s:! Error [%s]',self::LOGKEY,$e->getMessage()),['rc'=>$rc ?? '-UNDEFINED-']);
return $rc;
return;
}
}
return self::OK;
return;
}
/**

View File

@ -9,11 +9,9 @@ use Illuminate\Database\Eloquent\Collection;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Notification;
use App\Classes\FTN\Message;
use App\Models\{Address,Domain,System};
use App\Notifications\Echomails\AbsentNodes;
use App\Notifications\Emails\NodeMarkedDown as NodeMarkedDownEmail;
@ -205,7 +203,7 @@ class AddressIdle implements ShouldQueue
->whereIn('addresses.id',our_nodes($do)->pluck('id'))
->when($ao,fn($query)=>$query->where('addresses.id',$ao->id))
->where(fn($q)=>$q->where('last_session','<',$age)
->orWhere(fn($q)=>$q->whereNull('last_session')->where('updated_at','<',Carbon::now()->subDays(14)->startOfDay())))
->orWhere(fn($q)=>$q->whereNull('last_session')->where('addresses.updated_at','<',Carbon::now()->subDays(14)->startOfDay())))
->whereRaw(sprintf('((role IS NULL) OR (role=0) OR ((role & %d) > 0))',$flags))
->whereRaw(sprintf('((role IS NULL) OR ((role & %d) = 0))',Address::NODE_KEEP))
->join('systems',['systems.id'=>'addresses.system_id'])

View File

@ -57,22 +57,30 @@ class AbsentNodes extends Echomails
$msg->addText("The following nodes have had their status changed, because they are absent from the network.\r\r");
// Nodes marked HOLD - will be marked down ...
// Nodes marked HOLD
if (($x=$this->aos->filter(fn($item)=>$item->active && ($item->role & Address::NODE_HOLD)))->count()) {
$msg->addText("The following nodes have been marked HOLD:\r");
foreach ($x as $ao)
$msg->addText(sprintf('* %s (%s), last seen %d days ago',$ao->ftn4d,$ao->system->name,$ao->system->last_seen?->diffInDays($now)).($ao->contacted ? '': ' ^')."\r");
foreach ($x as $ao) {
if (! $ao->system->last_seen)
$msg->addText(sprintf('* %s (%s), not seen since registered %d days ago',$ao->ftn4d,$ao->system->name,$ao->system->updated_at->diffInDays($now)).($ao->contacted ? '': ' ^')."\r");
else
$msg->addText(sprintf('* %s (%s), last seen %d days ago',$ao->ftn4d,$ao->system->name,$ao->system->last_seen->diffInDays($now)).($ao->contacted ? '': ' ^')."\r");
}
$msg->addText("\r");
}
// Nodes marked DOWN - will be delisted on...
// Nodes marked DOWN
if (($x=$this->aos->filter(fn($item)=>$item->active && ($item->role & Address::NODE_DOWN)))->count()) {
$msg->addText("The following nodes have been marked DOWN:\r");
foreach ($x as $ao)
foreach ($x as $ao) {
if (! $ao->system->last_seen)
$msg->addText(sprintf('* %s (%s), not seen since registered %d days ago',$ao->ftn4d,$ao->system->name,$ao->system->updated_at->diffInDays($now)).($ao->contacted ? '': ' ^')."\r");
else
$msg->addText(sprintf('* %s (%s), last seen %d days ago',$ao->ftn4d,$ao->system->name,$ao->system->last_seen?->diffInDays($now)).($ao->contacted ? '': ' ^')."\r");
}
$msg->addText("\r");
}
@ -81,8 +89,12 @@ class AbsentNodes extends Echomails
if (($x=$this->aos->filter(fn($item)=>! $item->active))->count()) {
$msg->addText("The following nodes have been DE-LISTED:\r");
foreach ($x as $ao)
foreach ($x as $ao) {
if (! $ao->system->last_seen)
$msg->addText(sprintf('* %s (%s), not seen since registered %d days ago',$ao->ftn4d,$ao->system->name,$ao->system->updated_at->diffInDays($now)).($ao->contacted ? '': ' ^')."\r");
else
$msg->addText(sprintf('* %s (%s), last seen %d days ago',$ao->ftn4d,$ao->system->name,$ao->system->last_seen?->diffInDays($now)).($ao->contacted ? '': ' ^')."\r");
}
$msg->addText("\r");
}