From 86c27a3f1747bc8b1b71eb5b882fbd5fb7cedc2b Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 24 May 2024 11:04:25 +1000 Subject: [PATCH] Show users hub connection details for their domains --- app/Http/Controllers/HomeController.php | 10 +++- app/Models/User.php | 1 + app/helpers.php | 30 ++++++++++ resources/views/dashboard.blade.php | 80 ++++++++++++++++++++++++- 4 files changed, 117 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index f7b44dc..66a8601 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -10,7 +10,7 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Gate; use App\Classes\File; -use App\Classes\FTN\{Message,Packet}; +use App\Classes\FTN\Packet; use App\Http\Requests\SetupRequest; use App\Models\File as FileModel; use App\Models\{Address,Echomail,Netmail,Setup,System}; @@ -235,6 +235,12 @@ class HomeController extends Controller ->with('o',$o); } + /** + * Return a list of unsent items + * + * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Foundation\Application + * @see \App\Jobs\AddressIdle:class + */ public function status() { $date = Carbon::now()->yesterday()->endOfday(); @@ -262,7 +268,7 @@ class HomeController extends Controller ->union(Address::UncollectedFilesTotal() ->where('files.created_at','<',$this->yesterdayEOD()) ),'a') - ->where('systems.active',true) + ->where('systems.active',TRUE) ->where('addresses.active',TRUE) ->where('zones.active',TRUE) ->where('domains.active',TRUE) diff --git a/app/Models/User.php b/app/Models/User.php index 24a982b..efdaab8 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -86,6 +86,7 @@ class User extends Authenticatable implements MustVerifyEmail ->where('zones.domain_id',$o->id); }) ->where('system_user.user_id',$this->id) + ->activeFTN() ->with(['zone.domain']) ->get(); } diff --git a/app/helpers.php b/app/helpers.php index b22298b..70fb4c7 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -131,6 +131,36 @@ function our_address(Domain|Address $o=NULL): Collection|Address|NULL } } +function our_hostname(Address $o): string +{ + $our = our_address($o->domain)->first(); + + switch ($our->role_id) { + case Address::NODE_ZC: + $domain = collect(explode('.',gethostname()))->forget(0) + ->prepend(sprintf('z%d',$our->zone->zone_id)); + break; + + case Address::NODE_NC: + $domain = collect(explode('.',gethostname()))->forget(0) + ->prepend(sprintf('z%d',$our->zone->zone_id)) + ->prepend(sprintf('n%d',$our->host_id)); + break; + + case Address::NODE_HC: + $domain = collect(explode('.',gethostname()))->forget(0) + ->prepend(sprintf('z%d',$our->zone->zone_id)) + ->prepend(sprintf('n%d',$our->host_id)) + ->prepend(sprintf('f%d',$our->node_id)); + break; + + default: + $domain = collect(explode('.',gethostname())); + } + + return $domain->join('.'); +} + /** * Return a list of nodes that collect mail directly from us * diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 4e0116b..0f41107 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -3,7 +3,12 @@ Dashboard @endsection -@php($user->load(['systems.akas.zone.domain.echoareas','systems.akas.echoareas'])) +@php +use App\Classes\Protocol\Binkp; +use App\Models\Setup; +$user->load(['systems.akas.zone.domain.echoareas','systems.akas.echoareas']); +$setup = Setup::findOrFail(config('app.id')); +@endphp @section('content')

{{ $user->name }}

@@ -11,7 +16,78 @@ @if($user->systems->count())
-
+
+
+
+
+
+ +
+
+

Hub Details for your nets

+ +
+ @foreach($user + ->addresses() + ->diff(our_address()) + ->filter(fn($item)=>($item->point_id === 0)) + ->filter(function($item) { return $item->zone->domain->active && $item->zone->domain->public && $item->zone->domain->isManaged(); }) + ->sortBy('zone.domain.name') + ->groupBy('zone.domain.name') as $list) + +
+

+ {{ $x }} +

+ +
+
+

For your addresses in this domain: {!! $list->pluck('ftn')->join(', ') !!}, you'll need to use the following details:

+
+ + + + + + + + + + + + + + + + + + + +
+ Hub FTN Address + + {{ our_address($list->first())->ftn4d }} +
+ Hub FTN Domain + + {{ $x }} +
+ Hub Internet Address + + {{ our_hostname($list->first()) }} +
+ Hub Internet Ports + + BINKP: {{ $setup->binkp_port }} MD5 Mode: {{$setup->optionGet(Binkp::F_MD,'binkp_options') ? 'YES' : 'NO' }}
+ EMSI: {{ $setup->emsi_port }} Protocol: Zmodem
+
+
+
+
+ @endforeach +
+
+