Added SEEN-BY/PATH processing, dont show networks that are not public, minor other formatting
This commit is contained in:
parent
ad21285a8c
commit
9f762a642c
@ -22,6 +22,8 @@ use App\Traits\EncodeUTF8;
|
|||||||
*/
|
*/
|
||||||
class Message extends FTNBase
|
class Message extends FTNBase
|
||||||
{
|
{
|
||||||
|
private const LOGKEY = 'FM-';
|
||||||
|
|
||||||
use EncodeUTF8;
|
use EncodeUTF8;
|
||||||
|
|
||||||
private const cast_utf8 = [
|
private const cast_utf8 = [
|
||||||
@ -103,7 +105,11 @@ class Message extends FTNBase
|
|||||||
private array $point; // Point the message belongs to (Netmail)
|
private array $point; // Point the message belongs to (Netmail)
|
||||||
|
|
||||||
private Collection $path; // FTS-0004.001 The message PATH lines
|
private Collection $path; // FTS-0004.001 The message PATH lines
|
||||||
|
private Collection $pathaddress; // Collection of Addresses after parsing seenby
|
||||||
|
private Collection $rogue_path; // Collection of FTNs in the Seen-by that are not defined
|
||||||
private Collection $seenby; // FTS-0004.001 The message SEEN-BY lines
|
private Collection $seenby; // FTS-0004.001 The message SEEN-BY lines
|
||||||
|
private Collection $seenaddress; // Collection of Addresses after parsing seenby
|
||||||
|
private Collection $rogue_seen; // Collection of FTNs in the Seen-by that are not defined
|
||||||
private Collection $via; // The path the message has gone using Via lines (Netmail)
|
private Collection $via; // The path the message has gone using Via lines (Netmail)
|
||||||
private Collection $unknown; // Temporarily hold attributes we have no logic for.
|
private Collection $unknown; // Temporarily hold attributes we have no logic for.
|
||||||
|
|
||||||
@ -179,6 +185,8 @@ class Message extends FTNBase
|
|||||||
|
|
||||||
$this->path = collect();
|
$this->path = collect();
|
||||||
$this->seenby = collect();
|
$this->seenby = collect();
|
||||||
|
$this->rogue_seen = collect();
|
||||||
|
$this->rogue_path = collect();
|
||||||
$this->via = collect();
|
$this->via = collect();
|
||||||
$this->unknown = collect();
|
$this->unknown = collect();
|
||||||
}
|
}
|
||||||
@ -297,6 +305,10 @@ class Message extends FTNBase
|
|||||||
case 'kludge':
|
case 'kludge':
|
||||||
case 'path':
|
case 'path':
|
||||||
case 'seenby':
|
case 'seenby':
|
||||||
|
case 'pathaddress':
|
||||||
|
case 'seenaddress':
|
||||||
|
case 'rogue_path':
|
||||||
|
case 'rogue_seen':
|
||||||
case 'via':
|
case 'via':
|
||||||
|
|
||||||
case 'errors':
|
case 'errors':
|
||||||
@ -436,7 +448,6 @@ class Message extends FTNBase
|
|||||||
$return .= sprintf(" * Origin: %s\r",$this->origin);
|
$return .= sprintf(" * Origin: %s\r",$this->origin);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dump([__METHOD__=>'NOT LOCAL']);
|
|
||||||
$return .= $this->message."\r";
|
$return .= $this->message."\r";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,6 +529,46 @@ class Message extends FTNBase
|
|||||||
return ($this->flags & $flag);
|
return ($this->flags & $flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the Seenby/path lines and return a collection of addresses
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param Collection $addresses
|
||||||
|
* @param Collection $rogue
|
||||||
|
* @return Collection
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
private function parseAddresses(string $type,Collection $addresses,Collection &$rogue): Collection
|
||||||
|
{
|
||||||
|
$nodes = collect();
|
||||||
|
|
||||||
|
$net = NULL;
|
||||||
|
foreach ($addresses as $line) {
|
||||||
|
foreach (explode(' ',$line) as $item) {
|
||||||
|
if (($x=strpos($item,'/')) !== FALSE) {
|
||||||
|
$net = (int)substr($item,0,$x);
|
||||||
|
$node = (int)substr($item,$x+1);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$node = (int)$item;
|
||||||
|
};
|
||||||
|
|
||||||
|
$ftn = sprintf('%d:%d/%d',$this->fz,$net&0x7fff,$node&0x7fff);
|
||||||
|
$ao = Address::findFTN($ftn);
|
||||||
|
|
||||||
|
if (! $ao) {
|
||||||
|
Log::alert(sprintf('%s:! Undefined Node [%s] in %s.',self::LOGKEY,$ftn,$type));
|
||||||
|
$rogue->push($ftn);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$nodes->push($ao);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $nodes;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the data after the ORIGIN
|
* Process the data after the ORIGIN
|
||||||
* There may be kludge lines after the origin - notably SEEN-BY
|
* There may be kludge lines after the origin - notably SEEN-BY
|
||||||
@ -687,6 +738,14 @@ class Message extends FTNBase
|
|||||||
else
|
else
|
||||||
$this->unknown->push(chop($v,"\r"));
|
$this->unknown->push(chop($v,"\r"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse SEEN-BY
|
||||||
|
if ($this->seenby->count())
|
||||||
|
$this->seenaddress = $this->parseAddresses('seenby',$this->seenby,$this->rogue_seen);
|
||||||
|
|
||||||
|
// Parse PATH
|
||||||
|
if ($this->path->count())
|
||||||
|
$this->pathaddress = $this->parseAddresses('path',$this->path,$this->rogue_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +80,7 @@ class Packet extends FTNBase
|
|||||||
*/
|
*/
|
||||||
public static function open(File $file,Domain $domain=NULL): self
|
public static function open(File $file,Domain $domain=NULL): self
|
||||||
{
|
{
|
||||||
Log::debug(sprintf('%s:Opening Packet [%s]',self::LOGKEY,$file));
|
Log::debug(sprintf('%s:+ Opening Packet [%s]',self::LOGKEY,$file));
|
||||||
|
|
||||||
$f = fopen($file,'r');
|
$f = fopen($file,'r');
|
||||||
$fstat = fstat($f);
|
$fstat = fstat($f);
|
||||||
@ -366,7 +366,7 @@ class Packet extends FTNBase
|
|||||||
// If the message is invalid, we'll ignore it
|
// If the message is invalid, we'll ignore it
|
||||||
if ($msg->errors && $msg->errors->messages()->has('from')) {
|
if ($msg->errors && $msg->errors->messages()->has('from')) {
|
||||||
$this->errors->push($msg);
|
$this->errors->push($msg);
|
||||||
Log::error(sprintf('%s:%s Skipping...',self::LOGKEY,join('|',$msg->errors->messages()->get('from'))));
|
Log::error(sprintf('%s:! %s Skipping...',self::LOGKEY,join('|',$msg->errors->messages()->get('from'))));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->messages->push($msg);
|
$this->messages->push($msg);
|
||||||
|
@ -33,12 +33,11 @@ final class Ping extends Process
|
|||||||
$ftns = Setup::findOrFail(config('app.id'))->system->match($msg->fftn_o->zone)->first();
|
$ftns = Setup::findOrFail(config('app.id'))->system->match($msg->fftn_o->zone)->first();
|
||||||
|
|
||||||
$reply = sprintf("Your ping was received here on %s and it looks like you sent it on %s. If that is correct, then it took %s to get here.\r",
|
$reply = sprintf("Your ping was received here on %s and it looks like you sent it on %s. If that is correct, then it took %s to get here.\r",
|
||||||
$msg->date->toDateTimeString(),
|
$msg->date->utc()->toDateTimeString(),
|
||||||
Carbon::now()->toDateTimeString(),
|
Carbon::now()->utc()->toDateTimeString(),
|
||||||
$msg->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
|
$msg->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
|
||||||
);
|
);
|
||||||
|
|
||||||
$reply .= "\r";
|
|
||||||
$reply .= "\r";
|
$reply .= "\r";
|
||||||
$reply .= "Your message travelled along this path on the way here:\r";
|
$reply .= "Your message travelled along this path on the way here:\r";
|
||||||
foreach ($msg->via as $path)
|
foreach ($msg->via as $path)
|
||||||
|
@ -5,15 +5,19 @@ namespace App\Http\Controllers;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
use App\Classes\FTN\Packet;
|
use App\Classes\FTN\Packet;
|
||||||
use App\Models\{Address, Domain, Setup, System};
|
use App\Models\{Address,Domain,Setup};
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class HomeController extends Controller
|
class HomeController extends Controller
|
||||||
{
|
{
|
||||||
public function network(Domain $o)
|
public function network(Domain $o)
|
||||||
{
|
{
|
||||||
|
if (! $o->public && ! Gate::check('admin',$o))
|
||||||
|
abort(404);
|
||||||
|
|
||||||
$o->load(['zones.system','zones.domain']);
|
$o->load(['zones.system','zones.domain']);
|
||||||
|
|
||||||
return view('domain.view')
|
return view('domain.view')
|
||||||
|
@ -161,14 +161,6 @@ class ProcessPacket implements ShouldQueue
|
|||||||
|
|
||||||
// Else we are echomail
|
// Else we are echomail
|
||||||
} else {
|
} else {
|
||||||
Log::info(sprintf('%s: - Echomail [%s] in [%s] from (%s) [%s] to (%s).',
|
|
||||||
self::LOGKEY,
|
|
||||||
$this->msg->msgid,
|
|
||||||
$this->msg->echoarea,
|
|
||||||
$this->msg->user_to,$this->msg->tftn,
|
|
||||||
$this->msg->user_from,
|
|
||||||
));
|
|
||||||
|
|
||||||
$ea = Echoarea::where('name',$this->msg->echoarea)
|
$ea = Echoarea::where('name',$this->msg->echoarea)
|
||||||
->where('domain_id',$this->msg->fftn_o->zone->domain_id)
|
->where('domain_id',$this->msg->fftn_o->zone->domain_id)
|
||||||
->single();
|
->single();
|
||||||
@ -191,6 +183,7 @@ class ProcessPacket implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @todo Can the sender create it if it doesnt exist?
|
// @todo Can the sender create it if it doesnt exist?
|
||||||
|
// @todo Can the sender send messages to this area?
|
||||||
// - Create it, or
|
// - Create it, or
|
||||||
// - Else record in bad area
|
// - Else record in bad area
|
||||||
|
|
||||||
@ -207,11 +200,23 @@ class ProcessPacket implements ShouldQueue
|
|||||||
$o->msgid = $this->msg->msgid;
|
$o->msgid = $this->msg->msgid;
|
||||||
|
|
||||||
$o->msg = $this->msg->message_src;
|
$o->msg = $this->msg->message_src;
|
||||||
// @todo Record Path
|
$o->path = $this->msg->pathaddress->pluck('id')->jsonSerialize();
|
||||||
// @todo Record SeenBy
|
$o->rogue_path = $this->msg->rogue_path->jsonSerialize();
|
||||||
|
$o->seenby = $this->msg->seenaddress->pluck('id')->jsonSerialize();
|
||||||
|
$o->rogue_seen = $this->msg->rogue_path->jsonSerialize();
|
||||||
|
$o->toexport = TRUE;
|
||||||
|
|
||||||
$o->save();
|
$o->save();
|
||||||
|
|
||||||
|
Log::info(sprintf('%s: - Echomail [%s] in [%s] from (%s) [%s] to (%s) - [%s].',
|
||||||
|
self::LOGKEY,
|
||||||
|
$this->msg->msgid,
|
||||||
|
$this->msg->echoarea,
|
||||||
|
$this->msg->user_to,$this->msg->tftn,
|
||||||
|
$this->msg->user_from,
|
||||||
|
$o->id,
|
||||||
|
));
|
||||||
|
|
||||||
// If the message is to a bot, we'll process it
|
// If the message is to a bot, we'll process it
|
||||||
foreach (config('process.echomail') as $class) {
|
foreach (config('process.echomail') as $class) {
|
||||||
if ($class::handle($this->msg)) {
|
if ($class::handle($this->msg)) {
|
||||||
|
@ -51,6 +51,19 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="offset-1 col-2">
|
<div class="offset-1 col-2">
|
||||||
|
<label for="active" class="form-label">Active</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="btn-group" role="group">
|
||||||
|
<input type="radio" class="btn-check" name="active" id="active_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('active',$o->active))checked @endif>
|
||||||
|
<label class="btn btn-outline-success" for="active_yes">Yes</label>
|
||||||
|
|
||||||
|
<input type="radio" class="btn-check btn-danger" name="active" id="active_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('active',$o->active))checked @endif>
|
||||||
|
<label class="btn btn-outline-danger" for="active_no">No</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-2">
|
||||||
<label for="default" class="form-label">Default</label>
|
<label for="default" class="form-label">Default</label>
|
||||||
<div class="input-group has-validation">
|
<div class="input-group has-validation">
|
||||||
<div class="btn-group @error('default') is-invalid @enderror" role="group">
|
<div class="btn-group @error('default') is-invalid @enderror" role="group">
|
||||||
@ -67,19 +80,6 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-2">
|
|
||||||
<label for="active" class="form-label">Active</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="btn-group" role="group">
|
|
||||||
<input type="radio" class="btn-check" name="active" id="active_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('active',$o->active))checked @endif>
|
|
||||||
<label class="btn btn-outline-success" for="active_yes">Yes</label>
|
|
||||||
|
|
||||||
<input type="radio" class="btn-check btn-danger" name="active" id="active_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('active',$o->active))checked @endif>
|
|
||||||
<label class="btn btn-outline-danger" for="active_no">No</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
Loading…
Reference in New Issue
Block a user