From b2fa27e532148765e24ba661828cde238a8fd651 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 21 May 2026 16:38:34 +0000 Subject: [PATCH] Fix registration to IP address requires to-host --- .../resources/classes/event_guard_service.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/event_guard/resources/classes/event_guard_service.php b/app/event_guard/resources/classes/event_guard_service.php index bd6dac8de..8a6315f11 100644 --- a/app/event_guard/resources/classes/event_guard_service.php +++ b/app/event_guard/resources/classes/event_guard_service.php @@ -155,14 +155,15 @@ class event_guard_service extends service { // Registration failed - block IP address unless they are registered if (is_array($json_array) && $json_array['Event-Subclass'] == 'sofia::register_failure') { + // Debug info + $this->debug("sofia::register_failure network-ip ".$json_array['network-ip'].", to-host ".$json_array['to-host']); + // Not registered so block the address $is_valid_ip = filter_var($json_array['network-ip'], FILTER_VALIDATE_IP); if ($is_valid_ip && !$this->allow_access($json_array['network-ip'])) { $this->block_add($json_array['network-ip'], 'sip-auth-fail', $json_array); + continue; } - - // Debug info - $this->debug("sofia::register_failure network-ip ".$json_array['network-ip'].", to-host ".$json_array['to-host']); } // Sendevent CUSTOM event_guard:unblock @@ -202,17 +203,18 @@ class event_guard_service extends service { // Registration to the IP address if (is_array($json_array) && $json_array['Event-Subclass'] == 'sofia::pre_register') { - if (isset($json_array['network-ip'])) { - // Validate the IP address - $is_valid_ip = filter_var($json_array['network-ip'], FILTER_VALIDATE_IP); + if (isset($json_array['to-host'])) { + // Debug info + $this->debug("sofia::pre_register network-ip ".$json_array['network-ip'].", to-host ".$json_array['to-host']); + + // Validate the to-host IP address + $is_valid_ip = filter_var($json_array['to-host'], FILTER_VALIDATE_IP); // If not registered block the address if ($is_valid_ip && !$this->allow_access($json_array['network-ip'])) { $this->block_add($json_array['network-ip'], 'sip-auth-ip', $json_array); + continue; } - - // Debug info - $this->debug("sofia::pre_register network-ip ".$json_array['network-ip'].", to-host ".$json_array['to-host']); } }