Compare commits
No commits in common. "1bedad17a478c88374cd9153bee60d9c5dcb965d" and "617901f7df5f6b06efdca9db98e71dc4c77f09c6" have entirely different histories.
1bedad17a4
...
617901f7df
@ -17,7 +17,7 @@ abstract class FTN
|
||||
$this->fn,
|
||||
$this->ff,
|
||||
$this->fp,
|
||||
).((isset($this->zone) && $this->zone) ? sprintf('@%s',$this->zone->domain->name) : '');
|
||||
).($this->zone ? sprintf('@%s',$this->zone->domain->name) : '');
|
||||
|
||||
case 'tftn_t':
|
||||
return sprintf('%d:%d/%d.%d',
|
||||
@ -25,7 +25,7 @@ abstract class FTN
|
||||
$this->tn,
|
||||
$this->tf,
|
||||
$this->tp,
|
||||
).((isset($this->zone) && $this->zone) ? sprintf('@%s',$this->zone->domain->name) : '');
|
||||
).($this->zone ? sprintf('@%s',$this->zone->domain->name) : '');
|
||||
|
||||
case 'fftn':
|
||||
return Address::findFTN($this->fftn_t);
|
||||
|
@ -306,7 +306,7 @@ class Message extends FTNBase
|
||||
case 'fz': return (int)Arr::get($this->src,'z');
|
||||
case 'fn': return (int)($x=$this->src) ? Arr::get($x,'n') : Arr::get($this->header,'onet');
|
||||
case 'ff': return (int)($x=$this->src) ? Arr::get($x,'f') : Arr::get($this->header,'onode');
|
||||
case 'fp': return (int)$this->mo->kludges->get('FMPT') ?: Arr::get($this->src,'p',Arr::get($this->header,'opoint',0));
|
||||
case 'fp': return (int)$this->mo->kludges->get('FMPT:') ?: Arr::get($this->src,'p',Arr::get($this->header,'opoint',0));
|
||||
case 'fd': return Arr::get($this->src,'d');
|
||||
|
||||
case 'fzone':
|
||||
@ -323,7 +323,6 @@ class Message extends FTNBase
|
||||
return Zone::where('zone_id',$this->fz)
|
||||
->where('default',TRUE)
|
||||
->single();
|
||||
|
||||
case 'fdomain':
|
||||
// We'll use the zone's domain if this method class was called with a zone
|
||||
if ($this->zone && (($this->zone->domain->name === Arr::get($this->src,'d')) || ! Arr::get($this->src,'d')))
|
||||
@ -341,7 +340,7 @@ class Message extends FTNBase
|
||||
case 'tz': return (int)Arr::get($this->isEchomail() ? $this->src : $this->dst,'z');
|
||||
case 'tn': return (int)Arr::get($this->header,'dnet');
|
||||
case 'tf': return (int)Arr::get($this->header,'dnode');
|
||||
case 'tp': return (int)$this->mo->kludges->get('TOPT') ?: Arr::get($this->header,'dpoint',0);
|
||||
case 'tp': return (int)$this->mo->kludges->get('TOPT:') ?: Arr::get($this->header,'dpoint',0);
|
||||
|
||||
case 'tzone':
|
||||
// Use the zone if this class was called with it.
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Classes\FTN;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@ -12,7 +13,7 @@ use Symfony\Component\HttpFoundation\File\File;
|
||||
use App\Classes\FTN as FTNBase;
|
||||
use App\Exceptions\InvalidPacketException;
|
||||
use App\Models\{Address,Domain,Echomail,Netmail,Software,System,Zone};
|
||||
use App\Notifications\Netmails\{EchomailBadAddress,NetmailBadAddress};
|
||||
use App\Notifications\Netmails\EchomailBadAddress;
|
||||
|
||||
/**
|
||||
* Represents a Fidonet Packet, that contains an array of messages.
|
||||
@ -138,7 +139,7 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
|
||||
} else
|
||||
throw new InvalidPacketException('Not a valid packet, not EOP or SOM:'.bin2hex($x));
|
||||
|
||||
Log::info(sprintf('%s:- Packet [%s] is a [%s] packet',self::LOGKEY,$o->name,get_class($o)));
|
||||
Log::info(sprintf('%s:- Packet [%s] is a [%s] packet, dated [%s]',self::LOGKEY,$o->name,get_class($o),$o->date));
|
||||
|
||||
// Work out the packet zone
|
||||
if ($o->fz && ($o->fd || $domain)) {
|
||||
@ -158,8 +159,6 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
|
||||
->singleOrFail();
|
||||
}
|
||||
|
||||
Log::info(sprintf('%s:- Packet Dated [%s] from [%s] to [%s]',self::LOGKEY,$o->date,$o->fftn_t,$o->tftn_t));
|
||||
|
||||
$message = ''; // Current message we are building
|
||||
$msgbuf = '';
|
||||
$leader = Message::header_len()+strlen(self::PACKED_MSG_LEAD);
|
||||
@ -385,11 +384,10 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
|
||||
|
||||
// If the messages is not for the right zone, we'll ignore it
|
||||
if ($msg->errors->has('invalid-zone')) {
|
||||
Log::alert(sprintf('%s:! Message [%s] is from an invalid zone [%s], packet is from [%s] - ignoring it',self::LOGKEY,$msg->msgid,$msg->set_fftn,$this->fz));
|
||||
Log::alert(sprintf('%s:! Message [%s] is from an invalid zone [%s], packet is from [%s] - ignoring it',self::LOGKEY,$msg->msgid,$msg->fftn->zone->zone_id,$this->fftn->zone->zone_id));
|
||||
|
||||
// @todo $msg might not be echomail
|
||||
if (! $msg->kludges->get('RESCANNED'))
|
||||
Notification::route('netmail',$this->fftn)->notify(($msg instanceof Echomail) ? new EchomailBadAddress($msg) : new NetmailBadAddress($msg));
|
||||
Notification::route('netmail',$this->fftn)->notify(new EchomailBadAddress($msg));
|
||||
|
||||
return;
|
||||
}
|
||||
@ -398,7 +396,7 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
|
||||
if ($msg->errors->has('from') && $this->fftn && $this->fftn->zone_id) {
|
||||
Log::debug(sprintf('%s:^ From address [%s] doesnt exist, it needs to be created',self::LOGKEY,$msg->set->get('set_fftn')));
|
||||
|
||||
$ao = Address::findFTN($msg->set->get('set_fftn'),TRUE,TRUE);
|
||||
$ao = Address::findFTN($msg->set->get('set_fftn'),TRUE);
|
||||
|
||||
if ($ao?->exists && ($ao->zone?->domain_id !== $this->fftn->zone->domain_id)) {
|
||||
Log::alert(sprintf('%s:! From address [%s] domain [%d] doesnt match packet domain [%d]?',self::LOGKEY,$msg->set->get('set_fftn'),$ao->zone?->domain_id,$this->fftn->zone->domain_id));
|
||||
@ -409,20 +407,17 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
|
||||
if (! $ao) {
|
||||
$so = System::createUnknownSystem();
|
||||
$ao = Address::createFTN($msg->set->get('set_fftn'),$so);
|
||||
|
||||
Log::alert(sprintf('%s:- From FTN [%s] is not defined, created new entry for (%d)',self::LOGKEY,$msg->set->get('set_fftn'),$ao->id));
|
||||
}
|
||||
|
||||
$msg->fftn_id = $ao->id;
|
||||
$msg->errors->forget('from');
|
||||
$msg->errors->forget('fftn_id');
|
||||
Log::alert(sprintf('%s:- From FTN [%s] is not defined, created new entry for (%d)',self::LOGKEY,$msg->set->get('set_fftn'),$ao->id));
|
||||
}
|
||||
|
||||
// If the $msg->tftn doesnt exist, we'll need to create it
|
||||
if ($msg->errors->has('to') && $this->tftn && $this->tftn->zone_id) {
|
||||
Log::debug(sprintf('%s:^ To address [%s] doesnt exist, it needs to be created',self::LOGKEY,$msg->set->get('set_tftn')));
|
||||
|
||||
$ao = Address::findFTN($msg->set->get('set_tftn'),TRUE,TRUE);
|
||||
$ao = Address::findFTN($msg->set->get('set_tftn'),TRUE);
|
||||
|
||||
if ($ao?->exists && ($ao->zone?->domain_id !== $this->tftn->zone->domain_id)) {
|
||||
Log::alert(sprintf('%s:! To address [%s] domain [%d] doesnt match packet domain [%d]?',self::LOGKEY,$msg->set->get('set_tftn'),$ao->zone?->domain_id,$this->fftn->zone->domain_id));
|
||||
@ -433,13 +428,10 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
|
||||
if (! $ao) {
|
||||
$so = System::createUnknownSystem();
|
||||
$ao = Address::createFTN($msg->set->get('set_fftn'),$so);
|
||||
|
||||
Log::alert(sprintf('%s:- To FTN [%s] is not defined, created new entry for (%d)',self::LOGKEY,$msg->set->get('set_tftn'),$ao->id));
|
||||
}
|
||||
|
||||
$msg->tftn_id = $ao->id;
|
||||
$msg->errors->forget('to');
|
||||
$msg->errors->forget('tftn_id');
|
||||
Log::alert(sprintf('%s:- To FTN [%s] is not defined, created new entry for (%d)',self::LOGKEY,$msg->set->get('set_tftn'),$ao->id));
|
||||
}
|
||||
|
||||
// If there is no fftn, then its from a system that we dont know about
|
||||
|
@ -100,7 +100,7 @@ class AddressIdle implements ShouldQueue
|
||||
$contact = TRUE;
|
||||
}
|
||||
|
||||
$ao->contacted = $contact;
|
||||
$ao->contacted = (! $contact);
|
||||
$result->push($ao);
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ class AddressIdle implements ShouldQueue
|
||||
$ao->role |= Address::NODE_DOWN;
|
||||
$ao->save();
|
||||
|
||||
$ao->contacted = $contact;
|
||||
$ao->contacted = (! $contact);
|
||||
$result->push($ao);
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ class AddressIdle implements ShouldQueue
|
||||
$ao->role |= Address::NODE_HOLD;
|
||||
$ao->save();
|
||||
|
||||
$ao->contacted = $contact;
|
||||
$ao->contacted = (! $contact);
|
||||
$result->push($ao);
|
||||
}
|
||||
|
||||
@ -198,7 +198,6 @@ class AddressIdle implements ShouldQueue
|
||||
->where('addresses.active',TRUE)
|
||||
->where('zones.active',TRUE)
|
||||
->where('domains.active',TRUE)
|
||||
->where(fn($query)=>$query->where('a.point_id',0)->orWhereNull('a.point_id'))
|
||||
->whereNotIn('a.id',our_address()->pluck('id'))
|
||||
->when($ao,fn($query)=>$query->where('addresses.id',$ao->id))
|
||||
->where('last_session','<',$age)
|
||||
|
@ -86,14 +86,6 @@ class PacketProcess implements ShouldQueue
|
||||
break;
|
||||
}
|
||||
|
||||
// If we dont have the tftn in the DB, then packet cannot be to us
|
||||
if (! $pkt->tftn) {
|
||||
Log::error(sprintf('%s:! Packet [%s] is from a system [%s] we dont know about?',self::LOGKEY,$this->filename,$pkt->tftn_t));
|
||||
|
||||
// @todo Notification::route('netmail',$pkt->fftn)->notify(new UnexpectedPacketToUs($this->filename));
|
||||
break;
|
||||
}
|
||||
|
||||
// Check the packet is to our address, if not we'll reject it.
|
||||
if (! our_address($pkt->tftn->zone->domain)->contains($pkt->tftn)) {
|
||||
Log::error(sprintf('%s:! Packet [%s] is not to our address? [%s]',self::LOGKEY,$this->filename,$pkt->tftn->ftn));
|
||||
|
@ -175,11 +175,10 @@ class Address extends Model
|
||||
*
|
||||
* @param string $address
|
||||
* @param bool $trashed
|
||||
* @param bool $recent
|
||||
* @return Address|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function findFTN(string $address,bool $trashed=FALSE,bool $recent=FALSE): ?self
|
||||
public static function findFTN(string $address,bool $trashed=FALSE): ?self
|
||||
{
|
||||
$ftn = self::parseFTN($address);
|
||||
$o = NULL;
|
||||
@ -188,11 +187,8 @@ class Address extends Model
|
||||
->select('addresses.*')
|
||||
->join('zones',['zones.id'=>'addresses.zone_id'])
|
||||
->join('domains',['domains.id'=>'zones.domain_id'])
|
||||
->when($trashed,function($query) use ($recent) {
|
||||
return $query->withTrashed()
|
||||
->orderBy('updated_at','DESC')
|
||||
->when($recent,fn($query)=>$query->where(fn($query)=>$query
|
||||
->where('deleted_at','>=',Carbon::now()->subMonth())->orWhereNull('deleted_at')));
|
||||
->when($trashed,function($query) {
|
||||
$query->withTrashed();
|
||||
},function($query) {
|
||||
$query->active();
|
||||
})
|
||||
|
@ -184,13 +184,13 @@ final class Echomail extends Model implements Packet
|
||||
Log::debug(sprintf('%s:^ Message [%d] from point address is [%d]',self::LOGKEY,$model->id,$model->fftn->point_id));
|
||||
|
||||
// Make sure our sender is first in the path
|
||||
if (($model->fftn->point_id === 0) && (! $model->isFlagSet(Message::FLAG_LOCAL)) && (! $path->contains($model->fftn_id))) {
|
||||
if ((! $model->isFlagSet(Message::FLAG_LOCAL)) && (! $path->contains($model->fftn_id))) {
|
||||
Log::alert(sprintf('%s:? Echomail adding sender to start of PATH [%s].',self::LOGKEY,$model->fftn_id));
|
||||
$path->prepend($model->fftn_id);
|
||||
}
|
||||
|
||||
// Make sure our pktsrc is last in the path
|
||||
if ($model->set->has('set_sender') && (! $path->contains($model->set->get('set_sender')->id)) && ($model->set->get('set_sender')->point_id === 0)) {
|
||||
if ($model->set->has('set_sender') && (! $path->contains($model->set->get('set_sender')->id))) {
|
||||
Log::alert(sprintf('%s:? Echomail adding pktsrc to end of PATH [%s].',self::LOGKEY,$model->set->get('set_sender')->ftn));
|
||||
$path->push($model->set->get('set_sender')->id);
|
||||
}
|
||||
@ -215,13 +215,13 @@ final class Echomail extends Model implements Packet
|
||||
$seenby = self::parseAddresses('seenby',$model->set->get('set_seenby'),$model->fftn->zone,$rogue);
|
||||
|
||||
// Make sure our sender is in the seenby
|
||||
if (($model->fftn->point_id === 0) && (! $model->isFlagSet(Message::FLAG_LOCAL)) && (! $seenby->contains($model->fftn_id))) {
|
||||
if ((! $model->isFlagSet(Message::FLAG_LOCAL)) && (! $seenby->contains($model->fftn_id))) {
|
||||
Log::alert(sprintf('%s:? Echomail adding sender to SEENBY [%s].',self::LOGKEY,$model->fftn_id));
|
||||
$seenby->push($model->fftn_id);
|
||||
}
|
||||
|
||||
// Make sure our pktsrc is in the seenby
|
||||
if ($model->set->has('set_sender') && (! $seenby->contains($model->set->get('set_sender')->id)) && ($model->set->get('set_sender')->point_id === 0)) {
|
||||
if ($model->set->has('set_sender') && (! $seenby->contains($model->set->get('set_sender')->id))) {
|
||||
Log::alert(sprintf('%s:? Echomail adding pktsrc to SEENBY [%s].',self::LOGKEY,$model->set->get('set_sender')->ftn));
|
||||
$seenby->push($model->set->get('set_sender')->id);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Notifications\Netmails;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Notifications\Netmails;
|
||||
@ -49,7 +50,7 @@ class EchomailBadAddress extends Netmails
|
||||
|
||||
$msg->addText($this->sourceSummary($this->mo)."\r\r");
|
||||
|
||||
$msg->addText(sprintf("The address in this echomail [%s] is the wrong address for the domain [%s].\r\r",$this->mo->fftn,$ao->zone->domain->name));
|
||||
$msg->addText(sprintf("The address in this echomail [%s] is the wrong address for this domain [%s].\r\r",$this->mo->fftn,$ao->zone->domain->name));
|
||||
|
||||
$msg->addText("This echomail has been rejected and not stored here - so no downstream nodes will receive it. If you think this is a mistake, please let me know.\r\r");
|
||||
|
||||
|
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Netmails;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Notifications\Netmails;
|
||||
use App\Models\{Echomail,Netmail};
|
||||
use App\Traits\{MessagePath,PageTemplate};
|
||||
|
||||
class NetmailBadAddress extends Netmails
|
||||
{
|
||||
use MessagePath,PageTemplate;
|
||||
|
||||
private const LOGKEY = 'NBA';
|
||||
|
||||
private Netmail $mo;
|
||||
|
||||
/**
|
||||
* Send a sysop a message if they give us a message with a bad address in it.
|
||||
*
|
||||
* @param Echomail $mo
|
||||
*/
|
||||
public function __construct(Netmail $mo)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->mo = $mo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return Netmail
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function toNetmail(object $notifiable): Netmail
|
||||
{
|
||||
$o = $this->setupNetmail($notifiable);
|
||||
$ao = $notifiable->routeNotificationFor(static::via);
|
||||
|
||||
Log::info(sprintf('%s:+ Creating NETMAIL BAD ADDRESS netmail to [%s]',self::LOGKEY,$ao->ftn));
|
||||
|
||||
$o->subject = sprintf('Bad address in netmail [%s]',$this->mo->msgid);
|
||||
|
||||
// Message
|
||||
$msg = $this->page(FALSE,'badmsg');
|
||||
|
||||
$msg->addText($this->sourceSummary($this->mo)."\r\r");
|
||||
|
||||
$msg->addText(sprintf("The address in this netmail [%s] is the wrong address for the domain [%s].\r\r",$this->mo->set_fftn,$ao->zone->domain->name));
|
||||
|
||||
$msg->addText("This netmail has been rejected and not stored here - so no downstream node will receive it. If you think this is a mistake, please let me know.\r\r");
|
||||
|
||||
$msg->addText($this->message_path($this->mo));
|
||||
|
||||
$o->msg = $msg->render();
|
||||
$o->set_tagline = 'I enjoyed reading your message, even though nobody else will get it :)';
|
||||
|
||||
$o->save();
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ trait ParseAddresses
|
||||
// If domain should be flattened, look for node regardless of zone (within the list of zones for the domain)
|
||||
$ao = ($zone->domain->flatten)
|
||||
? 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&Address::ADDRESS_FIELD_MAX,$node&Address::ADDRESS_FIELD_MAX,$zone->domain->name),TRUE,TRUE);
|
||||
: 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) {
|
||||
case 'seenby':
|
||||
|
@ -8,12 +8,13 @@ RUN apk add zerotier-one -X http://dl-cdn.alpinelinux.org/alpine/v3.17/community
|
||||
COPY init-container /sbin/
|
||||
COPY . /var/www/html/
|
||||
|
||||
RUN mkdir -p ${COMPOSER_HOME} \
|
||||
&& ([ -r auth.json ] && mv auth.json ${COMPOSER_HOME}) || true \
|
||||
&& touch .composer.refresh \
|
||||
&& mv .env.example .env \
|
||||
&& apk add --no-cache git \
|
||||
&& FORCE_PERMS=1 NGINX_START=FALSE /sbin/init \
|
||||
&& apk del --no-cache git \
|
||||
&& chmod +x /var/www/html/artisan /var/www/html/init-php.sh \
|
||||
&& rm -rf ${COMPOSER_HOME}/* .git* composer.lock
|
||||
RUN mkdir -p ${COMPOSER_HOME} && \
|
||||
([ -r auth.json ] && mv auth.json ${COMPOSER_HOME}) || true && \
|
||||
touch .composer.refresh && \
|
||||
mv .env.example .env && \
|
||||
apk add --no-cache git && \
|
||||
FORCE_PERMS=1 NGINX_START=FALSE /sbin/init && \
|
||||
apk del --no-cache git && \
|
||||
chmod +x /var/www/html/artisan /var/www/html/init-php.sh && \
|
||||
touch .migrate && \
|
||||
rm -rf ${COMPOSER_HOME}/*
|
||||
|
Loading…
Reference in New Issue
Block a user