From 6c36f7f9aa4b240a729d4231a707fd77e07ff372 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 26 Nov 2024 17:03:59 +1100 Subject: [PATCH] Fix UDP services (ie: DNS) --- app/Classes/Protocol.php | 11 ++++++++--- app/Classes/Sock/SocketServer.php | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Classes/Protocol.php b/app/Classes/Protocol.php index 59f5d3e..88896c1 100644 --- a/app/Classes/Protocol.php +++ b/app/Classes/Protocol.php @@ -360,11 +360,11 @@ abstract class Protocol * Setup a session with a remote client * * @param SocketClient $client Socket details of session - * @param Address|null $o If we have an address, we originated a session to this Address + * @param Address $o If we have an address, we originated a session to this Address * @return int * @throws \Exception */ - public function session(SocketClient $client,Address $o=NULL): int + public function session(SocketClient $client,Address $o): int { if ($o->exists) Log::withContext(['ftn'=>$o->ftn]); @@ -395,7 +395,7 @@ abstract class Protocol } // We are an IP node - $this->optionSet(self::O_TCP); + $this->client = $client; // @todo This appears to be a bug in laravel? Need to call app()->isDownForMaintenance() twice? app()->isDownForMaintenance(); @@ -405,6 +405,7 @@ abstract class Protocol case EMSI::class: Log::debug(sprintf('%s:- Starting EMSI',self::LOGKEY)); + $this->optionSet(self::O_TCP); $rc = $this->protocol_init(); if ($rc < 0) { Log::error(sprintf('%s:! Unable to start EMSI [%d]',self::LOGKEY,$rc)); @@ -419,10 +420,14 @@ abstract class Protocol case Binkp::class: Log::debug(sprintf('%s:- Starting BINKP',self::LOGKEY)); + $this->optionSet(self::O_TCP); $rc = $this->protocol_session($this->originate); break; + case DNS::class: + return $this->protocol_session(); + default: Log::error(sprintf('%s:! Unsupported session type [%s]',self::LOGKEY,get_class($this))); diff --git a/app/Classes/Sock/SocketServer.php b/app/Classes/Sock/SocketServer.php index dc1b44b..c0642a6 100644 --- a/app/Classes/Sock/SocketServer.php +++ b/app/Classes/Sock/SocketServer.php @@ -155,7 +155,8 @@ final class SocketServer { $r = new SocketClient($this->server); if ($r->hasData(30)) { - $this->handler[0]->{$this->handler[1]}($r); + if (! ($this->handler[0]->{$this->handler[1]}($r))) + exit(0); // Sleep so our thread has a chance to pick up the data from our connection usleep(50000);