From 3852e69fcc85deef811415add067b3f80e89a9e6 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 19 Oct 2024 18:34:50 +1100 Subject: [PATCH] When originating a connection, ensure we dont do any HAPROXY stuff --- app/Classes/Sock/SocketClient.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Classes/Sock/SocketClient.php b/app/Classes/Sock/SocketClient.php index d7f8829..a3f051c 100644 --- a/app/Classes/Sock/SocketClient.php +++ b/app/Classes/Sock/SocketClient.php @@ -48,7 +48,7 @@ final class SocketClient { /** @var string Data in the RX buffer */ private string $rx_buf = ''; - public function __construct (\Socket $connection) { + public function __construct (\Socket $connection,bool $originate=FALSE) { $this->connection = $connection; if ($this->type === SOCK_STREAM) { @@ -56,7 +56,7 @@ final class SocketClient { socket_getpeername($connection,$this->address_remote,$this->port_remote); // If HAPROXY is used, work get the clients address - if (config('fido.haproxy')) { + if ((! $originate) && config('fido.haproxy')) { Log::debug(sprintf('%s:+ HAPROXY connection host [%s] on port [%d] (%s)',self::LOGKEY,$this->address_remote,$this->port_remote,$this->type)); if ($this->read(5,12) !== "\x0d\x0a\x0d\x0a\x00\x0d\x0aQUIT\x0a") @@ -184,7 +184,7 @@ final class SocketClient { * @param string $address * @param int $port * @return static - * @throws SocketException + * @throws SocketException|HAproxyException */ public static function create(string $address,int $port): self { @@ -207,6 +207,7 @@ final class SocketClient { throw new SocketException(SocketException::CANT_CONNECT,sprintf('%s doesnt resolved to an IPv4/IPv6 address',$address)); $result = FALSE; + $socket = NULL; foreach ($resolved as $address) { try { @@ -236,7 +237,7 @@ final class SocketClient { if ($result === FALSE) throw new SocketException(SocketException::CANT_CONNECT,socket_strerror(socket_last_error($socket))); - return new self($socket); + return new self($socket,TRUE); } /**